public void Ensure_deleted_succeeds() { var mockMongoDbConnection = new Mock <IMongoDbConnection>(); mockMongoDbConnection .Setup(mongoDbConnection => mongoDbConnection.DropDatabase()) .Verifiable(); var mongoDbDatabaseCreator = new MongoDbDatabaseCreator(mockMongoDbConnection.Object); Assert.True(mongoDbDatabaseCreator.EnsureDeleted()); mockMongoDbConnection.Verify( mongoDbConnection => mongoDbConnection.DropDatabase(), Times.Exactly(callCount: 1)); }
public async Task Ensure_deleted_async_succeeds() { var mockMongoDbConnection = new Mock <IMongoDbConnection>(); mockMongoDbConnection .Setup(mongoDbConnection => mongoDbConnection.DropDatabaseAsync(It.IsAny <CancellationToken>())) .Returns(Task.FromResult(result: 0)) .Verifiable(); var mongoDbDatabaseCreator = new MongoDbDatabaseCreator(mockMongoDbConnection.Object); Assert.True(await mongoDbDatabaseCreator.EnsureDeletedAsync()); mockMongoDbConnection.Verify( mongoDbConnection => mongoDbConnection.DropDatabaseAsync(It.IsAny <CancellationToken>()), Times.Exactly(callCount: 1)); }