Beispiel #1
0
        public void Set()
        {
            var dict = new ListMultiDictionary <int, int> {
                [3] = new[] { 1, 2, 3 }, [4] = new[] { 1 }
            };

            dict[3] = null;
            dict[4] = new int[0];
            Assert.IsFalse(dict.ContainsKey(3));
            Assert.IsFalse(dict.ContainsKey(4));
        }
Beispiel #2
0
        public void Remove()
        {
            var dict = new ListMultiDictionary <int, int> {
                [3] = new[] { 1, 2, 3 }
            };

            Assert.IsFalse(dict.Remove(new KeyValuePair <int, IReadOnlyCollection <int> >(3, new[] { 1, 2 })));
            Assert.IsFalse(dict.Remove(new KeyValuePair <int, IReadOnlyCollection <int> >(4, new[] { 1, 2 })));
            Assert.IsTrue(dict.ContainsKey(3));

            Assert.IsTrue(dict.Remove(new KeyValuePair <int, IReadOnlyCollection <int> >(3, new[] { 1, 2, 3 })));
            Assert.IsFalse(dict.ContainsKey(3));
        }
Beispiel #3
0
        public void Clear()
        {
            var dict = new ListMultiDictionary <int, int> {
                [3] = new[] { 1, 2, 3 }
            };

            dict.Clear();
            Assert.AreEqual(0, dict.Count);
            Assert.IsFalse(dict.ContainsKey(3));

            // verify we can operate after Clear
            dict[3] = new[] { 3, 4, 5 };
            Assert.IsTrue(dict[3].SequenceEqual(new[] { 3, 4, 5 }));
        }
Beispiel #4
0
        public void RemoveAll()
        {
            var dict = new ListMultiDictionary <int, int> {
                [3] = new[] { 1, 2, 3, 4 }
            };

            Assert.AreEqual(2, dict.RemoveAll(3, new[] { 1, 2, 5 }));
            Assert.IsTrue(dict[3].SequenceEqual(new[] { 3, 4 }));
            Assert.AreEqual(0, dict.RemoveAll(3, new[] { 1, 2, 5 }));
            Assert.AreEqual(2, dict.RemoveAll(3, new[] { 3, 4 }));

            Assert.IsFalse(dict.ContainsKey(3));
            Assert.AreEqual(0, dict.RemoveAll(3, new[] { 1 }));
        }
Beispiel #5
0
        public void Remove_ValidInput_ReturnsDataChanged()
        {
            var dict = new ListMultiDictionary <int, int> {
                [3] = new[] { 1, 2, 3 }
            };

            Assert.IsTrue(dict.Remove(3, 1));
            Assert.IsFalse(dict.Remove(3, 4));
            Assert.IsFalse(dict.Remove(4, 2));

            Assert.IsTrue(dict[3].SequenceEqual(new[] { 2, 3 }));

            Assert.IsTrue(dict.Remove(3, 2));
            Assert.IsTrue(dict.Remove(3, 3));
            Assert.IsFalse(dict.ContainsKey(3));
        }