Exemplo n.º 1
0
        public void TestCustomCollection3()
        {
            var options = new ImportOptions();

            var ccu = WsdlHelper.Import(customCollectionsMetadata, options);

            var type = ccu.FindType("MyCollection");

            Assert.That(type, Is.Not.Null, "#1a");
            Assert.That(type.BaseTypes.Count, Is.EqualTo(1), "#2a");

            var baseType = type.BaseTypes[0];

            Assert.That(baseType.BaseType, Is.EqualTo("System.Collections.Generic.List`1"), "#3a");
            Assert.That(baseType.TypeArguments.Count, Is.EqualTo(1), "#4a");
            Assert.That(baseType.TypeArguments[0].BaseType, Is.EqualTo("System.String"), "#5a");

            var attr = type.FindAttribute("System.Runtime.Serialization.CollectionDataContractAttribute");

            Assert.That(attr, Is.Not.Null, "#6a");

            var nameArg = attr.FindArgument("Name");

            Assert.That(nameArg, Is.Not.Null, "#7a");
            Assert.That(((CodePrimitiveExpression)nameArg.Value).Value, Is.EqualTo("MyCollection"), "#8a");

            var nsArg = attr.FindArgument("Namespace");

            Assert.That(nsArg, Is.Not.Null, "#9a");
            Assert.That(((CodePrimitiveExpression)nsArg.Value).Value, Is.EqualTo("http://schemas.datacontract.org/2004/07/TestWCF.Model"), "#10a");

            var itemArg = attr.FindArgument("ItemName");

            Assert.That(itemArg, Is.Not.Null);
            Assert.That(((CodePrimitiveExpression)itemArg.Value).Value, Is.EqualTo("string"), "#11a");

            type = ccu.FindType("MyCollectionOfdouble");
            Assert.That(type, Is.Not.Null, "#1b");
            Assert.That(type.BaseTypes.Count, Is.EqualTo(1), "#2b");

            baseType = type.BaseTypes[0];
            Assert.That(baseType.BaseType, Is.EqualTo("System.Collections.Generic.List`1"), "#3b");
            Assert.That(baseType.TypeArguments.Count, Is.EqualTo(1), "#4b");
            Assert.That(baseType.TypeArguments[0].BaseType, Is.EqualTo("System.Double"), "#5b");

            attr = type.FindAttribute("System.Runtime.Serialization.CollectionDataContractAttribute");
            Assert.That(attr, Is.Not.Null, "#6b");

            nameArg = attr.FindArgument("Name");
            Assert.That(nameArg, Is.Not.Null, "#7b");
            Assert.That(((CodePrimitiveExpression)nameArg.Value).Value, Is.EqualTo("MyCollectionOfdouble"), "#8b");

            nsArg = attr.FindArgument("Namespace");
            Assert.That(nsArg, Is.Not.Null, "#9b");
            Assert.That(((CodePrimitiveExpression)nsArg.Value).Value, Is.EqualTo("http://schemas.datacontract.org/2004/07/TestWCF.Model"), "#10b");

            itemArg = attr.FindArgument("ItemName");
            Assert.That(itemArg, Is.Not.Null);
            Assert.That(((CodePrimitiveExpression)itemArg.Value).Value, Is.EqualTo("double"), "#11b");
        }
Exemplo n.º 2
0
        public void TestSimpleDictionary2()
        {
            var options = new ImportOptions();

            options.ReferencedCollectionTypes.Add(typeof(SortedList <,>));

            var ccu = WsdlHelper.Import(collectionsMetadata, options);

            var method = ccu.FindMethod("MyServiceClient", "GetSimpleDictionary");

            Assert.That(method, Is.Not.Null, "#1");

            var ret = method.ReturnType;

            Assert.That(ret, Is.Not.Null, "#2");

            Assert.That(ret.ArrayRank, Is.EqualTo(0), "#3");
            Assert.That(ret.BaseType, Is.EqualTo("System.Collections.Generic.SortedList`2"), "#4");
            Assert.That(ret.TypeArguments.Count, Is.EqualTo(2), "#5");

            var keyType = ret.TypeArguments [0];

            Assert.That(keyType.BaseType, Is.EqualTo("System.Int32"), "#6");
            var valueType = ret.TypeArguments [1];

            Assert.That(valueType.BaseType, Is.EqualTo("System.String"), "#7");
        }
