public void AddItem(IQueueItem item) { lock (this) { bool canBeAdded = item.UniqueKey == null || !UniqueIndex.Contains(item.UniqueKey); if (canBeAdded) { Queue.Add(item as InMemoryQueueItem); if (item.UniqueKey != null) { UniqueIndex.Add(item.UniqueKey); } } } }
public void CanAddItems() { SUT.Add("hello", 40); Assert.AreEqual(1, SUT["hello"].Count); SUT.Add("hello", 50); Assert.AreEqual(2, SUT["hello"].Count); SUT.Add("foo", 60); Assert.AreEqual(2, SUT["hello"].Count); Assert.AreEqual(1, SUT["foo"].Count); }