public void ResolveObjectContractWithFlattenCollectionTest()
        {
            var actual = new XmlContractResolver(NamingConventions.CamelCase)
                         .ResolveContract <TestClassWithFlattenCollection>();

            var expected = new XmlObjectContractBuilder <TestClassWithFlattenCollection>()
                           .SetName("testClassWithFlattenCollection")
                           .SetProperty(x => x.Items, p => p
                                        .SetName("number")
                                        .SetCollection()
                                        .SetItem("number"))
                           .Build();

            XmlContractAssert.AreEqual(expected, actual);
        }
        public void ResolveCollectionContractWithoutSystemAttributesTest()
        {
            var resolver  = new XmlContractResolver(NamingConventions.CamelCase, ignoreSystemAttributes: true);
            var valueType = typeof(TestClassWithCollections);

            var actual = resolver.ResolveContract(valueType);

            var expected = new XmlObjectContractBuilder <TestClassWithCollections>()
                           .SetName("testClassWithCollections")
                           .SetProperty(x => x.Array, p => p.SetName("array"))
                           .SetProperty(x => x.GenericList, p => p.SetName("genericList"))
                           .Build();

            XmlContractAssert.AreEqual(expected, actual);
        }
        public void ResolveObjectContractWithCollectionsTest()
        {
            var actual = new XmlContractResolver(NamingConventions.CamelCase)
                         .ResolveContract <TestClassWithCollections>();

            var expected = new XmlObjectContractBuilder <TestClassWithCollections>()
                           .SetName("testClassWithCollections")
                           .SetProperty(x => x.Array, p => p.SetName("array"))
                           .SetProperty(x => x.GenericList, p => p
                                        .SetName("Array2")
                                        .SetItem(new XmlName("Item", "http://example.org")))
                           .Build();

            XmlContractAssert.AreEqual(expected, actual);
        }
        public void ResolveEnumContractWithoutSystemAttributesTest()
        {
            var resolver  = new XmlContractResolver(NamingConventions.CamelCase, ignoreSystemAttributes: true);
            var valueType = typeof(TestEnum);

            var actual = resolver.ResolveContract(valueType);

            var expected = new XmlEnumContractBuilder <TestEnum>()
                           .SetName("testEnum")
                           .SetItem(TestEnum.True, "true")
                           .SetItem(TestEnum.False, "false")
                           .SetItem(TestEnum.SomethingElse, "somethingElse")
                           .BuildContract();

            XmlContractAssert.AreEqual(expected, actual);
        }
        public void ResolveGenericCollectionContractTest()
        {
            var resolver  = new XmlContractResolver(NamingConventions.CamelCase, ignoreSystemAttributes: true);
            var valueType = typeof(List <TestClass>);

            var actual = resolver.ResolveContract(valueType);

            var expected = new XmlObjectContractBuilder <List <TestClass> >()
                           .SetName("list")
                           .SetProperty(x => x.Capacity, "capacity")
                           .SetProperty(x => x.Count, "count")
                           .SetItem("testClass")
                           .Build();

            XmlContractAssert.AreEqual(expected, actual);
        }
        public void ResolveEnumContractTest()
        {
            var resolver  = new XmlContractResolver();
            var valueType = typeof(TestEnum);

            var actual = resolver.ResolveContract(valueType);

            var expected = new XmlEnumContractBuilder <TestEnum>()
                           .SetName("Enum")
                           .SetItem(TestEnum.True, "1")
                           .SetItem(TestEnum.False, "0")
                           .SetItem(TestEnum.SomethingElse, "-")
                           .BuildContract();

            XmlContractAssert.AreEqual(expected, actual);
        }
        public void ResolveObjectContractWithoutSystemAttributesTest()
        {
            var resolver  = new XmlContractResolver(NamingConventions.CamelCase, ignoreSystemAttributes: true);
            var valueType = typeof(TestClass);

            var actual = resolver.ResolveContract(valueType);

            var expected = new XmlObjectContractBuilder <TestClass>()
                           .SetName("testClass")
                           .SetProperty(x => x.Id, "id")
                           .SetProperty(x => x.Value, "value")
                           .SetProperty(x => x.Comment, "comment")
                           .Build();

            XmlContractAssert.AreEqual(expected, actual);
        }
        public void ResolveObjectContractWithElementKnownTypesTest()
        {
            var resolver = new XmlContractResolver(NamingConventions.CamelCase);

            var actual = resolver.ResolveContract <TestClassWithElementKnownTypes>();

            var expected = new XmlObjectContractBuilder <TestClassWithElementKnownTypes>()
                           .SetName("testClassWithElementKnownTypes")
                           .SetProperty(x => x.Value, p => p
                                        .SetName("object")
                                        .SetKnownType <int>("number")
                                        .SetKnownType <string>("string"))
                           .Build();

            XmlContractAssert.AreEqual(expected, actual);
        }
        public void ResolveObjectContractWithInnerTextTest()
        {
            var resolver = new XmlContractResolver(NamingConventions.Ignore);

            var valueType = typeof(TestClassWithInnerText);

            var actual = resolver.ResolveContract(valueType);

            var expected = new XmlObjectContractBuilder <TestClassWithInnerText>()
                           .SetName("TestClassWithInnerText")
                           .SetProperty(x => x.Comment, p => p
                                        .SetMappingType(XmlMappingType.InnerText))
                           .Build();

            XmlContractAssert.AreEqual(expected, actual);
        }
        public void ResolveObjectContractWithCollectionItemKnownTypesTest()
        {
            var actual = new XmlContractResolver(NamingConventions.CamelCase)
                         .ResolveContract <TestClassWithCollectionItemKnownTypes>();

            var expected = new XmlObjectContractBuilder <TestClassWithCollectionItemKnownTypes>()
                           .SetName("testClassWithCollectionItemKnownTypes")
                           .SetProperty(x => x.Items, p => p
                                        .SetName("items")
                                        .SetItem(i => i
                                                 .SetName("object")
                                                 .SetKnownType <int>("number")
                                                 .SetKnownType <string>("string")))
                           .Build();

            XmlContractAssert.AreEqual(expected, actual);
        }
        public void ResolveObjectContractTest()
        {
            var resolver  = new XmlContractResolver(NamingConventions.CamelCase);
            var valueType = typeof(TestClass);

            var actual = resolver.ResolveContract(valueType);

            var expected = new XmlObjectContractBuilder <TestClass>()
                           .SetName("test")
                           .SetProperty(x => x.Id, p => p
                                        .SetName(new XmlName("ID", "http://example.org"))
                                        .SetMappingType(XmlMappingType.Attribute))
                           .SetProperty(x => x.Value, p => p
                                        .SetName("VALUE")
                                        .SetNullValueHandling(XmlNullValueHandling.Include).SetOrder(10))
                           .SetProperty(x => x.Comment, "comment")
                           .Build();

            XmlContractAssert.AreEqual(expected, actual);
        }