Example #1
0
        public void Create_With_Custom_NamingConventions_AsIConvention()
        {
            // arrange
            var options = new SchemaOptions();
            var naming  = new DefaultNamingConventions(
                new XmlDocumentationProvider(
                    new XmlDocumentationFileResolver(),
                    new NoOpStringBuilderPool()));
            var conventions = new Dictionary <(Type, string), List <CreateConvention> >
            {
                { (typeof(INamingConventions), null), new List <CreateConvention> {
                      s => naming
                  } }
            };

            // act
            var context = DescriptorContext.Create(
                options,
                new EmptyServiceProvider(),
                conventions,
                new Dictionary <string, object>(),
                new SchemaBuilder.LazySchema(),
                new AggregateSchemaInterceptor(),
                new AggregateTypeInterceptor());

            // assert
            Assert.Equal(naming, context.Naming);
            Assert.NotNull(context.TypeInspector);
            Assert.Equal(options, context.Options);
        }
Example #2
0
        public void Create_With_Custom_TypeInspector()
        {
            // arrange
            var options     = new SchemaOptions();
            var inspector   = new DefaultTypeInspector();
            var conventions = new Dictionary <(Type, string), List <CreateConvention> >();
            var services    = new DictionaryServiceProvider(
                typeof(ITypeInspector),
                inspector);

            // act
            var context = DescriptorContext.Create(
                options,
                services,
                conventions,
                new Dictionary <string, object>(),
                new SchemaBuilder.LazySchema(),
                new AggregateSchemaInterceptor(),
                new AggregateTypeInterceptor());

            // assert
            Assert.Equal(inspector, context.TypeInspector);
            Assert.NotNull(context.Naming);
            Assert.Equal(options, context.Options);
        }
Example #3
0
        public void Create_Without_Services()
        {
            // arrange
            // act
            DescriptorContext context = DescriptorContext.Create();

            // assert
            Assert.NotNull(context.Options);
            Assert.NotNull(context.Naming);
            Assert.NotNull(context.Inspector);
        }
        public void Create_OptionsNull_ArgumentException()
        {
            // arrange
            var service = new EmptyServiceProvider();

            // act
            Action action = () => DescriptorContext.Create(null, service);

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
        public void Create_ServicesNull_ArgumentException()
        {
            // arrange
            var options = new SchemaOptions();

            // act
            Action action = () => DescriptorContext.Create(options, null);

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
Example #6
0
        public void Create_ConventionsNull_ArgumentException()
        {
            // arrange
            var service = new EmptyServiceProvider();
            var options = new SchemaOptions();

            // act
            Action action = () => DescriptorContext.Create(options, service, null);

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
Example #7
0
        public void Create_OptionsNull_ArgumentException()
        {
            // arrange
            var service     = new EmptyServiceProvider();
            var conventions = new Dictionary <Type, IConvention>();

            // act
            Action action = () => DescriptorContext.Create(
                null, service, conventions, new Dictionary <string, object>());

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
Example #8
0
        public void Create_ServicesNull_ArgumentException()
        {
            // arrange
            var options     = new SchemaOptions();
            var conventions = new Dictionary <Type, IConvention>();

            // act
            Action action = () => DescriptorContext.Create(
                options, null, conventions, new Dictionary <string, object>());

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
        public void Create_ConventionsNull_ArgumentException()
        {
            // arrange
            var service = new EmptyServiceProvider();
            var options = new SchemaOptions();

            // act
            Action action = () => DescriptorContext.Create(
                options, service, null, new Dictionary <string, object>(),
                new SchemaBuilder.LazySchema());

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
        public void Create_With_Custom_TypeInspector()
        {
            // arrange
            var options   = new SchemaOptions();
            var inspector = new DefaultTypeInspector();
            var services  = new DictionaryServiceProvider(
                typeof(ITypeInspector),
                inspector);

            // act
            DescriptorContext context =
                DescriptorContext.Create(options, services);

            // assert
            Assert.Equal(inspector, context.Inspector);
            Assert.NotNull(context.Naming);
            Assert.Equal(options, context.Options);
        }
Example #11
0
        public void Create_With_Custom_NamingConventions_AsIConvention()
        {
            // arrange
            var options     = new SchemaOptions();
            var naming      = new DefaultNamingConventions();
            var conventions = new Dictionary <Type, IConvention>();

            conventions.Add(typeof(INamingConventions), naming);
            var services = new DictionaryServiceProvider();

            // act
            DescriptorContext context =
                DescriptorContext.Create(options, services, conventions);

            // assert
            Assert.Equal(naming, context.Naming);
            Assert.NotNull(context.Inspector);
            Assert.Equal(options, context.Options);
        }
        public void Create_With_Custom_NamingConventions_AsIConvention()
        {
            // arrange
            var options     = new SchemaOptions();
            var naming      = new DefaultNamingConventions();
            var conventions = new Dictionary <(Type, string), CreateConvention>
            {
                { (typeof(INamingConventions), null), s => naming }
            };

            // act
            var context = DescriptorContext.Create(
                options, new EmptyServiceProvider(), conventions, new Dictionary <string, object>(),
                new SchemaBuilder.LazySchema());

            // assert
            Assert.Equal(naming, context.Naming);
            Assert.NotNull(context.TypeInspector);
            Assert.Equal(options, context.Options);
        }