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 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 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);
 }