Exemple #1
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));
        }
Exemple #2
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));
        }
Exemple #3
0
        public void Equals()
        {
            var dict1 = new ListMultiDictionary <int, int> {
                [3] = new[] { 1, 2, 3, 4 }, [4] = new[] { 5 }
            };
            var dict2 = new ListMultiDictionary <int, int> {
                [3] = new[] { 1, 2, 3, 4 }, [4] = new[] { 5 }
            };

            Assert.IsTrue(dict1.Equals(dict2));
            dict1.Remove(3, 4);
            Assert.IsFalse(dict1.Equals(dict2));
            dict1.Add(3, 4);
            Assert.IsTrue(dict1.Equals(dict2));
        }