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 Contains_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); Assert.IsFalse(concurrentLookup.Contains(absentKey)); }
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 Contains_AfterAddingKey_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 newKey = Guid.NewGuid(); String newValue = Random.RandomString(20); ConcurrentLookup <Guid, String> concurrentLookup = new ConcurrentLookup <Guid, string>(collection); concurrentLookup.Add(newKey, newValue); Assert.IsTrue(concurrentLookup.Contains(newKey)); }
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 Contains_AfterAddingKey_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 newKey = Guid.NewGuid(); String newValue = Random.RandomString(20); ConcurrentLookup<Guid, String> concurrentLookup = new ConcurrentLookup<Guid, string>(collection); concurrentLookup.Add(newKey, newValue); Assert.IsTrue(concurrentLookup.Contains(newKey)); }
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 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 Contains_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); Assert.IsFalse(concurrentLookup.Contains(absentKey)); }
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)); }