Example #1
0
        public void TestOverallEquivalence([Values(false, true)] bool includeNull)
        {
            //--Arrange
            var collection = BuildSourceCollection(includeNull);
            var expected   = collection.ToLookup(x => x.key, x => x.element);

            //--Act/Assert
            var actual = new MutableLookup <long?, Guid>();

            foreach (var grouping in expected)
            {
                CollectionAssert.IsEmpty(actual[grouping.Key]);
                actual[grouping.Key] = grouping;
            }

            //--Assert
            Assert.IsFalse(actual.Contains(-1));
            CollectionAssert.AreEquivalent(expected.Select(x => x.Key), actual.Select(x => x.Key));
            foreach (var expectedGrouping in expected)
            {
                Assert.IsTrue(actual.Contains(expectedGrouping.Key));
                CollectionAssert.AreEquivalent(expectedGrouping, actual[expectedGrouping.Key]);
            }

            foreach (var(expectedGrouping, actualGrouping) in expected.Zip(actual, (e, a) => (e, a)))
            {
                Assert.AreEqual(expectedGrouping.Key, actualGrouping.Key);
                CollectionAssert.AreEquivalent(expectedGrouping, actualGrouping);
            }
        }
        public void ClearWithoutNull()
        {
            var lookup = new MutableLookup <string, string>();

            lookup.Add("F", "Foo");
            lookup.Add("F", "Foobar");
            lookup.Add("B", "Bar");

            lookup.Clear();
            Assert.AreEqual(0, lookup.Count);
            Assert.IsFalse(lookup.Contains("F"));
            Assert.IsFalse(lookup.Contains("B"));
        }
        public void ClearWithNull()
        {
            var lookup = new MutableLookup <string, string>();

            lookup.Add(null, "blah");
            lookup.Add("F", "Foo");

            lookup.Clear();

            Assert.AreEqual(0, lookup.Count);
            Assert.IsFalse(lookup.Contains(null));
            Assert.IsFalse(lookup.Contains("F"));
        }
Example #4
0
        public void ClearValueType()
        {
            var lookup = new MutableLookup<int, int>();
            lookup.Add (1, 10);
            lookup.Add (1, 12);
            lookup.Add (1, 13);
            lookup.Add (2, 21);
            lookup.Add (2, 22);
            lookup.Add (2, 23);

            lookup.Clear();
            Assert.AreEqual (0, lookup.Count);
            Assert.IsFalse (lookup.Contains (1));
            Assert.IsFalse (lookup.Contains (2));
        }
        public void ClearValueType()
        {
            var lookup = new MutableLookup <int, int>();

            lookup.Add(1, 10);
            lookup.Add(1, 12);
            lookup.Add(1, 13);
            lookup.Add(2, 21);
            lookup.Add(2, 22);
            lookup.Add(2, 23);

            lookup.Clear();
            Assert.AreEqual(0, lookup.Count);
            Assert.IsFalse(lookup.Contains(1));
            Assert.IsFalse(lookup.Contains(2));
        }
        public void DoesNotContainNull()
        {
            var lookup = new MutableLookup <string, string>();

            lookup.Add("F", "Foo");
            lookup.Add("F", "Foobar");
            lookup.Add("B", "Bar");

            Assert.IsFalse(lookup.Contains(null));
        }
        public void DoesNotContain()
        {
            var lookup = new MutableLookup <string, string>();

            lookup.Add(null, "blah");
            lookup.Add(null, "monkeys");
            lookup.Add("F", "Foo");
            lookup.Add("F", "Foobar");
            lookup.Add("B", "Bar");

            Assert.IsFalse(lookup.Contains("D"));
        }
Example #8
0
        public void ContainsNull()
        {
            var lookup = new MutableLookup <string, string>();

            lookup.Add(null, "blah");
            lookup.Add(null, "monkeys");
            lookup.Add("F", "Foo");
            lookup.Add("F", "Foobar");
            lookup.Add("B", "Bar");

            Assert.IsTrue(lookup.Contains(null));
        }
Example #9
0
        public void DoesNotContainNull()
        {
            var lookup = new MutableLookup<string, string>();
            lookup.Add("F", "Foo");
            lookup.Add("F", "Foobar");
            lookup.Add("B", "Bar");

            Assert.IsFalse (lookup.Contains (null));
        }
Example #10
0
        public void DoesNotContain()
        {
            var lookup = new MutableLookup<string, string>();
            lookup.Add(null, "blah");
            lookup.Add(null, "monkeys");
            lookup.Add("F", "Foo");
            lookup.Add("F", "Foobar");
            lookup.Add("B", "Bar");

            Assert.IsFalse (lookup.Contains ("D"));
        }
Example #11
0
        public void ClearWithoutNull()
        {
            var lookup = new MutableLookup<string, string>();
            lookup.Add("F", "Foo");
            lookup.Add("F", "Foobar");
            lookup.Add("B", "Bar");

            lookup.Clear();
            Assert.AreEqual (0, lookup.Count);
            Assert.IsFalse (lookup.Contains ("F"));
            Assert.IsFalse (lookup.Contains ("B"));
        }
Example #12
0
        public void ClearWithNull()
        {
            var lookup = new MutableLookup<string, string>();
            lookup.Add (null, "blah");
            lookup.Add ("F", "Foo");

            lookup.Clear();

            Assert.AreEqual (0, lookup.Count);
            Assert.IsFalse (lookup.Contains (null));
            Assert.IsFalse (lookup.Contains ("F"));
        }
Example #13
0
        public void ContainsNull()
        {
            var lookup = new MutableLookup<string, string>();
            lookup.Add(null, "blah");
            lookup.Add(null, "monkeys");
            lookup.Add("F", "Foo");
            lookup.Add("F", "Foobar");
            lookup.Add("B", "Bar");

            Assert.IsTrue (lookup.Contains (null));
        }