Example #1
0
        public void IsSyncRootTest()
        {
            var         target     = new MockStringDictionary();
            ICollection collection = target;

            Assert.IsNotNull(collection.SyncRoot);
        }
Example #2
0
        public void IsSynchronizedTest()
        {
            var         target     = new MockStringDictionary();
            ICollection collection = target;

            Assert.IsFalse(collection.IsSynchronized);
        }
Example #3
0
        public void IndexerSetTest()
        {
            var target = new MockStringDictionary();

            ((IDictionary)target)["a"] = "b";
            Assert.IsTrue(target.ContainsKey("a"));
        }
Example #4
0
        public void AddTest()
        {
            var target = new MockStringDictionary();

            ((IDictionary)target).Add("a", "b");
            Assert.IsTrue(target.ContainsKey("a"));
        }
Example #5
0
        public void GetEnumeratorTest()
        {
            var target = new MockStringDictionary {
                { "a", "b" }, { "s", "r" }, { "f", "t" }
            };
            ICollection <KeyValuePair <string, string> > dictionary = target;
            IEnumerator enumerator = dictionary.GetEnumerator();

            enumerator.MoveNext();
            var current = (KeyValuePair <string, string>)enumerator.Current;

            Assert.AreEqual("a", current.Key);
            Assert.AreEqual("b", current.Value);


            enumerator.MoveNext();
            current = (KeyValuePair <string, string>)enumerator.Current;
            Assert.AreEqual("s", current.Key);
            Assert.AreEqual("r", current.Value);

            enumerator.MoveNext();
            current = (KeyValuePair <string, string>)enumerator.Current;
            Assert.AreEqual("f", current.Key);
            Assert.AreEqual("t", current.Value);
        }
Example #6
0
        public void IsReadOnlyTest()
        {
            var target = new MockStringDictionary();
            ICollection <KeyValuePair <string, string> > collection = target;

            Assert.IsFalse(collection.IsReadOnly);
        }
Example #7
0
        public void GetEnumeratorTest()
        {
            var target = new MockStringDictionary {
                { "a", "b" }, { "s", "r" }, { "f", "t" }
            };
            IDictionary dictionary = target;
            var         enumerator = dictionary.GetEnumerator();

            enumerator.MoveNext();
            var current = (DictionaryEntry)enumerator.Current;

            Assert.AreEqual("a", current.Key);
            Assert.AreEqual("b", current.Value);


            enumerator.MoveNext();
            current = (DictionaryEntry)enumerator.Current;
            Assert.AreEqual("s", current.Key);
            Assert.AreEqual("r", current.Value);

            enumerator.MoveNext();
            current = (DictionaryEntry)enumerator.Current;
            Assert.AreEqual("f", current.Key);
            Assert.AreEqual("t", current.Value);
        }
Example #8
0
        public void AddTest()
        {
            var target = new MockStringDictionary();
            ICollection <KeyValuePair <string, string> > collection = target;

            collection.Add(new KeyValuePair <string, string>("a", "b"));
            Assert.IsTrue(target.ContainsKey("a"));
        }
Example #9
0
        public void IsFixedSizeTest()
        {
            var target = new MockStringDictionary {
                { "a", "b" }
            };

            Assert.IsFalse(((IDictionary)target).IsFixedSize);
        }
Example #10
0
        public void IndexerGetTest()
        {
            var target = new MockStringDictionary {
                { "a", "b" }
            };

            Assert.AreEqual("b", ((IDictionary)target)["a"]);
        }
Example #11
0
        public void Dictionary()
        {
            var dictionary = new Dictionary <string, string> {
                { "a", "a" }
            };
            var target = new MockStringDictionary(dictionary);

            Assert.AreEqual(1, target.Count);
        }
Example #12
0
        public void RemoveNonExistingKeyTest()
        {
            var target = new MockStringDictionary {
                { "a", "a" }
            };
            ICollection <KeyValuePair <string, string> > collection = target;

            Assert.IsFalse(collection.Remove(new KeyValuePair <string, string>("b", "a")));
        }
Example #13
0
        public void RemoveTest()
        {
            var target = new MockStringDictionary {
                { "a", "b" }
            };

            ((IDictionary)target).Remove("a");

            Assert.IsFalse(target.ContainsKey("a"));
        }
Example #14
0
        public void ContainsTest()
        {
            var target = new MockStringDictionary {
                { "a", "b" }
            };
            ICollection <KeyValuePair <string, string> > collection = target;

            Assert.IsTrue(collection.Contains(new KeyValuePair <string, string>("a", "b")));
            Assert.IsFalse(collection.Contains(new KeyValuePair <string, string>("b", "b")));
            Assert.IsFalse(collection.Contains(new KeyValuePair <string, string>("a", "c")));
        }
