Files
social-media/tests/Application.UnitTests/Common/Mappings/MappingTests.cs
2024-08-03 04:17:04 -04:00

37 lines
970 B
C#

using System.Reflection;
using System.Runtime.CompilerServices;
using AutoMapper;
using Hutopy.Application.Common.Interfaces;
using NUnit.Framework;
namespace Hutopy.Application.UnitTests.Common.Mappings;
public class MappingTests
{
private readonly IConfigurationProvider _configuration;
private readonly IMapper _mapper;
public MappingTests()
{
_configuration = new MapperConfiguration(config =>
config.AddMaps(Assembly.GetAssembly(typeof(IApplicationDbContext))));
_mapper = _configuration.CreateMapper();
}
[Test]
public void ShouldHaveValidConfiguration()
{
_configuration.AssertConfigurationIsValid();
}
private object GetInstanceOf(Type type)
{
if (type.GetConstructor(Type.EmptyTypes) != null)
return Activator.CreateInstance(type)!;
// Type without parameterless constructor
return RuntimeHelpers.GetUninitializedObject(type);
}
}