public void ICollection_NonGeneric_SyncRoot(int count)
{
ICollection collection = NonGenericICollectionFactory(count);
if (ICollection_NonGeneric_SupportsSyncRoot)
{
Assert.Equal(ICollection_NonGeneric_HasNullSyncRoot, collection.SyncRoot == null);
Assert.Same(collection.SyncRoot, collection.SyncRoot);
if (!ICollection_NonGeneric_HasNullSyncRoot)
{
Assert.IsType(ICollection_NonGeneric_SyncRootType, collection.SyncRoot);
if (ICollection_NonGeneric_SyncRootType == collection.GetType())
{
// If we expect the SyncRoot to be the same type as the collection,
// the SyncRoot should be the same as the collection (e.g. HybridDictionary)
Assert.Same(collection, collection.SyncRoot);
}
else
{
Assert.NotSame(collection, collection.SyncRoot);
}
}
}
else
{
Assert.Throws<NotSupportedException>(() => collection.SyncRoot);
}
}