Exemple #1
0
        public void Remove()
        {
            Bag <string> bag1 = new Bag <string>(StringComparer.InvariantCultureIgnoreCase);
            bool         b;

            b = bag1.Remove("Eric"); Assert.IsFalse(b);
            bag1.Add("hello");
            bag1.Add("foo");
            bag1.Add(null);
            bag1.Add(null);
            bag1.Add("HELLO");
            bag1.Add("Hello");
            b = bag1.Remove("hello"); Assert.IsTrue(b);
            InterfaceTests.TestCollection(bag1, new string[] { null, null, "foo", "hello", "hello" }, false);
            b = bag1.Remove("Hello"); Assert.IsTrue(b);
            b = bag1.Remove(null); Assert.IsTrue(b);
            b = bag1.Remove(null); Assert.IsTrue(b);
            b = bag1.Remove(null); Assert.IsFalse(b);
            bag1.Add("Hello");
            bag1.Add("Eric");
            bag1.Add(null);
            b = bag1.Remove(null); Assert.IsTrue(b);
            bag1.Add("ERIC");
            b = bag1.Remove("eRic"); Assert.IsTrue(b);
            b = bag1.Remove("eRic"); Assert.IsTrue(b);
            bag1.Clear();
            b = bag1.Remove(""); Assert.IsFalse(b);
        }
        public void ReadWriteCollection()
        {
            string[] s = { "Hello", "Goodbye", "Eric", "Clapton", "Rules" };

            ReadWriteTestCollection <string> coll = new ReadWriteTestCollection <string>(s);

            InterfaceTests.TestCollection <string>((ICollection)coll, s, true);
            InterfaceTests.TestReadWriteCollectionGeneric <string>((ICollection <string>)coll, s, true);
        }
Exemple #3
0
        public void ICollectionInterface()
        {
            string[]     s_array = { "Foo", "Eric", "Clapton", "hello", "goodbye", "C#" };
            Set <string> set1    = new Set <string>();

            foreach (string s in s_array)
            {
                set1.Add(s);
            }

            Array.Sort(s_array);
            InterfaceTests.TestCollection((ICollection)set1, s_array, false);
        }
        public void CheckList()
        {
            string[] s = { "Hello", "Goodbye", "Eric", "Clapton", "Rules" };

            List <string> coll = new List <string>(s);

            InterfaceTests.TestCollection <string>((ICollection)coll, s, true);
            InterfaceTests.TestReadWriteCollectionGeneric <string>((ICollection <string>)coll, s, true);

            IList <string> ro = new List <string>(s).AsReadOnly();

            InterfaceTests.TestReadonlyCollectionGeneric <string>(ro, s, true, null);
        }
Exemple #5
0
        public void ICollectionInterface()
        {
            string[]     s_array = { "Foo", "hello", "Eric", null, "Clapton", "hello", "goodbye", "C#", null };
            Bag <string> bag1    = new Bag <string>();

            foreach (string s in s_array)
            {
                bag1.Add(s);
            }

            Array.Sort(s_array);
            InterfaceTests.TestCollection <string>((ICollection)bag1, s_array, false);
        }
        public void CheckDictionaryKeyValues()
        {
            Dictionary <string, int> dict = new Dictionary <string, int>();

            dict["Eric"]     = 3;
            dict["Clapton"]  = 1;
            dict["Rules"]    = 4;
            dict["The"]      = 1;
            dict["Universe"] = 5;

            InterfaceTests.TestCollection <string>(dict.Keys, new string[] { "Eric", "Clapton", "Rules", "The", "Universe" }, false);
            InterfaceTests.TestReadonlyCollectionGeneric <string>(dict.Keys, new string[] { "Eric", "Clapton", "Rules", "The", "Universe" }, false, null);
            InterfaceTests.TestCollection <int>(dict.Values, new int[] { 1, 1, 3, 4, 5 }, false);
            InterfaceTests.TestReadonlyCollectionGeneric <int>(dict.Values, new int[] { 1, 1, 3, 4, 5 }, false, null);
        }