public void ExtensibleEnumTypesAreMappedToSchema()
        {
            var modelType = typeof(CustomDaysOfWeek);

            Assert.AreEqual(false, modelType.IsPublic);
            Assert.AreEqual("NamespaceForEnums", modelType.Namespace);
            TypeAsserts.HasProperty(modelType, "FancyMonday", BindingFlags.Static | BindingFlags.Public);
        }
Пример #2
0
        public void NonRequiredParameterHasDefaultValue()
        {
            var method = TypeAsserts.HasPublicInstanceMethod(typeof(StringClient), "PutNull");

            var parameter = method.GetParameters().Single(p => p.Name == "stringBody");

            Assert.True(parameter.HasDefaultValue);
        }
Пример #3
0
        public void RequiredPropertiesAreNotSetableInInputModels()
        {
            var requiredInt    = TypeAsserts.HasProperty(typeof(InputModel), "RequiredInt", BindingFlags.Public | BindingFlags.Instance);
            var requiredString = TypeAsserts.HasProperty(typeof(InputModel), "RequiredString", BindingFlags.Public | BindingFlags.Instance);

            Assert.Null(requiredInt.SetMethod);
            Assert.Null(requiredString.SetMethod);
        }
        public void EnumTypesAreMappedToSchema()
        {
            var modelType = typeof(CustomFruitEnum);

            Assert.True(modelType.IsEnum);
            Assert.AreEqual(false, modelType.IsPublic);
            Assert.AreEqual("NamespaceForEnums", modelType.Namespace);
            TypeAsserts.HasField(modelType, "Apple2", BindingFlags.Static | BindingFlags.Public);
        }
Пример #5
0
        public void ParametersAreRenamed()
        {
            var method = TypeAsserts.HasPublicInstanceMethod(typeof(ServiceClient), "RenamedOperationAsync");

            // TODO: Add more tests here
            TypeAsserts.HasParameter(method, "renamedBodyParameter");
            TypeAsserts.HasParameter(method, "renamedPathParameter");
            TypeAsserts.HasParameter(method, "renamedQueryParameter");
        }
        public void MultipleInheritanceResolvedToBaseWithDiscriminatorOthersInlined()
        {
            var type = typeof(ClassThatInheritsFromBaseClassWithDiscriminatorAndSomeProperties);

            Assert.AreEqual(typeof(BaseClassWithDiscriminator), type.BaseType);
            // public
            Assert.AreEqual(3, type.GetProperties().Length);
            TypeAsserts.HasProperty(type, "DiscriminatorProperty", BindingFlags.Instance | BindingFlags.NonPublic);
            TypeAsserts.HasProperty(type, "BaseClassProperty", BindingFlags.Instance | BindingFlags.Public);
            TypeAsserts.HasProperty(type, "SomeProperty", BindingFlags.Instance | BindingFlags.Public);
            TypeAsserts.HasProperty(type, "SomeOtherProperty", BindingFlags.Instance | BindingFlags.Public);
        }
        public void ObjectTypesAreMappedToSchema()
        {
            var modelType = typeof(CustomizedModel);

            Assert.AreEqual(false, modelType.IsPublic);
            Assert.AreEqual("CustomNamespace", modelType.Namespace);

            var property = TypeAsserts.HasProperty(modelType, "PropertyRenamedAndTypeChanged", BindingFlags.Instance | BindingFlags.NonPublic);

            Assert.AreEqual(typeof(int?), property.PropertyType);

            var field = TypeAsserts.HasField(modelType, "CustomizedFancyField", BindingFlags.Instance | BindingFlags.NonPublic);

            Assert.AreEqual(typeof(CustomFruitEnum), field.FieldType);
        }
        public void StructsAreMappedToSchemas()
        {
            var modelType = typeof(RenamedModelStruct);

            Assert.AreEqual(false, modelType.IsPublic);
            Assert.AreEqual(true, modelType.IsValueType);
            Assert.AreEqual("CustomNamespace", modelType.Namespace);

            var property = TypeAsserts.HasProperty(modelType, "CustomizedFlattenedStringProperty", BindingFlags.Instance | BindingFlags.NonPublic);

            Assert.AreEqual(typeof(string), property.PropertyType);

            var field = TypeAsserts.HasProperty(modelType, "Fruit", BindingFlags.Instance | BindingFlags.Public);

            // TODO: Remove nullable after https://github.com/Azure/autorest.modelerfour/issues/231 is done
            Assert.AreEqual(typeof(CustomFruitEnum?), field.PropertyType);
        }
        public void MultipleInheritanceBaseTypeOverride()
        {
            var type = typeof(ClassThatInheritsFromBaseClassAndSomePropertiesWithBaseClassOverride);

            Assert.AreEqual(typeof(SomeProperties), type.BaseType);
            // public
            Assert.AreEqual(3, type.GetProperties().Length);

            var inlinedProperty = TypeAsserts.HasProperty(type, "BaseClassProperty", BindingFlags.Instance | BindingFlags.Public);

            Assert.AreEqual(type, inlinedProperty.DeclaringType);

            var inheritedProperty = TypeAsserts.HasProperty(type, "SomeProperty", BindingFlags.Instance | BindingFlags.Public);

            Assert.AreEqual(typeof(SomeProperties), inheritedProperty.DeclaringType);

            inheritedProperty = TypeAsserts.HasProperty(type, "SomeOtherProperty", BindingFlags.Instance | BindingFlags.Public);
            Assert.AreEqual(typeof(SomeProperties), inheritedProperty.DeclaringType);
        }
        public void MultipleInheritanceResolvedToFirstClassWhenNoDiscriminatorOthersInlined()
        {
            var type = typeof(ClassThatInheritsFromBaseClassAndSomeProperties);

            Assert.AreEqual(typeof(BaseClass), type.BaseType);
            // public
            Assert.AreEqual(3, type.GetProperties().Length);

            var inheritedProperty = TypeAsserts.HasProperty(type, "BaseClassProperty", BindingFlags.Instance | BindingFlags.Public);

            Assert.AreEqual(typeof(BaseClass), inheritedProperty.DeclaringType);

            var inlinedProperty = TypeAsserts.HasProperty(type, "SomeProperty", BindingFlags.Instance | BindingFlags.Public);

            Assert.AreEqual(type, inlinedProperty.DeclaringType);

            inlinedProperty = TypeAsserts.HasProperty(type, "SomeOtherProperty", BindingFlags.Instance | BindingFlags.Public);
            Assert.AreEqual(type, inlinedProperty.DeclaringType);
        }
Пример #11
0
 public void PropertiesAreRenamed()
 {
     TypeAsserts.HasProperty(typeof(RenamedSchema), "RenamedProperty", BindingFlags.Instance | BindingFlags.Public);
     TypeAsserts.HasProperty(typeof(RenamedSchema), "RenamedPropertyString", BindingFlags.Instance | BindingFlags.Public);
 }