Exemplo n.º 1
0
        public void CanAddWithSameAggregateId()
        {
            var lookup = new ConcurrentLookup <ContextElement>();

            lookup.Add(new ContextElement("Type", "Subject", null));
            lookup.Add(new ContextElement("Type", "SubjectS", null));
        }
 public void Count_InitialCollectionContainsNoDuplicates_MatchesInitialCollection()
 {
     List<KeyValuePair<Guid, string>> collection =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(20))).ToList();
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     Assert.AreEqual(collection.Count, concurrentLookup.Count);
 }
        public void Count_InitialCollectionContainsNoDuplicates_MatchesInitialCollection()
        {
            List <KeyValuePair <Guid, string> > collection =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(20))).ToList();
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            Assert.AreEqual(collection.Count, concurrentLookup.Count);
        }
        public void Remove_AbsentKeyAndValue_ReturnsFalse()
        {
            Guid absentKey = Guid.NewGuid();
            IEnumerable <KeyValuePair <Guid, string> > collection =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(10)));
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            Assert.IsFalse(concurrentLookup.Remove(absentKey, Random.RandomString(15)));
        }
 public void GetEnumerator_InitialCollectionContainsDuplicatesKeys_GroupingKeysMatchUniqueCollectionKeys()
 {
     List<Guid> keys = Enumerable.Range(1, Random.Next(10, 100)).Select(n => Guid.NewGuid()).ToList();
     int numberOfDuplicates = Random.Next(1, keys.Count / 2);
     List<KeyValuePair<Guid, string>> collection = keys.Concat(keys.Take(numberOfDuplicates)).Select(
         key => new KeyValuePair<Guid, string>(key, Random.RandomString(20))
         ).ToList();
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     CollectionAssert.AreEquivalent(keys, concurrentLookup.Select(grouping => grouping.Key).ToList());
 }
Exemplo n.º 6
0
        public void CanTakeWhenUsingDuplicateIds()
        {
            var lookup = new ConcurrentLookup <ContextElement>();

            lookup.Add(new ContextElement("Type", "Subject", null));
            lookup.Add(new ContextElement("Type", "SubjectS", null));

            Assert.NotNull(lookup.Take("Type"));
            Assert.NotNull(lookup.Take("Type"));
        }
        public void Contains_ExistingKey_ReturnsTrue()
        {
            List <KeyValuePair <Guid, string> > collection =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(10))).ToList();
            Guid existingKey = collection[Random.Next(0, collection.Count)].Key;
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            Assert.IsTrue(concurrentLookup.Contains(existingKey));
        }
 public void Count_InitialCollectionContainsDuplicatesKeys_MatchesNumberOfUniqueKeys()
 {
     List<Guid> keys = Enumerable.Range(1, Random.Next(10, 100)).Select(n => Guid.NewGuid()).ToList();
     int numberOfDuplicates = Random.Next(1, keys.Count / 2);
     List<KeyValuePair<Guid, string>> collection = keys.Concat(keys.Take(numberOfDuplicates)).Select(
         key => new KeyValuePair<Guid, string>(key, Random.RandomString(20))
         ).ToList();
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     Assert.AreEqual(collection.Count - numberOfDuplicates, concurrentLookup.Count);
 }
        public void This_AbsentKey_ReturnsEmptyEnumeration()
        {
            Guid absentKey = Guid.NewGuid();
            IEnumerable <KeyValuePair <Guid, string> > collection =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(10)));
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            CollectionAssert.AreEquivalent(Enumerable.Empty <string>().ToList(), concurrentLookup[absentKey].ToList());
        }
        public void Remove_ExistingKeyAndValue_ReturnsTrue()
        {
            List <KeyValuePair <Guid, string> > collection =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(10))).ToList();
            KeyValuePair <Guid, string>     existing         = collection[Random.Next(0, collection.Count)];
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            Assert.IsTrue(concurrentLookup.Remove(existing.Key, existing.Value));
        }
        public void Remove_WrongValueForKey_ReturnsFalse()
        {
            List <KeyValuePair <Guid, string> > collection =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(10))).ToList();
            Guid existingKey = collection[Random.Next(0, collection.Count)].Key;
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            Assert.IsFalse(concurrentLookup.Remove(existingKey, Random.RandomString(50)));
        }
        public void GetEnumerator_InitialCollectionContainsDuplicatesKeys_GroupingKeysMatchUniqueCollectionKeys()
        {
            List <Guid> keys = Enumerable.Range(1, Random.Next(10, 100)).Select(n => Guid.NewGuid()).ToList();
            int         numberOfDuplicates = Random.Next(1, keys.Count / 2);
            List <KeyValuePair <Guid, string> > collection = keys.Concat(keys.Take(numberOfDuplicates)).Select(
                key => new KeyValuePair <Guid, string>(key, Random.RandomString(20))
                ).ToList();
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            CollectionAssert.AreEquivalent(keys, concurrentLookup.Select(grouping => grouping.Key).ToList());
        }
        public void TryGet_AbsentKey_ReturnsFalse()
        {
            Guid absentKey = Guid.NewGuid();
            IEnumerable <KeyValuePair <Guid, string> > collection =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(10)));
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);
            IGrouping <Guid, String>        output;

            Assert.IsFalse(concurrentLookup.TryGet(absentKey, out output));
        }
