示例#1
0
        private static DtoLoaderConfiguration GetDtoLoaderConfiguration()
        {
            var configurationExpress = new DtoLoaderConfigurationExpression();

            configurationExpress.AddProfile(new MyUnitTestDtoLoaderProfile());

            var config = new DtoLoaderConfiguration(configurationExpress);

            return(config);
        }
示例#2
0
        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);
        }
示例#3
0
        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();
        }
示例#4
0
        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);
        }
示例#5
0
        private void Check_LoadRule_By_Profile(DtoLoaderConfiguration config)
        {
            config.GetLoadRule(typeof(OrderDto)).ShouldBeNull();

            config.GetLoadRule(typeof(ProductDto)).ShouldNotBeNull();
        }