using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using CoreUnitTests.Infrastructure.Model; using MongoDbGenericRepository.DataAccess.Index; using Moq; using Xunit; namespace CoreUnitTests.BaseMongoRepositoryTests.IndexTests; public class GetIndexNamesTests : BaseIndexTests { [Fact] public async Task Ensure_Returns_IndexNames() { // Arrange IndexHandler = new Mock(); const string indexName = "theIndexName"; IndexHandler .Setup(x => x.GetIndexesNamesAsync(null)) .ReturnsAsync(new List { indexName }); // Act var result = await Sut.GetIndexesNamesAsync(); // Assert Assert.NotNull(result); Assert.Contains(result, x => x == indexName); IndexHandler.Verify(x => x.GetIndexesNamesAsync(null), Times.Once()); } /* [Fact] public async Task Ensure_Passes_Provided_CancellationToken() { // Arrange const string indexName = "theIndexName"; var token = new CancellationToken(); IndexHandler = new Mock(); IndexHandler .Setup(x => x.GetIndexesNamesAsync(null, token)) .ReturnsAsync(new List { indexName }); // Act var result = await Sut.GetIndexesNamesAsync(token); // Assert Assert.NotNull(result); Assert.Contains(result, x => x == indexName); } */ [Fact] public async Task Ensure_Handles_PartitionKey() { // Arrange const string partitionKey = "thePartitionKey"; const string indexName = "theIndexName"; IndexHandler = new Mock(); IndexHandler .Setup(x => x.GetIndexesNamesAsync(partitionKey)) .ReturnsAsync(new List { indexName }); // Act var result = await Sut.GetIndexesNamesAsync(partitionKey); // Assert Assert.NotNull(result); Assert.Contains(result, x => x == indexName); } /*[Fact] public async Task Ensure_Passes_Provided_CancellationToken_And_Handles_Partition_Key() { // Arrange const string partitionKey = "thePartitionKey"; const string indexName = "theIndexName"; var token = new CancellationToken(); IndexHandler = new Mock(); IndexHandler .Setup(x => x.GetIndexesNamesAsync(partitionKey, token)) .ReturnsAsync(new List { indexName }); // Act var result = await Sut.GetIndexesNamesAsync(token, partitionKey); // Assert Assert.NotNull(result); Assert.Contains(result, x => x == indexName); }*/ /*[Fact] public async Task Ensure_Returns_IndexNames_Custom_Primary_Key() { // Arrange const string indexName = "theIndexName"; IndexHandler = new Mock(); IndexHandler .Setup(x => x.GetIndexesNamesAsync(null)) .ReturnsAsync(new List { indexName }); // Act var result = await Sut.GetIndexesNamesAsync(); // Assert Assert.NotNull(result); Assert.Contains(result, x => x == indexName); }*/ /*[Fact] public async Task Ensure_Passes_Provided_CancellationToken_Custom_Primary_Key() { // Arrange const string indexName = "theIndexName"; var token = new CancellationToken(); IndexHandler = new Mock(); IndexHandler .Setup(x => x.GetIndexesNamesAsync(null, token)) .ReturnsAsync(new List { indexName }); // Act var result = await Sut.GetIndexesNamesAsync(token); // Assert Assert.NotNull(result); Assert.Contains(result, x => x == indexName); }*/ /*[Fact] public async Task Ensure_Handles_PartitionKey_Custom_Primary_Key() { // Arrange const string indexName = "theIndexName"; const string partitionKey = "thePartitionKey"; IndexHandler = new Mock(); IndexHandler .Setup(x => x.GetIndexesNamesAsync(partitionKey)) .ReturnsAsync(new List { indexName }); // Act var result = await Sut.GetIndexesNamesAsync(partitionKey); // Assert Assert.NotNull(result); Assert.Contains(result, x => x == indexName); }*/ /*[Fact] public async Task Ensure_Passes_Provided_CancellationToken_And_Handles_Partition_Key_Custom_Primary_Key() { // Arrange const string indexName = "theIndexName"; const string partitionKey = "thePartitionKey"; var token = new CancellationToken(); IndexHandler = new Mock(); IndexHandler .Setup(x => x.GetIndexesNamesAsync(partitionKey, token)) .ReturnsAsync(new List { indexName }); // Act var result = await Sut.GetIndexesNamesAsync(token, partitionKey); // Assert Assert.NotNull(result); Assert.Contains(result, x => x == indexName); }*/ }