Exemplo n.º 14
0
        public void ReturnsNullWhenAllTaken()
        {
            var lookup = new ConcurrentLookup <ContextElement>();

            lookup.Add(new ContextElement("Type", "Subject", null));
            lookup.Add(new ContextElement("Type", "SubjectS", null));

            Assert.NotNull(lookup.Take("Type"));
            Assert.NotNull(lookup.Take("Type"));
            Assert.Null(lookup.Take("Type"));
        }
        public void Contains_AfterRemovingLastValueInKey_ReturnsFalse()
        {
            List <KeyValuePair <Guid, string> > collection =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(10))).ToList();
            KeyValuePair <Guid, string>     existing         = collection[Random.Next(0, collection.Count)];
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            concurrentLookup.Remove(existing.Key, existing.Value);
            Assert.IsFalse(concurrentLookup.Contains(existing.Key));
        }
        public void Count_InitialCollectionContainsDuplicatesKeys_MatchesNumberOfUniqueKeys()
        {
            List <Guid> keys = Enumerable.Range(1, Random.Next(10, 100)).Select(n => Guid.NewGuid()).ToList();
            int         numberOfDuplicates = Random.Next(1, keys.Count / 2);
            List <KeyValuePair <Guid, string> > collection = keys.Concat(keys.Take(numberOfDuplicates)).Select(
                key => new KeyValuePair <Guid, string>(key, Random.RandomString(20))
                ).ToList();
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            Assert.AreEqual(collection.Count - numberOfDuplicates, concurrentLookup.Count);
        }
        public void This_AfterAddingKey_ContainsAddedValue()
        {
            List <KeyValuePair <Guid, string> > collection =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(10))).ToList();
            Guid   newKey   = Guid.NewGuid();
            String newValue = Random.RandomString(20);
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            concurrentLookup.Add(newKey, newValue);
            CollectionAssert.Contains(concurrentLookup[newKey].ToList(), newValue);
        }
