public void ResetsSnapshotSoThatItsRecreatedAtNextRead() { var target = new TestableSnapshottingCollection <object>(new List <object>()); target.GetSnapshot(); target.Clear(); Assert.Null(target.Snapshot); }
public void RemovesItemsFromCollection() { var collection = new List <object> { new object() }; var target = new TestableSnapshottingCollection <object>(collection); target.Clear(); Assert.Equal(0, collection.Count); }
public void LocksCollectionForThreadSafety() { Task anotherThread; var collection = new List <object>(); var target = new TestableSnapshottingCollection <object>(collection); lock (collection) { anotherThread = Task.Run(() => target.Clear()); Assert.False(anotherThread.Wait(20)); } Assert.True(anotherThread.Wait(20)); }