public void ClearTest() { var storageFactory = new StorageFactory(); storageFactory.GetStorage(false, "LocalStorageFileSystem"); storageFactory.GetStorage(false, "GoogleCloudStorage"); storageFactory.GetStorage(false, "AzureFileStorage"); var property = storageFactory.GetType().GetField("StorageCollection", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField); var before = ((List <StorageBase>)property.GetValue(storageFactory)).Count; storageFactory.ClearStorage(); var after = ((List <StorageBase>)property.GetValue(storageFactory)).Count; Assert.IsTrue((before > after) && after == 0); }