Example #15
0
        public void DictionaryCompare()
        {
            var dictionary = new Dictionary <string, string> {
                { "a", "a" }
            };
            var target =
                new MockStringDictionary(dictionary, StringComparer.InvariantCultureIgnoreCase);

            Assert.AreEqual(StringComparer.InvariantCultureIgnoreCase, target.Comparer);
            Assert.AreEqual(1, target.Count);
        }
Example #16
0
        public void ContainsTest()
        {
            var target = new MockStringDictionary {
                { "a", "b" }
            };
            IDictionary dictionary = target;

            Assert.IsTrue(dictionary.Contains("a"));
            Assert.IsFalse(dictionary.Contains("b"));
            Assert.IsFalse(dictionary.Contains("c"));
            Assert.IsFalse(dictionary.Contains(2));
        }
Example #17
0
        public void ValuesTest()
        {
            var target = new MockStringDictionary {
                { "a", "b" }, { "f", "s" }, { "g", "z" }
            };
            var values = target.Values;

            Assert.AreEqual(3, values.Count);
            Assert.IsTrue(values.Contains("b"));
            Assert.IsTrue(values.Contains("s"));
            Assert.IsTrue(values.Contains("z"));
        }
Example #18
0
        public void KeysTest()
        {
            var target = new MockStringDictionary {
                { "a", "b" }, { "f", "b" }, { "g", "b" }
            };
            var keys = target.Keys;

            Assert.AreEqual(3, keys.Count);
            Assert.IsTrue(keys.Contains("a"));
            Assert.IsTrue(keys.Contains("f"));
            Assert.IsTrue(keys.Contains("g"));
        }
Example #19
0
        public void KeysTest()
        {
            var target = new MockStringDictionary {
                { "a", "b" }, { "f", "b" }, { "g", "b" }
            };
            var keys = ((IDictionary)target).Keys;

            Assert.AreEqual(3, keys.Count);
            var strings = new string[3];

            keys.CopyTo(strings, 0);
            Assert.AreEqual("a", strings[0]);
            Assert.AreEqual("f", strings[1]);
            Assert.AreEqual("g", strings[2]);
        }
Example #20
0
        public void ValuesTest()
        {
            var target = new MockStringDictionary {
                { "a", "b" }, { "f", "z" }, { "g", "x" }
            };
            var values = ((IDictionary)target).Values;

            Assert.AreEqual(3, values.Count);
            var strings = new string[3];

            values.CopyTo(strings, 0);
            Assert.AreEqual("b", strings[0]);
            Assert.AreEqual("z", strings[1]);
            Assert.AreEqual("x", strings[2]);
        }
Example #21
0
        public void CopyToTest()
        {
            var target = new MockStringDictionary {
                { "a", "b" }, { "g", "s" }, { "h", "x" }
            };
            ICollection <KeyValuePair <string, string> > collection = target;
            var pairs = new KeyValuePair <string, string> [3];

            collection.CopyTo(pairs, 0);
            Assert.AreEqual("a", pairs[0].Key);
            Assert.AreEqual("g", pairs[1].Key);
            Assert.AreEqual("h", pairs[2].Key);
            Assert.AreEqual("b", pairs[0].Value);
            Assert.AreEqual("s", pairs[1].Value);
            Assert.AreEqual("x", pairs[2].Value);
        }
Example #22
0
        public void AddInvalidValueTypeTest()
        {
            var target = new MockStringDictionary();

            ((IDictionary)target).Add("a", 2);
        }
        public void IndexerSetInvalidValueTypeTest()
        {
            var target = new MockStringDictionary();

            Assert.Throws <ArgumentException>(() => ((IDictionary)target)["a"] = 2);
        }
        public void AddInvalidValueTypeTest()
        {
            var target = new MockStringDictionary();

            Assert.Throws <ArgumentException>(() => ((IDictionary)target).Add("a", 2));
        }
Example #25
0
        public void IndexerSetInvalidKeyTypeTest()
        {
            var target = new MockStringDictionary();

            ((IDictionary)target)[2] = "a";
        }
Example #26
0
        public void IndexerSetInvalidValueTypeTest()
        {
            var target = new MockStringDictionary();

            ((IDictionary)target)["a"] = 2;
        }
Example #27
0
        public void IsReadOnlyTest()
        {
            var target = new MockStringDictionary();

            Assert.IsFalse(((IDictionary)target).IsReadOnly);
        }
Example #28
0
        public void AddInvalidKeyTypeTest()
        {
            var target = new MockStringDictionary();

            ((IDictionary)target).Add(2, "a");
        }
Example #29
0
        public void CapacityComparer()
        {
            var target = new MockStringDictionary(1, StringComparer.InvariantCultureIgnoreCase);

            Assert.AreEqual(StringComparer.InvariantCultureIgnoreCase, target.Comparer);
        }