/// <summary> /// Checks whether properties of the specified collection have the expected default values and /// whether the collection contains the expected amount of log messages. /// </summary> /// <param name="collection">Collection to check.</param> /// <param name="expectedCount">Expected number of log messages in the collection.</param> private void TestCollectionPropertyDefaults(LogMessageCollection <LogMessage> collection, long expectedCount) { using (var eventWatcher = collection.AttachEventWatcher()) { // check collection specific properties Assert.Equal(expectedCount, collection.Count); // check properties exposed by IList implementation { var list = collection as IList; Assert.Equal(expectedCount, list.Count); Assert.Equal(CollectionIsReadOnly, list.IsReadOnly); Assert.Equal(CollectionIsFixedSize, list.IsFixedSize); Assert.Equal(CollectionIsSynchronized, list.IsSynchronized); Assert.NotSame(collection, list.SyncRoot); // sync root must not be the same as the collection to avoid deadlocks } // check properties exposed by IList<T> implementation { var list = collection as IList <LogMessage>; Assert.False(list.IsReadOnly); Assert.Equal(expectedCount, list.Count); } // no events should have been raised eventWatcher.CheckInvocations(); } }