public void ResetsSnapshotSoThatItIsRecreatedAtNextRead()
            {
                var target = new TestableSnapshottingCollection <object>(new List <object>());

                target.GetSnapshot();

                target.Add(new object());

                Assert.Null(target.Snapshot);
            }
            public void AddsItemToCollection()
            {
                var collection = new List <object>();
                var target     = new TestableSnapshottingCollection <object>(collection);
                var item       = new object();

                target.Add(item);

                Assert.True(collection.Contains(item));
            }
            public void LocksCollectionForThreadSafety()
            {
                Task anotherThread;
                var  collection = new List <object>();
                var  target     = new TestableSnapshottingCollection <object>(collection);

                lock (collection)
                {
                    anotherThread = Task.Run(() => target.Add(new object()));
                    Assert.False(anotherThread.Wait(20));
                }

                Assert.True(anotherThread.Wait(20));
            }