Index tests
This commit is contained in:
@@ -12,20 +12,20 @@ namespace CoreUnitTests.BaseMongoRepositoryTests.IndexTests;
|
||||
|
||||
public class CreateTextIndexTests : BaseIndexTests
|
||||
{
|
||||
private readonly Expression<Func<TestDocument, object>> _fieldExpression = t => t.SomeContent2;
|
||||
private readonly Expression<Func<TestDocument, object>> fieldExpression = t => t.SomeContent2;
|
||||
|
||||
[Fact]
|
||||
public async Task Ensure_Creates_Index()
|
||||
public async Task WhenFieldExpression_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateTextIndexAsync<TestDocument>(_fieldExpression);
|
||||
await Sut.CreateTextIndexAsync(fieldExpression);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateTextIndexAsync<TestDocument, Guid>(_fieldExpression, null, null));
|
||||
x => x.CreateTextIndexAsync<TestDocument, Guid>(fieldExpression, null, null, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -36,12 +36,12 @@ public class CreateTextIndexTests : BaseIndexTests
|
||||
var options = new IndexCreationOptions { Name = "theIndexName" };
|
||||
|
||||
// Act
|
||||
await Sut.CreateTextIndexAsync<TestDocument>(_fieldExpression, options);
|
||||
await Sut.CreateTextIndexAsync(fieldExpression, options);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateTextIndexAsync<TestDocument, Guid>(
|
||||
_fieldExpression, options, null));
|
||||
fieldExpression, options, null, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -53,16 +53,15 @@ public class CreateTextIndexTests : BaseIndexTests
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateTextIndexAsync<TestDocument>(_fieldExpression, partitionKey: partitionKey);
|
||||
await Sut.CreateTextIndexAsync(fieldExpression, partitionKey: partitionKey);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateTextIndexAsync<TestDocument, Guid>(
|
||||
_fieldExpression, null, partitionKey));
|
||||
fieldExpression, null, partitionKey, CancellationToken.None));
|
||||
}
|
||||
|
||||
/*
|
||||
[Fact]
|
||||
/*[Fact]
|
||||
public async Task Ensure_Creates_Index_With_CancellationToken()
|
||||
{
|
||||
// Arrange
|
||||
@@ -70,13 +69,14 @@ public class CreateTextIndexTests : BaseIndexTests
|
||||
var token = new CancellationToken(true);
|
||||
|
||||
// Act
|
||||
await Sut.CreateTextIndexAsync<TestDocument>(_fieldExpression, token);
|
||||
await Sut.CreateTextIndexAsync<TestDocument>(fieldExpression, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateTextIndexAsync<TestDocument, Guid>(_fieldExpression, null, null, token));
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
[Fact]
|
||||
public async Task Ensure_Passes_Options_With_CancellationToken()
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ public class GetIndexNamesTests : BaseIndexTests
|
||||
const string indexName = "theIndexName";
|
||||
|
||||
IndexHandler
|
||||
.Setup(x => x.GetIndexesNamesAsync<TestDocument, Guid>(null))
|
||||
.Setup(x => x.GetIndexesNamesAsync<TestDocument, Guid>(It.IsAny<string>(), It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new List<string> { indexName });
|
||||
|
||||
// Act
|
||||
@@ -28,7 +28,7 @@ public class GetIndexNamesTests : BaseIndexTests
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
Assert.Contains(result, x => x == indexName);
|
||||
IndexHandler.Verify(x => x.GetIndexesNamesAsync<TestDocument, Guid>(null), Times.Once());
|
||||
IndexHandler.Verify(x => x.GetIndexesNamesAsync<TestDocument, Guid>(null, CancellationToken.None), Times.Once());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -61,7 +61,7 @@ public class GetIndexNamesTests : BaseIndexTests
|
||||
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
IndexHandler
|
||||
.Setup(x => x.GetIndexesNamesAsync<TestDocument, Guid>(partitionKey))
|
||||
.Setup(x => x.GetIndexesNamesAsync<TestDocument, Guid>(It.IsAny<string>(), It.IsAny<CancellationToken>()))
|
||||
.ReturnsAsync(new List<string> { indexName });
|
||||
|
||||
// Act
|
||||
|
||||
Reference in New Issue
Block a user