Exemplo n.º 3
0
        public void TestListOfStringArray()
        {
            var options = new ImportOptions();

            options.ReferencedCollectionTypes.Add(typeof(List <>));

            var ccu = WsdlHelper.Import(collectionsMetadata, options);

            var method = ccu.FindMethod("MyServiceClient", "GetListOfStringArray");

            Assert.That(method, Is.Not.Null, "#1");

            var ret = method.ReturnType;

            Assert.That(ret, Is.Not.Null, "#2");

            Assert.That(ret.ArrayRank, Is.EqualTo(0), "#3");
            Assert.That(ret.BaseType, Is.EqualTo("System.Collections.Generic.List`1"), "#4");
            Assert.That(ret.TypeArguments.Count, Is.EqualTo(1), "#5");

            var baseType = ret.TypeArguments [0];

            Assert.That(baseType.BaseType, Is.EqualTo("System.Collections.Generic.List`1"), "#6");
            Assert.That(baseType.TypeArguments.Count, Is.EqualTo(1), "#7");
            Assert.That(baseType.TypeArguments [0].BaseType, Is.EqualTo("System.String"), "#8");
        }
Exemplo n.º 4
0
        public void TestSimpleList()
        {
            var options = new ImportOptions();

            var ccu = WsdlHelper.Import(collectionsMetadata, options);

            var method = ccu.FindMethod("MyServiceClient", "GetSimpleList");

            Assert.That(method, Is.Not.Null, "#1");
            Assert.That(method.ReturnType, Is.Not.Null, "#2");

            Assert.That(method.ReturnType.ArrayRank, Is.EqualTo(1), "#3");
            Assert.That(method.ReturnType.BaseType, Is.EqualTo("System.Int32"), "#4");
        }
Exemplo n.º 5
0
        public void TestCustomCollection2()
        {
            var options = new ImportOptions();

            var ccu = WsdlHelper.Import(customCollectionsMetadata, options);

            var method = ccu.FindMethod("MyServiceClient", "GetCustomCollection2");

            Assert.That(method, Is.Not.Null, "#1");

            var ret = method.ReturnType;

            Assert.That(ret, Is.Not.Null, "#2");

            Assert.That(ret.ArrayRank, Is.EqualTo(0), "#3");
            Assert.That(ret.BaseType, Is.EqualTo("TestWCF.Model1.MyCollectionOfdouble"), "#4");
            Assert.That(ret.TypeArguments.Count, Is.EqualTo(0), "#5");
        }
Exemplo n.º 6
0
        public void TestSimpleList3()
        {
            var options = new ImportOptions();

            options.ReferencedCollectionTypes.Add(typeof(Dictionary <,>));
            options.ReferencedCollectionTypes.Add(typeof(ObservableCollection <>));

            var ccu = WsdlHelper.Import(collectionsMetadata, options);

            var method = ccu.FindMethod("MyServiceClient", "GetSimpleList");

            Assert.That(method, Is.Not.Null, "#1");

            var ret = method.ReturnType;

            Assert.That(ret, Is.Not.Null, "#2");

            Assert.That(ret.ArrayRank, Is.EqualTo(0), "#3");
            Assert.That(ret.BaseType, Is.EqualTo("System.Collections.ObjectModel.ObservableCollection`1"), "#4");
            Assert.That(ret.TypeArguments.Count, Is.EqualTo(1), "#5");
            Assert.That(ret.TypeArguments [0].BaseType, Is.EqualTo("System.Int32"), "#6");
        }
Exemplo n.º 7
0
 public void Setup()
 {
     collectionsMetadata       = WsdlHelper.GetMetadataSet("collections.wsdl");
     customCollectionsMetadata = WsdlHelper.GetMetadataSet("custom-collections.wsdl");
 }
Exemplo n.º 8
0
 public void Setup()
 {
     collectionsMetadata       = WsdlHelper.GetMetadataSet("Test/Resources/WSDL/collections.wsdl");
     customCollectionsMetadata = WsdlHelper.GetMetadataSet("Test/Resources/WSDL/custom-collections.wsdl");
 }