using System; using System.Threading; using System.Threading.Tasks; using AutoFixture; using CoreUnitTests.Infrastructure.Model; using MongoDbGenericRepository.DataAccess.Index; using Moq; using Xunit; namespace CoreUnitTests.BaseMongoRepositoryTests.IndexTests; public class DropIndexAsyncTests: BaseIndexTests { [Fact] public async Task WitIndexName_DropsIndex() { // Arrange var indexName = Fixture.Create(); IndexHandler = new Mock(); // Act await Sut.DropIndexAsync(indexName); // Assert IndexHandler.Verify( x => x.DropIndexAsync(indexName, null, CancellationToken.None)); } [Fact] public async Task WitIndexNameAndCancellationToken_DropsIndex() { // Arrange var indexName = Fixture.Create(); var token = new CancellationToken(true); IndexHandler = new Mock(); // Act await Sut.DropIndexAsync(indexName, token); // Assert IndexHandler.Verify( x => x.DropIndexAsync(indexName, null, token)); } [Fact] public async Task WitIndexNameAndPartitionKey_DropsIndex() { // Arrange var indexName = Fixture.Create(); var partitionKey = Fixture.Create(); IndexHandler = new Mock(); // Act await Sut.DropIndexAsync(indexName, partitionKey); // Assert IndexHandler.Verify( x => x.DropIndexAsync(indexName, partitionKey, CancellationToken.None)); } [Fact] public async Task WitIndexNameAndPartitionKeyAndCancellationToken_DropsIndex() { // Arrange var indexName = Fixture.Create(); var partitionKey = Fixture.Create(); var token = new CancellationToken(true); IndexHandler = new Mock(); // Act await Sut.DropIndexAsync(indexName, partitionKey, token); // Assert IndexHandler.Verify( x => x.DropIndexAsync(indexName, partitionKey, token)); } #region Keyed [Fact] public async Task Keyed_WithIndexName_DropsIndex() { // Arrange var indexName = Fixture.Create(); IndexHandler = new Mock(); // Act await Sut.DropIndexAsync, int>(indexName); // Assert IndexHandler.Verify( x => x.DropIndexAsync, int>(indexName, null, CancellationToken.None)); } [Fact] public async Task Keyed_WithIndexNameAndCancellationToken_DropsIndex() { // Arrange var indexName = Fixture.Create(); var token = new CancellationToken(true); IndexHandler = new Mock(); // Act await Sut.DropIndexAsync, int>(indexName, token); // Assert IndexHandler.Verify( x => x.DropIndexAsync, int>(indexName, null, token)); } [Fact] public async Task Keyed_WithIndexNameAndPartitionKey_DropsIndex() { // Arrange var indexName = Fixture.Create(); var partitionKey = Fixture.Create(); IndexHandler = new Mock(); // Act await Sut.DropIndexAsync, int>(indexName, partitionKey); // Assert IndexHandler.Verify( x => x.DropIndexAsync, int>(indexName, partitionKey, CancellationToken.None)); } [Fact] public async Task Keyed_WithIndexNameAndPartitionKeyAndCancellationToken_DropsIndex() { // Arrange var indexName = Fixture.Create(); var partitionKey = Fixture.Create(); var token = new CancellationToken(true); IndexHandler = new Mock(); // Act await Sut.DropIndexAsync, int>(indexName, partitionKey, token); // Assert IndexHandler.Verify( x => x.DropIndexAsync, int>(indexName, partitionKey, token)); } #endregion }