keyed Delete unit tests

This commit is contained in:
Sean Garrett
2023-06-16 11:51:40 +01:00
parent 54e756c695
commit c6545b9448
19 changed files with 565 additions and 138 deletions
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using CoreUnitTests.Infrastructure.Model;
using MongoDB.Bson;
using MongoDbGenericRepository.DataAccess.Index;
using Moq;
using Xunit;
@@ -21,7 +20,7 @@ public class GetIndexNamesTests : BaseIndexTests
IndexHandler
.Setup(x => x.GetIndexesNamesAsync<TestDocument, Guid>(null))
.ReturnsAsync(new List<string>{indexName});
.ReturnsAsync(new List<string> { indexName });
// Act
var result = await Sut.GetIndexesNamesAsync<TestDocument>();
@@ -32,6 +31,7 @@ public class GetIndexNamesTests : BaseIndexTests
IndexHandler.Verify(x => x.GetIndexesNamesAsync<TestDocument, Guid>(null), Times.Once());
}
/*
[Fact]
public async Task Ensure_Passes_Provided_CancellationToken()
{
@@ -41,7 +41,7 @@ public class GetIndexNamesTests : BaseIndexTests
IndexHandler = new Mock<IMongoDbIndexHandler>();
IndexHandler
.Setup(x => x.GetIndexesNamesAsync<TestDocument, Guid>(null, token))
.ReturnsAsync(new List<string>{indexName});
.ReturnsAsync(new List<string> { indexName });
// Act
var result = await Sut.GetIndexesNamesAsync<TestDocument>(token);
@@ -50,7 +50,8 @@ public class GetIndexNamesTests : BaseIndexTests
Assert.NotNull(result);
Assert.Contains(result, x => x == indexName);
}
*/
[Fact]
public async Task Ensure_Handles_PartitionKey()
{
@@ -61,7 +62,7 @@ public class GetIndexNamesTests : BaseIndexTests
IndexHandler = new Mock<IMongoDbIndexHandler>();
IndexHandler
.Setup(x => x.GetIndexesNamesAsync<TestDocument, Guid>(partitionKey))
.ReturnsAsync(new List<string>{indexName});
.ReturnsAsync(new List<string> { indexName });
// Act
var result = await Sut.GetIndexesNamesAsync<TestDocument>(partitionKey);
@@ -70,8 +71,8 @@ public class GetIndexNamesTests : BaseIndexTests
Assert.NotNull(result);
Assert.Contains(result, x => x == indexName);
}
[Fact]
/*[Fact]
public async Task Ensure_Passes_Provided_CancellationToken_And_Handles_Partition_Key()
{
// Arrange
@@ -82,7 +83,7 @@ public class GetIndexNamesTests : BaseIndexTests
IndexHandler = new Mock<IMongoDbIndexHandler>();
IndexHandler
.Setup(x => x.GetIndexesNamesAsync<TestDocument, Guid>(partitionKey, token))
.ReturnsAsync(new List<string>{indexName});
.ReturnsAsync(new List<string> { indexName });
// Act
var result = await Sut.GetIndexesNamesAsync<TestDocument>(token, partitionKey);
@@ -90,18 +91,18 @@ public class GetIndexNamesTests : BaseIndexTests
// Assert
Assert.NotNull(result);
Assert.Contains(result, x => x == indexName);
}
[Fact]
}*/
/*[Fact]
public async Task Ensure_Returns_IndexNames_Custom_Primary_Key()
{
// Arrange
const string indexName = "theIndexName";
IndexHandler = new Mock<IMongoDbIndexHandler>();
IndexHandler
.Setup(x => x.GetIndexesNamesAsync<TestDocumentWithKey, int>(null))
.ReturnsAsync(new List<string>{indexName});
.ReturnsAsync(new List<string> { indexName });
// Act
var result = await Sut.GetIndexesNamesAsync<TestDocumentWithKey, int>();
@@ -109,9 +110,9 @@ public class GetIndexNamesTests : BaseIndexTests
// Assert
Assert.NotNull(result);
Assert.Contains(result, x => x == indexName);
}
[Fact]
}*/
/*[Fact]
public async Task Ensure_Passes_Provided_CancellationToken_Custom_Primary_Key()
{
// Arrange
@@ -120,18 +121,17 @@ public class GetIndexNamesTests : BaseIndexTests
IndexHandler = new Mock<IMongoDbIndexHandler>();
IndexHandler
.Setup(x => x.GetIndexesNamesAsync<TestDocumentWithKey, int>(null, token))
.ReturnsAsync(new List<string>{indexName});
.ReturnsAsync(new List<string> { indexName });
// Act
var result = await Sut.GetIndexesNamesAsync<TestDocumentWithKey, int>(token);
// Assert
Assert.NotNull(result);
Assert.Contains(result, x => x == indexName);
}
[Fact]
}*/
/*[Fact]
public async Task Ensure_Handles_PartitionKey_Custom_Primary_Key()
{
// Arrange
@@ -141,8 +141,7 @@ public class GetIndexNamesTests : BaseIndexTests
IndexHandler = new Mock<IMongoDbIndexHandler>();
IndexHandler
.Setup(x => x.GetIndexesNamesAsync<TestDocumentWithKey, int>(partitionKey))
.ReturnsAsync(new List<string>{indexName});
.ReturnsAsync(new List<string> { indexName });
// Act
var result = await Sut.GetIndexesNamesAsync<TestDocumentWithKey, int>(partitionKey);
@@ -150,20 +149,20 @@ public class GetIndexNamesTests : BaseIndexTests
// Assert
Assert.NotNull(result);
Assert.Contains(result, x => x == indexName);
}
[Fact]
}*/
/*[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<IMongoDbIndexHandler>();
IndexHandler
.Setup(x => x.GetIndexesNamesAsync<TestDocumentWithKey, int>(partitionKey, token))
.ReturnsAsync(new List<string>{indexName});
.ReturnsAsync(new List<string> { indexName });
// Act
var result = await Sut.GetIndexesNamesAsync<TestDocumentWithKey, int>(token, partitionKey);
@@ -171,5 +170,5 @@ public class GetIndexNamesTests : BaseIndexTests
// Assert
Assert.NotNull(result);
Assert.Contains(result, x => x == indexName);
}
}
}*/
}