Пример #1
0
        public void SerializeStrings()
        {
            Bag <string> d = new Bag <string>(StringComparer.InvariantCultureIgnoreCase);

            d.Add("foo");
            d.Add("world");
            d.Add("hello");
            d.Add("elvis");
            d.Add("ELVIS");
            d.Add(null);
            d.Add("Foo");
            d.AddMany(new string[] { "1", "2", "3", "4", "5", "6" });
            d.AddMany(new string[] { "7", "8", "9", "1", "2", "3" });

            Bag <string> result = (Bag <string>)InterfaceTests.SerializeRoundTrip(d);


            InterfaceTests.TestReadWriteCollectionGeneric(result,
                                                          new string[]
            {
                "1", "2", "3", "4", "5", "6", "elvis", "elvis", "hello", "foo", "foo",
                "WORLD", null, "7", "8", "9", "1", "2", "3"
            }, false,
                                                          StringComparer.InvariantCultureIgnoreCase.Equals);
        }
Пример #2
0
        public void SerializeUnique()
        {
            UniqueStuff d = new UniqueStuff(), result = new UniqueStuff();

            d.objects = new InterfaceTests.Unique[] {
                new InterfaceTests.Unique("1"), new InterfaceTests.Unique("2"), new InterfaceTests.Unique("3"), new InterfaceTests.Unique("4"), new InterfaceTests.Unique("5"), new InterfaceTests.Unique("6"),
                new InterfaceTests.Unique("cool"), new InterfaceTests.Unique("elvis"), new InterfaceTests.Unique("hello"), new InterfaceTests.Unique("foo"), new InterfaceTests.Unique("world"), new InterfaceTests.Unique("elvis"), new InterfaceTests.Unique(null), null,
                new InterfaceTests.Unique("7"), new InterfaceTests.Unique("8"), new InterfaceTests.Unique("9"), new InterfaceTests.Unique("10"), new InterfaceTests.Unique("11"), new InterfaceTests.Unique("12")
            };
            d.set = new Set <InterfaceTests.Unique>();

            d.set.Add(d.objects[9]);
            d.set.Add(d.objects[10]);
            d.set.Add(d.objects[8]);
            d.set.Add(d.objects[11]);
            d.set.Add(d.objects[7]);
            d.set.Add(d.objects[12]);
            d.set.Add(d.objects[6]);
            d.set.Add(d.objects[13]);
            d.set.AddMany(new InterfaceTests.Unique[] { d.objects[0], d.objects[1], d.objects[2], d.objects[3], d.objects[4], d.objects[5] });
            d.set.AddMany(new InterfaceTests.Unique[] { d.objects[14], d.objects[15], d.objects[16], d.objects[17], d.objects[18], d.objects[19] });

            result = (UniqueStuff)InterfaceTests.SerializeRoundTrip(d);

            InterfaceTests.TestReadWriteCollectionGeneric(result.set, result.objects, false);

            for (int i = 0; i < result.objects.Length; ++i)
            {
                if (result.objects[i] != null)
                {
                    Assert.IsFalse(object.Equals(result.objects[i], d.objects[i]));
                }
            }
        }
