我正在使用nunit进行单元测试,并且我想在静态类中测试私有方法。 这是我的课程:
public static class ServiceModuleExtentions
{
public static void RegisterCoreServices(this IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<ICourseService, CourseService>();
var automapper = RegisterAutoMapperService();
serviceCollection.AddSingleton(automapper);
}
private static IMapper RegisterAutoMapperService()
{
// Auto Mapper Configurations
var mappingConfig = new MapperConfiguration(mc =>
{
mc.AddProfile(new MapperProfile());
});
IMapper mapper = mappingConfig.CreateMapper();
return mapper;
}
}
现在我的问题是如何为RegisterAutoMapperService方法编写单元测试?
这也是我的MapperProfile类:
public class MapperProfile : Profile
{
public MapperProfile()
{
CreateMap<Course, CourseVM>().ReverseMap();
}
}