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,10 +11,10 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class ProjectOneTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class ProjectOneTests : 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()
@@ -30,7 +30,7 @@ public class ProjectOneTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.ProjectOne<TestDocument, TestProjection, Guid>(
x => x.ProjectOne<TestDocumentWithKey<int>, TestProjection, int>(
filter,
projection,
null,
@@ -53,7 +53,7 @@ public class ProjectOneTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.ProjectOne<TestDocument, TestProjection, Guid>(filter, projection, null, token),
x => x.ProjectOne<TestDocumentWithKey<int>, TestProjection, int>(filter, projection, null, token),
Times.Once);
}
@@ -72,7 +72,7 @@ public class ProjectOneTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.ProjectOne<TestDocument, TestProjection, Guid>(filter, projection, partitionKey, CancellationToken.None),
x => x.ProjectOne<TestDocumentWithKey<int>, TestProjection, int>(filter, projection, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -92,7 +92,7 @@ public class ProjectOneTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.ProjectOne<TestDocument, TestProjection, Guid>(filter, projection, partitionKey, token),
x => x.ProjectOne<TestDocumentWithKey<int>, TestProjection, int>(filter, projection, partitionKey, token),
Times.Once);
}
@@ -101,9 +101,9 @@ public class ProjectOneTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.ProjectOne<TestDocument, TestProjection, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, TestProjection>>>(),
x => x.ProjectOne<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(result);