Пример #3
0
        public void SerializeUnique()
        {
            var d  = new UniqueStuff();
            var u1 = new InterfaceTests.Unique("cool");
            var u2 = new InterfaceTests.Unique("elvis");

            d.objects = new InterfaceTests.Unique[]
            {
                new InterfaceTests.Unique("1"),
                new InterfaceTests.Unique("2"),
                new InterfaceTests.Unique("3"),
                new InterfaceTests.Unique("4"),
                new InterfaceTests.Unique("5"),
                new InterfaceTests.Unique("6"),
                u1,
                u2,
                new InterfaceTests.Unique("hello"),
                new InterfaceTests.Unique("foo"),
                new InterfaceTests.Unique("world"),
                u2,
                new InterfaceTests.Unique(null),
                null,
                new InterfaceTests.Unique("7"),
                new InterfaceTests.Unique("8"),
                new InterfaceTests.Unique("9"),
                u1,
                u2,
                new InterfaceTests.Unique("3")
            };

            d.bag = new Bag <InterfaceTests.Unique>
            {
                d.objects[9],
                d.objects[10],
                d.objects[8],
                d.objects[11],
                d.objects[7],
                d.objects[12],
                d.objects[6],
                d.objects[13]
            };

            d.bag.AddMany(new InterfaceTests.Unique[]
                          { d.objects[0], d.objects[1], d.objects[2], d.objects[3], d.objects[4], d.objects[5] });
            d.bag.AddMany(new InterfaceTests.Unique[]
                          { d.objects[14], d.objects[15], d.objects[16], d.objects[17], d.objects[18], d.objects[19] });

            UniqueStuff result = (UniqueStuff)InterfaceTests.SerializeRoundTrip(d);

            InterfaceTests.TestReadWriteCollectionGeneric(result.bag, result.objects, false);

            for (var i = 0; i < result.objects.Length; ++i)
            {
                if (result.objects[i] != null)
                {
                    Assert.IsFalse(Equals(result.objects[i], d.objects[i]));
                }
            }
        }
Пример #4
0
 public void Serialize()
 {
     Triple<int, string, string> p1 = new Triple<int, string,string>(-12, "hello", "world");
     Triple<string, string, double> p2 = new Triple<string, string, double>("hi", "elvis", 11);
     Triple<int, string,string> s1 = (Triple<int, string,string>)InterfaceTests.SerializeRoundTrip(p1);
     Triple<string, string, double> s2 = (Triple<string, string, double>)InterfaceTests.SerializeRoundTrip(p2);
     Assert.AreEqual(p1, s1);
     Assert.AreEqual(p2, s2);
 }
Пример #5
0
        public void Serialize()
        {
            var p1 = new Pair <int, string>(-12, "hello");
            var p2 = new Pair <string, double>("hi", 11);
            var s1 = (Pair <int, string>)InterfaceTests.SerializeRoundTrip(p1);
            var s2 = (Pair <string, double>)InterfaceTests.SerializeRoundTrip(p2);

            Assert.AreEqual(p1, s1);
            Assert.AreEqual(p2, s2);
        }
Пример #6
0
        public void SerializeStrings()
        {
            Set <string> d = new Set <string>();

            d.Add("foo");
            d.Add("world");
            d.Add("hello");
            d.Add("elvis");
            d.Add("elvis");
            d.Add(null);
            d.Add("cool");
            d.AddMany(new string[] { "1", "2", "3", "4", "5", "6" });
            d.AddMany(new string[] { "7", "8", "9", "10", "11", "12" });

            Set <string> result = (Set <string>)InterfaceTests.SerializeRoundTrip(d);

            InterfaceTests.TestReadWriteCollectionGeneric((ICollection <string>)result, new string[] { "1", "2", "3", "4", "5", "6", "cool", "elvis", "hello", "foo", "world", null, "7", "8", "9", "10", "11", "12" }, false);
        }
Пример #7
0
        public void SerializeStrings()
        {
            Deque <string> d = new Deque <string>();

            d.AddToFront("foo");
            d.AddToBack("world");
            d.AddToFront("hello");
            d.AddToBack("elvis");
            d.AddToFront("elvis");
            d.AddToBack(null);
            d.AddToFront("cool");
            d.AddManyToFront(new string[] { "1", "2", "3", "4", "5", "6" });
            d.AddManyToBack(new string[] { "7", "8", "9", "10", "11", "12" });

            Deque <string> result = (Deque <string>)InterfaceTests.SerializeRoundTrip(d);

            InterfaceTests.TestReadWriteListGeneric((IList <string>)result, new string[] { "1", "2", "3", "4", "5", "6", "cool", "elvis", "hello", "foo", "world", "elvis", null, "7", "8", "9", "10", "11", "12" });
        }