tests for readonly repositories

This commit is contained in:
Sean Garrett
2023-07-04 22:38:01 +01:00
parent b09b359867
commit dc7a4dc67b
56 changed files with 10877 additions and 1212 deletions
@@ -11,9 +11,9 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class AnyTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class AnyTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.SomeContent == "SomeContent";
[Fact]
public void WithFilter_GetsResult()
@@ -27,7 +27,7 @@ public class AnyTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().BeTrue();
Reader.Verify(
x => x.Any<TestDocument, Guid>(filter, null, CancellationToken.None),
x => x.Any<TestDocumentWithKey<int>, int>(filter, null, CancellationToken.None),
Times.Once);
}
@@ -45,7 +45,7 @@ public class AnyTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().BeTrue();
Reader.Verify(
x => x.Any<TestDocument, Guid>(filter, null, token),
x => x.Any<TestDocumentWithKey<int>, int>(filter, null, token),
Times.Once);
}
@@ -63,7 +63,7 @@ public class AnyTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().BeTrue();
Reader.Verify(
x => x.Any<TestDocument, Guid>(filter, partitionKey, CancellationToken.None),
x => x.Any<TestDocumentWithKey<int>, int>(filter, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -82,7 +82,7 @@ public class AnyTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().BeTrue();
Reader.Verify(
x => x.Any<TestDocument, Guid>(filter, partitionKey, token),
x => x.Any<TestDocumentWithKey<int>, int>(filter, partitionKey, token),
Times.Once);
}
@@ -91,8 +91,8 @@ public class AnyTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.Any<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
x => x.Any<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(true);