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
@@ -13,10 +13,10 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class ProjectManyTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class ProjectManyTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocument, TestProjection>> projection = document => new TestProjection {NestedData = document.Nested.SomeDate};
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocumentWithKey<int>, TestProjection>> projection = document => new TestProjection {NestedData = document.Nested.SomeDate};
[Fact]
public void WithFilterAndProjection_Projects()
@@ -32,7 +32,7 @@ public class ProjectManyTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().OnlyContain(x => projections.Contains(x));
Reader.Verify(
x => x.ProjectMany<TestDocument, TestProjection, Guid>(
x => x.ProjectMany<TestDocumentWithKey<int>, TestProjection, int>(
filter,
projection,
null,
@@ -55,7 +55,7 @@ public class ProjectManyTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().OnlyContain(x => projections.Contains(x));
Reader.Verify(
x => x.ProjectMany<TestDocument, TestProjection, Guid>(filter, projection, null, token),
x => x.ProjectMany<TestDocumentWithKey<int>, TestProjection, int>(filter, projection, null, token),
Times.Once);
}
@@ -74,7 +74,7 @@ public class ProjectManyTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().OnlyContain(x => projections.Contains(x));
Reader.Verify(
x => x.ProjectMany<TestDocument, TestProjection, Guid>(filter, projection, partitionKey, CancellationToken.None),
x => x.ProjectMany<TestDocumentWithKey<int>, TestProjection, int>(filter, projection, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -94,7 +94,7 @@ public class ProjectManyTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().OnlyContain(x => projections.Contains(x));
Reader.Verify(
x => x.ProjectMany<TestDocument, TestProjection, Guid>(filter, projection, partitionKey, token),
x => x.ProjectMany<TestDocumentWithKey<int>, TestProjection, int>(filter, projection, partitionKey, token),
Times.Once);
}
@@ -103,9 +103,9 @@ public class ProjectManyTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.ProjectMany<TestDocument, TestProjection, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, TestProjection>>>(),
x => x.ProjectMany<TestDocumentWithKey<int>, TestProjection, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, TestProjection>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(projections);