private static DtoLoaderConfiguration GetDtoLoaderConfiguration() { var configurationExpress = new DtoLoaderConfigurationExpression(); configurationExpress.AddProfile(new MyUnitTestDtoLoaderProfile()); var config = new DtoLoaderConfiguration(configurationExpress); return(config); }
public void Should_Have_Correct_RelatedDtoProperties_By_Assembly() { var configurationExpress = new DtoLoaderConfigurationExpression(); var assemblyOptions = new RelatedDtoLoaderAssemblyOptions(); configurationExpress.AddAssemblies(assemblyOptions, typeof(RelatedDtoLoaderConfigurationTest).Assembly); var config = new DtoLoaderConfiguration(configurationExpress); Check_RelatedDtoPropertie_By_Profile(config); Check_LoadRule_By_Profile(config); }
private void Check_RelatedDtoPropertie_By_Profile(DtoLoaderConfiguration config) { config.GetRelatedDtoProperties(typeof(OrderDto)).ShouldNotBeNull(); config.GetRelatedDtoProperties(typeof(UnsupportedOrderDto)).ShouldBeNull(); config.GetRelatedDtoProperties(typeof(Order)).ShouldBeNull(); config.GetRelatedDtoProperties(typeof(Product)).ShouldBeNull(); config.GetRelatedDtoProperties(typeof(Product)).ShouldBeNull(); config.GetRelatedDtoProperties(typeof(ProductDto)).ShouldBeNull(); }
private DtoLoaderConfiguration CreateDtoLoaderConfiguration(IServiceProvider serviceProvider) { var options = serviceProvider.GetRequiredService <IOptions <RelatedDtoLoaderOptions> >().Value; var configuration = new DtoLoaderConfiguration(configurationExpression => { var context = new RelatedDtoLoaderConfigurationContext(configurationExpression, serviceProvider); foreach (var configurator in options.Configurators) { configurator(context); } }); return(configuration); }
private void Check_LoadRule_By_Profile(DtoLoaderConfiguration config) { config.GetLoadRule(typeof(OrderDto)).ShouldBeNull(); config.GetLoadRule(typeof(ProductDto)).ShouldNotBeNull(); }