Exemplo n.º 18
0
        public void GetOrEmpty()
        {
            var lookup = new ConcurrentLookup <int, string>();

            lookup.Add(1, "one");
            lookup.Add(2, "two");
            lookup.Add(2, "zwei");

            AssertGetOrEmpty("", 0);
            AssertGetOrEmpty("one", 1);
            AssertGetOrEmpty("two,zwei", 2);

            void AssertGetOrEmpty(string expected, int key) => Assert.AreEqual(expected, lookup.GetOrEmpty(key).ToDelimitedString(","));
        }
        public void This_AfterAddingDuplicateValue_ContainsBothAddedValues()
        {
            List <KeyValuePair <Guid, string> > collection =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(10))).ToList();
            Guid   newKey   = Guid.NewGuid();
            String newValue = Random.RandomString(20);
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            concurrentLookup.Add(newKey, newValue);
            concurrentLookup.Add(newKey, newValue);
            CollectionAssert.AreEqual(new List <String> {
                newValue, newValue
            }, concurrentLookup[newKey].ToList());
        }
        public void Contains_AfterRemovingButValuesStillExistForKey_ReturnsTrue()
        {
            Guid existingKeyWithDuplicates = Guid.NewGuid();
            List <KeyValuePair <Guid, string> > existingValues =
                Enumerable.Range(1, Random.Next(2, 10)).Select(
                    n => new KeyValuePair <Guid, string>(existingKeyWithDuplicates, Random.RandomString(20))).ToList();
            IEnumerable <KeyValuePair <Guid, string> > collection =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(10)))
                .Concat(existingValues);
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            concurrentLookup.Remove(existingKeyWithDuplicates, existingValues.First().Value);
            Assert.IsTrue(concurrentLookup.Contains(existingKeyWithDuplicates));
        }
        public void This_ExistingKey_EnumerationMatchesAllCollectionEntriesMatchingKey()
        {
            Guid          matchingKey    = Guid.NewGuid();
            List <string> matchingValues =
                Enumerable.Range(1, Random.Next(10, 100)).Select(n => Random.RandomString(20)).ToList();
            IEnumerable <KeyValuePair <Guid, string> > otherEntries =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(10)));
            IEnumerable <KeyValuePair <Guid, string> > collection = matchingValues.Select(
                value => new KeyValuePair <Guid, string>(matchingKey, value))
                                                                    .Concat(otherEntries);
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            CollectionAssert.AreEquivalent(matchingValues, concurrentLookup[matchingKey].ToList());
        }
 public void GetEnumerator_InitialCollectionContainsDuplicatesKeys_GroupingsMatchCollectionEntriesMatchingKey()
 {
     List<Guid> keys = Enumerable.Range(1, Random.Next(10, 100)).Select(n => Guid.NewGuid()).ToList();
     int numberOfDuplicates = Random.Next(1, keys.Count / 2);
     List<KeyValuePair<Guid, string>> collection = keys.Concat(keys.Take(numberOfDuplicates)).Select(
         key => new KeyValuePair<Guid, string>(key, Random.RandomString(20))
         ).ToList();
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     foreach (IGrouping<Guid, string> grouping in concurrentLookup)
     {
         Assert.IsNotNull(grouping);
         CollectionAssert.AreEquivalent(
             collection.Where(e => e.Key == grouping.Key).Select(e => e.Value).ToList(),
             grouping.ToList());
     }
 }
        public void GetEnumerator_InitialCollectionContainsDuplicatesKeys_GroupingsMatchCollectionEntriesMatchingKey()
        {
            List <Guid> keys = Enumerable.Range(1, Random.Next(10, 100)).Select(n => Guid.NewGuid()).ToList();
            int         numberOfDuplicates = Random.Next(1, keys.Count / 2);
            List <KeyValuePair <Guid, string> > collection = keys.Concat(keys.Take(numberOfDuplicates)).Select(
                key => new KeyValuePair <Guid, string>(key, Random.RandomString(20))
                ).ToList();
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);

            foreach (IGrouping <Guid, string> grouping in concurrentLookup)
            {
                Assert.IsNotNull(grouping);
                CollectionAssert.AreEquivalent(
                    collection.Where(e => e.Key == grouping.Key).Select(e => e.Value).ToList(),
                    grouping.ToList());
            }
        }
        public void TryGet_ExistingKey_OutputKeyMatchesKey()
        {
            Guid          matchingKey    = Guid.NewGuid();
            List <string> matchingValues =
                Enumerable.Range(1, Random.Next(10, 100)).Select(n => Random.RandomString(20)).ToList();
            IEnumerable <KeyValuePair <Guid, string> > otherEntries =
                Enumerable.Range(1, Random.Next(10, 100)).Select(
                    n => new KeyValuePair <Guid, string>(Guid.NewGuid(), Random.RandomString(10)));
            IEnumerable <KeyValuePair <Guid, string> > collection = matchingValues.Select(
                value => new KeyValuePair <Guid, string>(matchingKey, value))
                                                                    .Concat(otherEntries);
            ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection);
            IGrouping <Guid, String>        output;

            concurrentLookup.TryGet(matchingKey, out output);
            Assert.IsNotNull(output);
            Assert.AreEqual(matchingKey, output.Key);
        }
