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); }
public void Create_With_Custom_NamingConventions() { // arrange var options = new SchemaOptions(); var naming = new DefaultNamingConventions(); var conventions = new Dictionary <(Type, string), List <CreateConvention> >(); var services = new DictionaryServiceProvider( typeof(INamingConventions), naming); // act var context = DescriptorContext.Create( options, services, 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); }
public static DescriptorContext Create(IServiceProvider services) { if (services == null) { throw new ArgumentNullException(nameof(services)); } var naming = (INamingConventions)services.GetService( typeof(INamingConventions)); if (naming == null) { naming = new DefaultNamingConventions(); } var inspector = (ITypeInspector)services.GetService( typeof(ITypeInspector)); if (inspector == null) { inspector = new DefaultTypeInspector(); } return(new DescriptorContext(naming, inspector)); }
public void Input_Naming_Convention(Type type, string expectedName) { // arrange var conventions = new DefaultNamingConventions(); // act NameString typeName = conventions.GetTypeName(type, TypeKind.InputObject); // assert Assert.Equal(expectedName, typeName.Value); }
public void GetEnumValueDescription_AttributeDescription() { // arrange var namingConventions = new DefaultNamingConventions(); // act string result = namingConventions.GetEnumValueDescription(Foo.Baz); // assert Assert.Equal("Baz Desc", result); }
public void GetEnumValueDescription_XmlDescription() { // arrange var namingConventions = new DefaultNamingConventions(); // act var result = namingConventions.GetEnumValueDescription(EnumWithDocEnum.Value1); // assert Assert.Equal("Value1 Documentation", result); }
public void GetEnumValueDescription_NoDescription(object value) { // arrange var namingConventions = new DefaultNamingConventions(); // act var result = namingConventions.GetEnumValueDescription(value); // assert Assert.Null(result); }
public void GetEnumName(string runtimeName, string expectedSchemaName) { // arrange var namingConventions = new DefaultNamingConventions(); // act NameString schemaName = namingConventions.GetEnumValueName(runtimeName); // assert Assert.Equal(expectedSchemaName, schemaName.Value); }
public void GetEnumValueDescription_AttributeDescription() { // arrange var namingConventions = new DefaultNamingConventions( new XmlDocumentationProvider( new XmlDocumentationFileResolver(), new NoOpStringBuilderPool())); // act var result = namingConventions.GetEnumValueDescription(Foo.Baz); // assert Assert.Equal("Baz Desc", result); }
public void Input_Naming_Convention(Type type, string expectedName) { // arrange var namingConventions = new DefaultNamingConventions( new XmlDocumentationProvider( new XmlDocumentationFileResolver(), new NoOpStringBuilderPool())); // act NameString typeName = namingConventions.GetTypeName(type, TypeKind.InputObject); // assert Assert.Equal(expectedName, typeName.Value); }
public void GetEnumValueDescription_XmlDescription() { // arrange var namingConventions = new DefaultNamingConventions( new XmlDocumentationProvider( new XmlDocumentationFileResolver(), new NoOpStringBuilderPool())); // act var result = namingConventions.GetEnumValueDescription(EnumWithDocEnum.Value1); // assert Assert.Equal("Value1 Documentation", result); }
public void GetEnumValueDescription_NoDescription(object value) { // arrange var namingConventions = new DefaultNamingConventions( new XmlDocumentationProvider( new XmlDocumentationFileResolver(), new NoOpStringBuilderPool())); // act var result = namingConventions.GetEnumValueDescription(value); // assert Assert.Null(result); }
public void GetEnumName(string runtimeName, string expectedSchemaName) { // arrange var namingConventions = new DefaultNamingConventions( new XmlDocumentationProvider( new XmlDocumentationFileResolver(), new NoOpStringBuilderPool())); // act NameString schemaName = namingConventions.GetEnumValueName(runtimeName); // assert Assert.Equal(expectedSchemaName, schemaName.Value); }
public void Create_With_Custom_NamingConventions() { // arrange var options = new SchemaOptions(); var naming = new DefaultNamingConventions(); var services = new DictionaryServiceProvider( typeof(INamingConventions), naming); // act DescriptorContext context = DescriptorContext.Create(options, services); // 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); }