Exemplo n.º 25
0
        public void Remove()
        {
            var lookup = new ConcurrentLookup <int, string>();

            lookup.Add(1, "one");
            Assert.IsTrue(lookup.TryGetValues(1, out IReadOnlyList <string> ones));
            Assert.AreEqual(1, ones.Count);
            Assert.AreEqual("one", ones[0]);

            lookup.Add(2, "two");
            lookup.Add(2, "zwei");
            Assert.IsTrue(lookup.TryGetValues(2, out IReadOnlyList <string> twos));
            Assert.AreEqual(2, twos.Count);
            Assert.AreEqual("two", twos[0]);
            Assert.AreEqual("zwei", twos[1]);

            Assert.IsFalse(lookup.TryGetValues(0, out IReadOnlyList <string> zeros));
            Assert.IsNull(zeros);

            lookup.Remove(2, "zwei");

            Assert.IsTrue(lookup.TryGetValues(2, out IReadOnlyList <string> oneTwo));
            Assert.AreEqual(1, oneTwo.Count);
            Assert.AreEqual("two", oneTwo[0]);

            lookup.Remove(2, "duo");

            Assert.IsTrue(lookup.TryGetValues(2, out IReadOnlyList <string> stillTwo));
            Assert.AreEqual(1, stillTwo.Count);
            Assert.AreEqual("two", stillTwo[0]);

            lookup.Remove(2, "two");

            Assert.IsFalse(lookup.TryGetValues(2, out IReadOnlyList <string> noTwos));
            Assert.IsNull(noTwos);
        }
 public void Remove_AbsentKeyAndValue_ReturnsFalse()
 {
     Guid absentKey = Guid.NewGuid();
     IEnumerable<KeyValuePair<Guid, string>> collection =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(10)));
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     Assert.IsFalse(concurrentLookup.Remove(absentKey, Random.RandomString(15)));
 }
 public void This_AbsentKey_ReturnsEmptyEnumeration()
 {
     Guid absentKey = Guid.NewGuid();
     IEnumerable<KeyValuePair<Guid, string>> collection =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(10)));
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     CollectionAssert.AreEquivalent(Enumerable.Empty<string>().ToList(), concurrentLookup[absentKey].ToList());
 }
 public void This_AfterRemovingDuplicateValue_StillContainsOneAddedValues()
 {
     List<KeyValuePair<Guid, string>> collection =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(10))).ToList();
     Guid newKey = Guid.NewGuid();
     String newValue = Random.RandomString(20);
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     concurrentLookup.Add(newKey, newValue);
     concurrentLookup.Add(newKey, newValue);
     concurrentLookup.Remove(newKey, newValue);
     CollectionAssert.AreEqual(new List<String> {newValue}, concurrentLookup[newKey].ToList());
 }
 public void TryGet_ExistingKey_ReturnsTrue()
 {
     List<KeyValuePair<Guid, string>> collection =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(10))).ToList();
     Guid existingKey = collection[Random.Next(0, collection.Count)].Key;
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     IGrouping<Guid, String> output;
     Assert.IsTrue(concurrentLookup.TryGet(existingKey, out output));
 }
 public void TryGet_ExistingKey_OutputKeyMatchesKey()
 {
     Guid matchingKey = Guid.NewGuid();
     List<string> matchingValues =
         Enumerable.Range(1, Random.Next(10, 100)).Select(n => Random.RandomString(20)).ToList();
     IEnumerable<KeyValuePair<Guid, string>> otherEntries =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(10)));
     IEnumerable<KeyValuePair<Guid, string>> collection = matchingValues.Select(
         value => new KeyValuePair<Guid, string>(matchingKey, value))
         .Concat(otherEntries);
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     IGrouping<Guid, String> output;
     concurrentLookup.TryGet(matchingKey, out output);
     Assert.IsNotNull(output);
     Assert.AreEqual(matchingKey, output.Key);
 }
 public void TryGet_AbsentKey_ReturnsFalse()
 {
     Guid absentKey = Guid.NewGuid();
     IEnumerable<KeyValuePair<Guid, string>> collection =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(10)));
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     IGrouping<Guid, String> output;
     Assert.IsFalse(concurrentLookup.TryGet(absentKey, out output));
 }
 public void This_AfterAddingKey_ContainsAddedValue()
 {
     List<KeyValuePair<Guid, string>> collection =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(10))).ToList();
     Guid newKey = Guid.NewGuid();
     String newValue = Random.RandomString(20);
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     concurrentLookup.Add(newKey, newValue);
     CollectionAssert.Contains(concurrentLookup[newKey].ToList(), newValue);
 }
 public void Contains_AfterRemovingButValuesStillExistForKey_ReturnsTrue()
 {
     Guid existingKeyWithDuplicates = Guid.NewGuid();
     List<KeyValuePair<Guid, string>> existingValues =
         Enumerable.Range(1, Random.Next(2, 10)).Select(
             n => new KeyValuePair<Guid, string>(existingKeyWithDuplicates, Random.RandomString(20))).ToList();
     IEnumerable<KeyValuePair<Guid, string>> collection =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(10)))
             .Concat(existingValues);
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     concurrentLookup.Remove(existingKeyWithDuplicates, existingValues.First().Value);
     Assert.IsTrue(concurrentLookup.Contains(existingKeyWithDuplicates));
 }
 public void Remove_ExistingKeyAndValue_ReturnsTrue()
 {
     List<KeyValuePair<Guid, string>> collection =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(10))).ToList();
     KeyValuePair<Guid, string> existing = collection[Random.Next(0, collection.Count)];
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     Assert.IsTrue(concurrentLookup.Remove(existing.Key, existing.Value));
 }
 public void This_ExistingKey_EnumerationMatchesAllCollectionEntriesMatchingKey()
 {
     Guid matchingKey = Guid.NewGuid();
     List<string> matchingValues =
         Enumerable.Range(1, Random.Next(10, 100)).Select(n => Random.RandomString(20)).ToList();
     IEnumerable<KeyValuePair<Guid, string>> otherEntries =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(10)));
     IEnumerable<KeyValuePair<Guid, string>> collection = matchingValues.Select(
         value => new KeyValuePair<Guid, string>(matchingKey, value))
         .Concat(otherEntries);
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     CollectionAssert.AreEquivalent(matchingValues, concurrentLookup[matchingKey].ToList());
 }
 public void Remove_WrongValueForKey_ReturnsFalse()
 {
     List<KeyValuePair<Guid, string>> collection =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(10))).ToList();
     Guid existingKey = collection[Random.Next(0, collection.Count)].Key;
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     Assert.IsFalse(concurrentLookup.Remove(existingKey, Random.RandomString(50)));
 }
 public void Contains_AfterRemovingLastValueInKey_ReturnsFalse()
 {
     List<KeyValuePair<Guid, string>> collection =
         Enumerable.Range(1, Random.Next(10, 100)).Select(
             n => new KeyValuePair<Guid, string>(Guid.NewGuid(), Random.RandomString(10))).ToList();
     KeyValuePair<Guid, string> existing = collection[Random.Next(0, collection.Count)];
     ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection);
     concurrentLookup.Remove(existing.Key, existing.Value);
     Assert.IsFalse(concurrentLookup.Contains(existing.Key));
 }