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
@@ -12,9 +12,9 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class AnyAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class AnyAsyncTests : 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 async Task WithFilter_GetsResult()
@@ -28,7 +28,7 @@ public class AnyAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().BeTrue();
Reader.Verify(
x => x.AnyAsync<TestDocument, Guid>(filter, null, CancellationToken.None),
x => x.AnyAsync<TestDocumentWithKey<int>, int>(filter, null, CancellationToken.None),
Times.Once);
}
@@ -46,7 +46,7 @@ public class AnyAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().BeTrue();
Reader.Verify(
x => x.AnyAsync<TestDocument, Guid>(filter, null, token),
x => x.AnyAsync<TestDocumentWithKey<int>, int>(filter, null, token),
Times.Once);
}
@@ -64,7 +64,7 @@ public class AnyAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().BeTrue();
Reader.Verify(
x => x.AnyAsync<TestDocument, Guid>(filter, partitionKey, CancellationToken.None),
x => x.AnyAsync<TestDocumentWithKey<int>, int>(filter, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -83,7 +83,7 @@ public class AnyAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().BeTrue();
Reader.Verify(
x => x.AnyAsync<TestDocument, Guid>(filter, partitionKey, token),
x => x.AnyAsync<TestDocumentWithKey<int>, int>(filter, partitionKey, token),
Times.Once);
}
@@ -92,8 +92,8 @@ public class AnyAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.AnyAsync<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
x => x.AnyAsync<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(true);
@@ -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);
@@ -14,9 +14,9 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class CountAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class CountAsyncTests : 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 async Task WithFilter_GetsOne()
@@ -32,7 +32,7 @@ public class CountAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(count);
Reader.Verify(
x => x.CountAsync<TestDocument, Guid>(filter, null, CancellationToken.None),
x => x.CountAsync<TestDocumentWithKey<int>, int>(filter, null, CancellationToken.None),
Times.Once);
}
@@ -51,7 +51,7 @@ public class CountAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(count);
Reader.Verify(
x => x.CountAsync<TestDocument, Guid>(filter, null, token),
x => x.CountAsync<TestDocumentWithKey<int>, int>(filter, null, token),
Times.Once);
}
@@ -70,7 +70,7 @@ public class CountAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(count);
Reader.Verify(
x => x.CountAsync<TestDocument, Guid>(filter, partitionKey, CancellationToken.None),
x => x.CountAsync<TestDocumentWithKey<int>, int>(filter, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -90,7 +90,7 @@ public class CountAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(count);
Reader.Verify(
x => x.CountAsync<TestDocument, Guid>(filter, partitionKey, token),
x => x.CountAsync<TestDocumentWithKey<int>, int>(filter, partitionKey, token),
Times.Once);
}
@@ -99,8 +99,8 @@ public class CountAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.CountAsync<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
x => x.CountAsync<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(count);
@@ -11,9 +11,9 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class CountTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class CountTests : 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_GetsOne()
@@ -29,7 +29,7 @@ public class CountTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(count);
Reader.Verify(
x => x.Count<TestDocument, Guid>(filter, null, CancellationToken.None),
x => x.Count<TestDocumentWithKey<int>, int>(filter, null, CancellationToken.None),
Times.Once);
}
@@ -48,7 +48,7 @@ public class CountTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(count);
Reader.Verify(
x => x.Count<TestDocument, Guid>(filter, null, token),
x => x.Count<TestDocumentWithKey<int>, int>(filter, null, token),
Times.Once);
}
@@ -67,7 +67,7 @@ public class CountTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(count);
Reader.Verify(
x => x.Count<TestDocument, Guid>(filter, partitionKey, CancellationToken.None),
x => x.Count<TestDocumentWithKey<int>, int>(filter, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -87,7 +87,7 @@ public class CountTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(count);
Reader.Verify(
x => x.Count<TestDocument, Guid>(filter, partitionKey, token),
x => x.Count<TestDocumentWithKey<int>, int>(filter, partitionKey, token),
Times.Once);
}
@@ -96,8 +96,8 @@ public class CountTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.Count<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
x => x.Count<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(count);
@@ -14,15 +14,15 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetAllAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetAllAsyncTests : 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 async Task WithFilter_GetsOne()
{
// Arrange
var document = Fixture.CreateMany<TestDocument>().ToList();
var document = Fixture.CreateMany<TestDocumentWithKey<int>>().ToList();
SetupReader(document);
@@ -33,7 +33,7 @@ public class GetAllAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetAllAsync<TestDocument, Guid>(filter, null, CancellationToken.None),
x => x.GetAllAsync<TestDocumentWithKey<int>, int>(filter, null, CancellationToken.None),
Times.Once);
}
@@ -41,7 +41,7 @@ public class GetAllAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithFilterAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.CreateMany<TestDocument>().ToList();
var document = Fixture.CreateMany<TestDocumentWithKey<int>>().ToList();
var token = new CancellationToken(true);
SetupReader(document);
@@ -53,7 +53,7 @@ public class GetAllAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetAllAsync<TestDocument, Guid>(filter, null, token),
x => x.GetAllAsync<TestDocumentWithKey<int>, int>(filter, null, token),
Times.Once);
}
@@ -61,7 +61,7 @@ public class GetAllAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithFilterAndPartitionKey_GetsOne()
{
// Arrange
var document = Fixture.CreateMany<TestDocument>().ToList();
var document = Fixture.CreateMany<TestDocumentWithKey<int>>().ToList();
var partitionKey = Fixture.Create<string>();
SetupReader(document);
@@ -73,7 +73,7 @@ public class GetAllAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetAllAsync<TestDocument, Guid>(filter, partitionKey, CancellationToken.None),
x => x.GetAllAsync<TestDocumentWithKey<int>, int>(filter, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -81,7 +81,7 @@ public class GetAllAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithFilterAndPartitionKeyAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.CreateMany<TestDocument>().ToList();
var document = Fixture.CreateMany<TestDocumentWithKey<int>>().ToList();
var partitionKey = Fixture.Create<string>();
var token = new CancellationToken(true);
@@ -94,17 +94,17 @@ public class GetAllAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetAllAsync<TestDocument, Guid>(filter, partitionKey, token),
x => x.GetAllAsync<TestDocumentWithKey<int>, int>(filter, partitionKey, token),
Times.Once);
}
private void SetupReader(List<TestDocument> documents)
private void SetupReader(List<TestDocumentWithKey<int>> documents)
{
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetAllAsync<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
x => x.GetAllAsync<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(documents);
@@ -13,15 +13,15 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetAllTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetAllTests : 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_GetsOne()
{
// Arrange
var document = Fixture.CreateMany<TestDocument>().ToList();
var document = Fixture.CreateMany<TestDocumentWithKey<int>>().ToList();
SetupReader(document);
@@ -32,7 +32,7 @@ public class GetAllTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetAll<TestDocument, Guid>(filter, null, CancellationToken.None),
x => x.GetAll<TestDocumentWithKey<int>, int>(filter, null, CancellationToken.None),
Times.Once);
}
@@ -40,7 +40,7 @@ public class GetAllTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public void WithFilterAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.CreateMany<TestDocument>().ToList();
var document = Fixture.CreateMany<TestDocumentWithKey<int>>().ToList();
var token = new CancellationToken(true);
SetupReader(document);
@@ -52,7 +52,7 @@ public class GetAllTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetAll<TestDocument, Guid>(filter, null, token),
x => x.GetAll<TestDocumentWithKey<int>, int>(filter, null, token),
Times.Once);
}
@@ -60,7 +60,7 @@ public class GetAllTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public void WithFilterAndPartitionKey_GetsOne()
{
// Arrange
var document = Fixture.CreateMany<TestDocument>().ToList();
var document = Fixture.CreateMany<TestDocumentWithKey<int>>().ToList();
var partitionKey = Fixture.Create<string>();
SetupReader(document);
@@ -72,7 +72,7 @@ public class GetAllTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetAll<TestDocument, Guid>(filter, partitionKey, CancellationToken.None),
x => x.GetAll<TestDocumentWithKey<int>, int>(filter, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -80,7 +80,7 @@ public class GetAllTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public void WithFilterAndPartitionKeyAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.CreateMany<TestDocument>().ToList();
var document = Fixture.CreateMany<TestDocumentWithKey<int>>().ToList();
var partitionKey = Fixture.Create<string>();
var token = new CancellationToken(true);
@@ -93,17 +93,17 @@ public class GetAllTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetAll<TestDocument, Guid>(filter, partitionKey, token),
x => x.GetAll<TestDocumentWithKey<int>, int>(filter, partitionKey, token),
Times.Once);
}
private void SetupReader(List<TestDocument> documents)
private void SetupReader(List<TestDocumentWithKey<int>> documents)
{
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetAll<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
x => x.GetAll<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(documents);
@@ -1,6 +1,3 @@
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using AutoFixture;
@@ -13,24 +10,24 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetByIdAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetByIdAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
[Fact]
public async Task WithId_Gets()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
SetupReader(document);
// Act
var result = await Sut.GetByIdAsync<TestDocument>(document.Id);
var result = await Sut.GetByIdAsync<TestDocumentWithKey<int>>(document.Id);
// Assert
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByIdAsync<TestDocument, Guid>(document.Id, null, CancellationToken.None),
x => x.GetByIdAsync<TestDocumentWithKey<int>, int>(document.Id, null, CancellationToken.None),
Times.Once);
}
@@ -38,19 +35,19 @@ public class GetByIdAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithIdAndCancellationToken_Gets()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var token = new CancellationToken(true);
SetupReader(document);
// Act
var result = await Sut.GetByIdAsync<TestDocument>(document.Id, token);
var result = await Sut.GetByIdAsync<TestDocumentWithKey<int>>(document.Id, token);
// Assert
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByIdAsync<TestDocument, Guid>(document.Id, null, token),
x => x.GetByIdAsync<TestDocumentWithKey<int>, int>(document.Id, null, token),
Times.Once);
}
@@ -58,19 +55,19 @@ public class GetByIdAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithIdAndPartitionKey_Gets()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
SetupReader(document);
// Act
var result = await Sut.GetByIdAsync<TestDocument>(document.Id, partitionKey);
var result = await Sut.GetByIdAsync<TestDocumentWithKey<int>>(document.Id, partitionKey);
// Assert
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByIdAsync<TestDocument, Guid>(document.Id, partitionKey, CancellationToken.None),
x => x.GetByIdAsync<TestDocumentWithKey<int>, int>(document.Id, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -78,30 +75,30 @@ public class GetByIdAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithIdAndPartitionKeyAndCancellationToken_Gets()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
var token = new CancellationToken(true);
SetupReader(document);
// Act
var result = await Sut.GetByIdAsync<TestDocument>(document.Id, partitionKey, token);
var result = await Sut.GetByIdAsync<TestDocumentWithKey<int>>(document.Id, partitionKey, token);
// Assert
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByIdAsync<TestDocument, Guid>(document.Id, partitionKey, token),
x => x.GetByIdAsync<TestDocumentWithKey<int>, int>(document.Id, partitionKey, token),
Times.Once);
}
private void SetupReader(TestDocument document)
private void SetupReader(TestDocumentWithKey<int> document)
{
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetByIdAsync<TestDocument, Guid>(
It.IsAny<Guid>(),
x => x.GetByIdAsync<TestDocumentWithKey<int>, int>(
It.IsAny<int>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(document);
@@ -1,8 +1,4 @@
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using AutoFixture;
using CoreUnitTests.Infrastructure;
using CoreUnitTests.Infrastructure.Model;
@@ -13,24 +9,24 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetByIdTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetByIdTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
[Fact]
public void WithId_Gets()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
SetupReader(document);
// Act
var result = Sut.GetById<TestDocument>(document.Id);
var result = Sut.GetById<TestDocumentWithKey<int>>(document.Id);
// Assert
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetById<TestDocument, Guid>(document.Id, null, CancellationToken.None),
x => x.GetById<TestDocumentWithKey<int>, int>(document.Id, null, CancellationToken.None),
Times.Once);
}
@@ -38,19 +34,19 @@ public class GetByIdTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public void WithIdAndCancellationToken_Gets()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var token = new CancellationToken(true);
SetupReader(document);
// Act
var result = Sut.GetById<TestDocument>(document.Id, token);
var result = Sut.GetById<TestDocumentWithKey<int>>(document.Id, token);
// Assert
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetById<TestDocument, Guid>(document.Id, null, token),
x => x.GetById<TestDocumentWithKey<int>, int>(document.Id, null, token),
Times.Once);
}
@@ -58,19 +54,19 @@ public class GetByIdTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public void WithIdAndPartitionKey_Gets()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
SetupReader(document);
// Act
var result = Sut.GetById<TestDocument>(document.Id, partitionKey);
var result = Sut.GetById<TestDocumentWithKey<int>>(document.Id, partitionKey);
// Assert
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetById<TestDocument, Guid>(document.Id, partitionKey, CancellationToken.None),
x => x.GetById<TestDocumentWithKey<int>, int>(document.Id, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -78,30 +74,30 @@ public class GetByIdTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public void WithIdAndPartitionKeyAndCancellationToken_Gets()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
var token = new CancellationToken(true);
SetupReader(document);
// Act
var result = Sut.GetById<TestDocument>(document.Id, partitionKey, token);
var result = Sut.GetById<TestDocumentWithKey<int>>(document.Id, partitionKey, token);
// Assert
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetById<TestDocument, Guid>(document.Id, partitionKey, token),
x => x.GetById<TestDocumentWithKey<int>, int>(document.Id, partitionKey, token),
Times.Once);
}
private void SetupReader(TestDocument document)
private void SetupReader(TestDocumentWithKey<int> document)
{
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetById<TestDocument, Guid>(
It.IsAny<Guid>(),
x => x.GetById<TestDocumentWithKey<int>, int>(
It.IsAny<int>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(document);
@@ -12,16 +12,16 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetByMaxAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetByMaxAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocument, object>> selector = document => document.SomeValue;
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocumentWithKey<int>, object>> selector = document => document.SomeValue;
[Fact]
public async Task WithFilterAndSelector_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
SetupReader(document);
@@ -32,7 +32,7 @@ public class GetByMaxAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMaxAsync<TestDocument, Guid>(filter, selector, null, CancellationToken.None),
x => x.GetByMaxAsync<TestDocumentWithKey<int>, int>(filter, selector, null, CancellationToken.None),
Times.Once);
}
@@ -40,7 +40,7 @@ public class GetByMaxAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithFilterAndSelectorAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var token = new CancellationToken(true);
SetupReader(document);
@@ -52,7 +52,7 @@ public class GetByMaxAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMaxAsync<TestDocument, Guid>(filter, selector, null, token),
x => x.GetByMaxAsync<TestDocumentWithKey<int>, int>(filter, selector, null, token),
Times.Once);
}
@@ -60,7 +60,7 @@ public class GetByMaxAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithFilterAndSelectorAndPartitionKey_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
SetupReader(document);
@@ -72,7 +72,7 @@ public class GetByMaxAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMaxAsync<TestDocument, Guid>(filter, selector, partitionKey, CancellationToken.None),
x => x.GetByMaxAsync<TestDocumentWithKey<int>, int>(filter, selector, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -80,7 +80,7 @@ public class GetByMaxAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithFilterAndSelectorAndPartitionKeyAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
var token = new CancellationToken(true);
@@ -93,18 +93,18 @@ public class GetByMaxAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMaxAsync<TestDocument, Guid>(filter, selector, partitionKey, token),
x => x.GetByMaxAsync<TestDocumentWithKey<int>, int>(filter, selector, partitionKey, token),
Times.Once);
}
private void SetupReader(TestDocument document)
private void SetupReader(TestDocumentWithKey<int> document)
{
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetByMaxAsync<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, object>>>(),
x => x.GetByMaxAsync<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, object>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(document);
@@ -11,16 +11,16 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetByMaxTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetByMaxTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocument, object>> selector = document => document.SomeValue;
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocumentWithKey<int>, object>> selector = document => document.SomeValue;
[Fact]
public void WithFilterAndSelector_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
SetupReader(document);
@@ -31,7 +31,7 @@ public class GetByMaxTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMax<TestDocument, Guid>(filter, selector, null, CancellationToken.None),
x => x.GetByMax<TestDocumentWithKey<int>, int>(filter, selector, null, CancellationToken.None),
Times.Once);
}
@@ -39,7 +39,7 @@ public class GetByMaxTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public void WithFilterAndSelectorAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var token = new CancellationToken(true);
SetupReader(document);
@@ -51,7 +51,7 @@ public class GetByMaxTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMax<TestDocument, Guid>(filter, selector, null, token),
x => x.GetByMax<TestDocumentWithKey<int>, int>(filter, selector, null, token),
Times.Once);
}
@@ -59,7 +59,7 @@ public class GetByMaxTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public void WithFilterAndSelectorAndPartitionKey_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
SetupReader(document);
@@ -71,7 +71,7 @@ public class GetByMaxTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMax<TestDocument, Guid>(filter, selector, partitionKey, CancellationToken.None),
x => x.GetByMax<TestDocumentWithKey<int>, int>(filter, selector, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -79,7 +79,7 @@ public class GetByMaxTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public void WithFilterAndSelectorAndPartitionKeyAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
var token = new CancellationToken(true);
@@ -92,18 +92,18 @@ public class GetByMaxTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMax<TestDocument, Guid>(filter, selector, partitionKey, token),
x => x.GetByMax<TestDocumentWithKey<int>, int>(filter, selector, partitionKey, token),
Times.Once);
}
private void SetupReader(TestDocument document)
private void SetupReader(TestDocumentWithKey<int> document)
{
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetByMax<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, object>>>(),
x => x.GetByMax<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, object>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(document);
@@ -12,16 +12,16 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetByMinAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetByMinAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocument, object>> selector = document => document.SomeValue;
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocumentWithKey<int>, object>> selector = document => document.SomeValue;
[Fact]
public async Task WithFilterAndSelector_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
SetupReader(document);
@@ -32,7 +32,7 @@ public class GetByMinAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMinAsync<TestDocument, Guid>(filter, selector, null, CancellationToken.None),
x => x.GetByMinAsync<TestDocumentWithKey<int>, int>(filter, selector, null, CancellationToken.None),
Times.Once);
}
@@ -40,7 +40,7 @@ public class GetByMinAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithFilterAndSelectorAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var token = new CancellationToken(true);
SetupReader(document);
@@ -52,7 +52,7 @@ public class GetByMinAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMinAsync<TestDocument, Guid>(filter, selector, null, token),
x => x.GetByMinAsync<TestDocumentWithKey<int>, int>(filter, selector, null, token),
Times.Once);
}
@@ -60,7 +60,7 @@ public class GetByMinAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithFilterAndSelectorAndPartitionKey_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
SetupReader(document);
@@ -72,7 +72,7 @@ public class GetByMinAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMinAsync<TestDocument, Guid>(filter, selector, partitionKey, CancellationToken.None),
x => x.GetByMinAsync<TestDocumentWithKey<int>, int>(filter, selector, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -80,7 +80,7 @@ public class GetByMinAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithFilterAndSelectorAndPartitionKeyAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
var token = new CancellationToken(true);
@@ -93,18 +93,18 @@ public class GetByMinAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMinAsync<TestDocument, Guid>(filter, selector, partitionKey, token),
x => x.GetByMinAsync<TestDocumentWithKey<int>, int>(filter, selector, partitionKey, token),
Times.Once);
}
private void SetupReader(TestDocument document)
private void SetupReader(TestDocumentWithKey<int> document)
{
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetByMinAsync<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, object>>>(),
x => x.GetByMinAsync<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, object>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(document);
@@ -11,16 +11,16 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetByMinTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetByMinTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocument, object>> selector = document => document.SomeValue;
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocumentWithKey<int>, object>> selector = document => document.SomeValue;
[Fact]
public void WithFilterAndSelector_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
SetupReader(document);
@@ -31,7 +31,7 @@ public class GetByMinTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMin<TestDocument, Guid>(filter, selector, null, CancellationToken.None),
x => x.GetByMin<TestDocumentWithKey<int>, int>(filter, selector, null, CancellationToken.None),
Times.Once);
}
@@ -39,7 +39,7 @@ public class GetByMinTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public void WithFilterAndSelectorAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var token = new CancellationToken(true);
SetupReader(document);
@@ -51,7 +51,7 @@ public class GetByMinTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMin<TestDocument, Guid>(filter, selector, null, token),
x => x.GetByMin<TestDocumentWithKey<int>, int>(filter, selector, null, token),
Times.Once);
}
@@ -59,7 +59,7 @@ public class GetByMinTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public void WithFilterAndSelectorAndPartitionKey_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
SetupReader(document);
@@ -71,7 +71,7 @@ public class GetByMinTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMin<TestDocument, Guid>(filter, selector, partitionKey, CancellationToken.None),
x => x.GetByMin<TestDocumentWithKey<int>, int>(filter, selector, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -79,7 +79,7 @@ public class GetByMinTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public void WithFilterAndSelectorAndPartitionKeyAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
var token = new CancellationToken(true);
@@ -92,18 +92,18 @@ public class GetByMinTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetByMin<TestDocument, Guid>(filter, selector, partitionKey, token),
x => x.GetByMin<TestDocumentWithKey<int>, int>(filter, selector, partitionKey, token),
Times.Once);
}
private void SetupReader(TestDocument document)
private void SetupReader(TestDocumentWithKey<int> document)
{
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetByMin<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, object>>>(),
x => x.GetByMin<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, object>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(document);
@@ -12,10 +12,10 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetMaxValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetMaxValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocument, int>> selector = document => document.SomeValue;
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocumentWithKey<int>, int>> selector = document => document.SomeValue;
[Fact]
public async Task WithFilterAndSelector_GetsMaxValue()
@@ -31,7 +31,7 @@ public class GetMaxValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMaxValueAsync<TestDocument, Guid, int>(filter, selector, null, CancellationToken.None),
x => x.GetMaxValueAsync<TestDocumentWithKey<int>, int, int>(filter, selector, null, CancellationToken.None),
Times.Once);
}
@@ -50,7 +50,7 @@ public class GetMaxValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMaxValueAsync<TestDocument, Guid, int>(filter, selector, null, token),
x => x.GetMaxValueAsync<TestDocumentWithKey<int>, int, int>(filter, selector, null, token),
Times.Once);
}
@@ -69,7 +69,7 @@ public class GetMaxValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMaxValueAsync<TestDocument, Guid, int>(filter, selector, partitionKey, CancellationToken.None),
x => x.GetMaxValueAsync<TestDocumentWithKey<int>, int, int>(filter, selector, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -89,7 +89,7 @@ public class GetMaxValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMaxValueAsync<TestDocument, Guid, int>(filter, selector, partitionKey, token),
x => x.GetMaxValueAsync<TestDocumentWithKey<int>, int, int>(filter, selector, partitionKey, token),
Times.Once);
}
@@ -98,9 +98,9 @@ public class GetMaxValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetMaxValueAsync<TestDocument, Guid, int>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, int>>>(),
x => x.GetMaxValueAsync<TestDocumentWithKey<int>, int, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, int>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(value);
@@ -11,10 +11,10 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetMaxValueTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetMaxValueTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocument, int>> selector = document => document.SomeValue;
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocumentWithKey<int>, int>> selector = document => document.SomeValue;
[Fact]
public void WithFilterAndSelector_GetsMaxValue()
@@ -30,7 +30,7 @@ public class GetMaxValueTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMaxValue<TestDocument, Guid, int>(filter, selector, null, CancellationToken.None),
x => x.GetMaxValue<TestDocumentWithKey<int>, int, int>(filter, selector, null, CancellationToken.None),
Times.Once);
}
@@ -49,7 +49,7 @@ public class GetMaxValueTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMaxValue<TestDocument, Guid, int>(filter, selector, null, token),
x => x.GetMaxValue<TestDocumentWithKey<int>, int, int>(filter, selector, null, token),
Times.Once);
}
@@ -68,7 +68,7 @@ public class GetMaxValueTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMaxValue<TestDocument, Guid, int>(filter, selector, partitionKey, CancellationToken.None),
x => x.GetMaxValue<TestDocumentWithKey<int>, int, int>(filter, selector, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -88,7 +88,7 @@ public class GetMaxValueTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMaxValue<TestDocument, Guid, int>(filter, selector, partitionKey, token),
x => x.GetMaxValue<TestDocumentWithKey<int>, int, int>(filter, selector, partitionKey, token),
Times.Once);
}
@@ -97,9 +97,9 @@ public class GetMaxValueTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetMaxValue<TestDocument, Guid, int>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, int>>>(),
x => x.GetMaxValue<TestDocumentWithKey<int>, int, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, int>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(value);
@@ -12,10 +12,10 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetMinValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetMinValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocument, int>> selector = document => document.SomeValue;
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocumentWithKey<int>, int>> selector = document => document.SomeValue;
[Fact]
public async Task WithFilterAndSelector_GetsMaxValue()
@@ -31,7 +31,7 @@ public class GetMinValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMinValueAsync<TestDocument, Guid, int>(filter, selector, null, CancellationToken.None),
x => x.GetMinValueAsync<TestDocumentWithKey<int>, int, int>(filter, selector, null, CancellationToken.None),
Times.Once);
}
@@ -50,7 +50,7 @@ public class GetMinValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMinValueAsync<TestDocument, Guid, int>(filter, selector, null, token),
x => x.GetMinValueAsync<TestDocumentWithKey<int>, int, int>(filter, selector, null, token),
Times.Once);
}
@@ -69,7 +69,7 @@ public class GetMinValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMinValueAsync<TestDocument, Guid, int>(filter, selector, partitionKey, CancellationToken.None),
x => x.GetMinValueAsync<TestDocumentWithKey<int>, int, int>(filter, selector, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -89,7 +89,7 @@ public class GetMinValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMinValueAsync<TestDocument, Guid, int>(filter, selector, partitionKey, token),
x => x.GetMinValueAsync<TestDocumentWithKey<int>, int, int>(filter, selector, partitionKey, token),
Times.Once);
}
@@ -98,9 +98,9 @@ public class GetMinValueAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetMinValueAsync<TestDocument, Guid, int>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, int>>>(),
x => x.GetMinValueAsync<TestDocumentWithKey<int>, int, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, int>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(value);
@@ -11,10 +11,10 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetMinValueTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetMinValueTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocument, int>> selector = document => document.SomeValue;
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocumentWithKey<int>, int>> selector = document => document.SomeValue;
[Fact]
public void WithFilterAndSelector_GetsMinValue()
@@ -30,7 +30,7 @@ public class GetMinValueTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMinValue<TestDocument, Guid, int>(filter, selector, null, CancellationToken.None),
x => x.GetMinValue<TestDocumentWithKey<int>, int, int>(filter, selector, null, CancellationToken.None),
Times.Once);
}
@@ -49,7 +49,7 @@ public class GetMinValueTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMinValue<TestDocument, Guid, int>(filter, selector, null, token),
x => x.GetMinValue<TestDocumentWithKey<int>, int, int>(filter, selector, null, token),
Times.Once);
}
@@ -68,7 +68,7 @@ public class GetMinValueTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMinValue<TestDocument, Guid, int>(filter, selector, partitionKey, CancellationToken.None),
x => x.GetMinValue<TestDocumentWithKey<int>, int, int>(filter, selector, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -88,7 +88,7 @@ public class GetMinValueTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(value);
Reader.Verify(
x => x.GetMinValue<TestDocument, Guid, int>(filter, selector, partitionKey, token),
x => x.GetMinValue<TestDocumentWithKey<int>, int, int>(filter, selector, partitionKey, token),
Times.Once);
}
@@ -97,9 +97,9 @@ public class GetMinValueTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetMinValue<TestDocument, Guid, int>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, int>>>(),
x => x.GetMinValue<TestDocumentWithKey<int>, int, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, int>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(value);
@@ -12,15 +12,15 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetOneAsyncTests : 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 async Task WithFilter_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
SetupReader(document);
@@ -31,7 +31,7 @@ public class GetOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetOneAsync<TestDocument, Guid>(filter, null, CancellationToken.None),
x => x.GetOneAsync<TestDocumentWithKey<int>, int>(filter, null, CancellationToken.None),
Times.Once);
}
@@ -39,7 +39,7 @@ public class GetOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithFilterAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var token = new CancellationToken(true);
SetupReader(document);
@@ -51,7 +51,7 @@ public class GetOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetOneAsync<TestDocument, Guid>(filter, null, token),
x => x.GetOneAsync<TestDocumentWithKey<int>, int>(filter, null, token),
Times.Once);
}
@@ -59,7 +59,7 @@ public class GetOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithFilterAndPartitionKey_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
SetupReader(document);
@@ -71,7 +71,7 @@ public class GetOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetOneAsync<TestDocument, Guid>(filter, partitionKey, CancellationToken.None),
x => x.GetOneAsync<TestDocumentWithKey<int>, int>(filter, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -79,7 +79,7 @@ public class GetOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public async Task WithFilterAndPartitionKeyAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
var token = new CancellationToken(true);
@@ -92,17 +92,17 @@ public class GetOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetOneAsync<TestDocument, Guid>(filter, partitionKey, token),
x => x.GetOneAsync<TestDocumentWithKey<int>, int>(filter, partitionKey, token),
Times.Once);
}
private void SetupReader(TestDocument document)
private void SetupReader(TestDocumentWithKey<int> document)
{
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetOneAsync<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
x => x.GetOneAsync<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(document);
@@ -1,7 +1,6 @@
using System;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using AutoFixture;
using CoreUnitTests.Infrastructure;
using CoreUnitTests.Infrastructure.Model;
@@ -12,15 +11,15 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetOneTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetOneTests : 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 WithId_GetsOne()
public void WithFilter_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
SetupReader(document);
@@ -31,15 +30,15 @@ public class GetOneTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetOne<TestDocument, Guid>(filter, null, CancellationToken.None),
x => x.GetOne<TestDocumentWithKey<int>, int>(filter, null, CancellationToken.None),
Times.Once);
}
[Fact]
public void WithIdAndCancellationToken_GetsOne()
public void WithFilterAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var token = new CancellationToken(true);
SetupReader(document);
@@ -51,15 +50,15 @@ public class GetOneTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetOne<TestDocument, Guid>(filter, null, token),
x => x.GetOne<TestDocumentWithKey<int>, int>(filter, null, token),
Times.Once);
}
[Fact]
public void WithIdAndPartitionKey_GetsOne()
public void WithFilterAndPartitionKey_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
SetupReader(document);
@@ -71,15 +70,15 @@ public class GetOneTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetOne<TestDocument, Guid>(filter, partitionKey, CancellationToken.None),
x => x.GetOne<TestDocumentWithKey<int>, int>(filter, partitionKey, CancellationToken.None),
Times.Once);
}
[Fact]
public void WithIdAndPartitionKeyAndCancellationToken_GetsOne()
public void WithFilterAndPartitionKeyAndCancellationToken_GetsOne()
{
// Arrange
var document = Fixture.Create<TestDocument>();
var document = Fixture.Create<TestDocumentWithKey<int>>();
var partitionKey = Fixture.Create<string>();
var token = new CancellationToken(true);
@@ -92,17 +91,17 @@ public class GetOneTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(document);
Reader.Verify(
x => x.GetOne<TestDocument, Guid>(filter, partitionKey, token),
x => x.GetOne<TestDocumentWithKey<int>, int>(filter, partitionKey, token),
Times.Once);
}
private void SetupReader(TestDocument document)
private void SetupReader(TestDocumentWithKey<int> document)
{
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.GetOne<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
x => x.GetOne<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(document);
@@ -15,11 +15,11 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GetSortedPaginatedAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GetSortedPaginatedAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, bool>> filter = document => document.GroupingKey == 1;
private readonly Expression<Func<TestDocument, object>> selector = document => document.GroupingKey;
private readonly SortDefinition<TestDocument> sortDefinition = Builders<TestDocument>.Sort.Ascending(document => document.GroupingKey);
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.GroupingKey == 1;
private readonly Expression<Func<TestDocumentWithKey<int>, object>> selector = document => document.GroupingKey;
private readonly SortDefinition<TestDocumentWithKey<int>> sortDefinition = Builders<TestDocumentWithKey<int>>.Sort.Ascending(document => document.GroupingKey);
private const bool DefaultAscending = true;
private const int DefaultSkipNumber = 0;
@@ -178,15 +178,15 @@ public class GetSortedPaginatedAsyncTests : TestKeyedReadOnlyMongoRepositoryCont
VerifyDefinition(result, documents, DefaultSkipNumber, DefaultTakeNumber, null, token);
}
private List<TestDocument> SetupReaderWithSortSelector()
private List<TestDocumentWithKey<int>> SetupReaderWithSortSelector()
{
var documents = Fixture.CreateMany<TestDocument>().ToList();
var documents = Fixture.CreateMany<TestDocumentWithKey<int>>().ToList();
Reader = new Mock<IMongoDbReader>();
Reader.Setup(
x => x.GetSortedPaginatedAsync<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, object>>>(),
x => x.GetSortedPaginatedAsync<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, object>>>(),
It.IsAny<bool>(),
It.IsAny<int>(),
It.IsAny<int>(),
@@ -196,12 +196,12 @@ public class GetSortedPaginatedAsyncTests : TestKeyedReadOnlyMongoRepositoryCont
return documents;
}
private void VerifySelector(List<TestDocument> result, List<TestDocument> documents, bool ascending, int skipNumber, int takeNumber, string partitionKey, CancellationToken cancellationToken)
private void VerifySelector(List<TestDocumentWithKey<int>> result, List<TestDocumentWithKey<int>> documents, bool ascending, int skipNumber, int takeNumber, string partitionKey, CancellationToken cancellationToken)
{
result.Should().NotBeNull();
result.Should().BeEquivalentTo(documents);
Reader.Verify(
x => x.GetSortedPaginatedAsync<TestDocument, Guid>(
x => x.GetSortedPaginatedAsync<TestDocumentWithKey<int>, int>(
filter,
selector,
ascending,
@@ -212,15 +212,15 @@ public class GetSortedPaginatedAsyncTests : TestKeyedReadOnlyMongoRepositoryCont
Times.Once);
}
private List<TestDocument> SetupReaderWithSortDefinition()
private List<TestDocumentWithKey<int>> SetupReaderWithSortDefinition()
{
var documents = Fixture.CreateMany<TestDocument>().ToList();
var documents = Fixture.CreateMany<TestDocumentWithKey<int>>().ToList();
Reader = new Mock<IMongoDbReader>();
Reader.Setup(
x => x.GetSortedPaginatedAsync<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<SortDefinition<TestDocument>>(),
x => x.GetSortedPaginatedAsync<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<SortDefinition<TestDocumentWithKey<int>>>(),
It.IsAny<int>(),
It.IsAny<int>(),
It.IsAny<string>(),
@@ -229,12 +229,12 @@ public class GetSortedPaginatedAsyncTests : TestKeyedReadOnlyMongoRepositoryCont
return documents;
}
private void VerifyDefinition(List<TestDocument> result, List<TestDocument> documents, int skipNumber, int takeNumber, string partitionKey, CancellationToken cancellationToken)
private void VerifyDefinition(List<TestDocumentWithKey<int>> result, List<TestDocumentWithKey<int>> documents, int skipNumber, int takeNumber, string partitionKey, CancellationToken cancellationToken)
{
result.Should().NotBeNull();
result.Should().BeEquivalentTo(documents);
Reader.Verify(
x => x.GetSortedPaginatedAsync<TestDocument, Guid>(
x => x.GetSortedPaginatedAsync<TestDocumentWithKey<int>, int>(
filter,
sortDefinition,
skipNumber,
@@ -12,11 +12,11 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, int>> grouping = document => document.GroupingKey;
private readonly Expression<Func<IGrouping<int, TestDocument>, TestProjection>> projection = documents => new TestProjection {Count = documents.Count()};
private readonly Expression<Func<TestDocument, bool>> filter = document => document.GroupingKey == 1;
private readonly Expression<Func<TestDocumentWithKey<int>, int>> grouping = document => document.GroupingKey;
private readonly Expression<Func<IGrouping<int, TestDocumentWithKey<int>>, TestProjection>> projection = documents => new TestProjection {Count = documents.Count()};
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.GroupingKey == 1;
[Fact]
public void WithGroupingCriteriaAndProjection_Groups()
@@ -26,9 +26,9 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader.Setup(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(
It.IsAny<Expression<Func<TestDocument, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocument>, TestProjection>>>(),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocumentWithKey<int>>, TestProjection>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(projections);
@@ -40,7 +40,7 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(projections);
Reader.Verify(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(grouping, projection, null, CancellationToken.None),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(grouping, projection, null, CancellationToken.None),
Times.Once);
}
@@ -54,9 +54,9 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader
.Setup(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(
It.IsAny<Expression<Func<TestDocument, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocument>, TestProjection>>>(),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocumentWithKey<int>>, TestProjection>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(projections);
@@ -68,7 +68,7 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(projections);
Reader.Verify(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(grouping, projection, null, token),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(grouping, projection, null, token),
Times.Once);
}
@@ -82,9 +82,9 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader
.Setup(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(
It.IsAny<Expression<Func<TestDocument, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocument>, TestProjection>>>(),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocumentWithKey<int>>, TestProjection>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(projections);
@@ -96,7 +96,7 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(projections);
Reader.Verify(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(grouping, projection, partitionKey, CancellationToken.None),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(grouping, projection, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -111,9 +111,9 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader
.Setup(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(
It.IsAny<Expression<Func<TestDocument, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocument>, TestProjection>>>(),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocumentWithKey<int>>, TestProjection>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(projections);
@@ -125,7 +125,7 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(projections);
Reader.Verify(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(grouping, projection, partitionKey, token),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(grouping, projection, partitionKey, token),
Times.Once);
}
@@ -137,10 +137,10 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader.Setup(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(
It.IsAny<Expression<Func<TestDocument,bool>>>(),
It.IsAny<Expression<Func<TestDocument, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocument>, TestProjection>>>(),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>,bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocumentWithKey<int>>, TestProjection>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(projections);
@@ -152,7 +152,7 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(projections);
Reader.Verify(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(filter, grouping, projection, null, CancellationToken.None),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(filter, grouping, projection, null, CancellationToken.None),
Times.Once);
}
@@ -165,10 +165,10 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader.Setup(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(
It.IsAny<Expression<Func<TestDocument,bool>>>(),
It.IsAny<Expression<Func<TestDocument, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocument>, TestProjection>>>(),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>,bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocumentWithKey<int>>, TestProjection>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(projections);
@@ -180,7 +180,7 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(projections);
Reader.Verify(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(filter, grouping, projection, null, token),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(filter, grouping, projection, null, token),
Times.Once);
}
@@ -193,10 +193,10 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader.Setup(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(
It.IsAny<Expression<Func<TestDocument,bool>>>(),
It.IsAny<Expression<Func<TestDocument, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocument>, TestProjection>>>(),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>,bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocumentWithKey<int>>, TestProjection>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(projections);
@@ -208,7 +208,7 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(projections);
Reader.Verify(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(filter, grouping, projection, partitionKey, CancellationToken.None),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(filter, grouping, projection, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -222,10 +222,10 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader.Setup(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(
It.IsAny<Expression<Func<TestDocument,bool>>>(),
It.IsAny<Expression<Func<TestDocument, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocument>, TestProjection>>>(),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>,bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, int>>>(),
It.IsAny<Expression<Func<IGrouping<int, TestDocumentWithKey<int>>, TestProjection>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.Returns(projections);
@@ -237,7 +237,7 @@ public class GroupByTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
result.Should().NotBeNull();
result.Should().BeEquivalentTo(projections);
Reader.Verify(
x => x.GroupBy<TestDocument, int, TestProjection, Guid>(filter, grouping, projection, partitionKey, token),
x => x.GroupBy<TestDocumentWithKey<int>, int, TestProjection, int>(filter, grouping, projection, partitionKey, token),
Times.Once);
}
}
@@ -14,10 +14,10 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class ProjectManyAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class ProjectManyAsyncTests : 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 async Task WithFilterAndProjection_Projects()
@@ -33,7 +33,7 @@ public class ProjectManyAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
// Assert
result.Should().OnlyContain(x => projections.Contains(x));
Reader.Verify(
x => x.ProjectManyAsync<TestDocument, TestProjection, Guid>(
x => x.ProjectManyAsync<TestDocumentWithKey<int>, TestProjection, int>(
filter,
projection,
null,
@@ -56,7 +56,7 @@ public class ProjectManyAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
// Assert
result.Should().OnlyContain(x => projections.Contains(x));
Reader.Verify(
x => x.ProjectManyAsync<TestDocument, TestProjection, Guid>(filter, projection, null, token),
x => x.ProjectManyAsync<TestDocumentWithKey<int>, TestProjection, int>(filter, projection, null, token),
Times.Once);
}
@@ -75,7 +75,7 @@ public class ProjectManyAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
// Assert
result.Should().OnlyContain(x => projections.Contains(x));
Reader.Verify(
x => x.ProjectManyAsync<TestDocument, TestProjection, Guid>(filter, projection, partitionKey, CancellationToken.None),
x => x.ProjectManyAsync<TestDocumentWithKey<int>, TestProjection, int>(filter, projection, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -95,7 +95,7 @@ public class ProjectManyAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
// Assert
result.Should().OnlyContain(x => projections.Contains(x));
Reader.Verify(
x => x.ProjectManyAsync<TestDocument, TestProjection, Guid>(filter, projection, partitionKey, token),
x => x.ProjectManyAsync<TestDocumentWithKey<int>, TestProjection, int>(filter, projection, partitionKey, token),
Times.Once);
}
@@ -104,9 +104,9 @@ public class ProjectManyAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Gui
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.ProjectManyAsync<TestDocument, TestProjection, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, TestProjection>>>(),
x => x.ProjectManyAsync<TestDocumentWithKey<int>, TestProjection, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, TestProjection>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(projections);
@@ -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);
@@ -12,10 +12,10 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class ProjectOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class ProjectOneAsyncTests : 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 async Task WithFilterAndProjection_Projects()
@@ -31,7 +31,7 @@ public class ProjectOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.ProjectOneAsync<TestDocument, TestProjection, Guid>(
x => x.ProjectOneAsync<TestDocumentWithKey<int>, TestProjection, int>(
filter,
projection,
null,
@@ -54,7 +54,7 @@ public class ProjectOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.ProjectOneAsync<TestDocument, TestProjection, Guid>(filter, projection, null, token),
x => x.ProjectOneAsync<TestDocumentWithKey<int>, TestProjection, int>(filter, projection, null, token),
Times.Once);
}
@@ -73,7 +73,7 @@ public class ProjectOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.ProjectOneAsync<TestDocument, TestProjection, Guid>(filter, projection, partitionKey, CancellationToken.None),
x => x.ProjectOneAsync<TestDocumentWithKey<int>, TestProjection, int>(filter, projection, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -93,7 +93,7 @@ public class ProjectOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.ProjectOneAsync<TestDocument, TestProjection, Guid>(filter, projection, partitionKey, token),
x => x.ProjectOneAsync<TestDocumentWithKey<int>, TestProjection, int>(filter, projection, partitionKey, token),
Times.Once);
}
@@ -102,9 +102,9 @@ public class ProjectOneAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.ProjectOneAsync<TestDocument, TestProjection, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, TestProjection>>>(),
x => x.ProjectOneAsync<TestDocumentWithKey<int>, TestProjection, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, TestProjection>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(result);
@@ -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);
@@ -12,11 +12,11 @@ using Xunit;
namespace CoreUnitTests.KeyedReadOnlyMongoRepositoryTests;
public class SumByAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
public class SumByAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<int>
{
private readonly Expression<Func<TestDocument, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocument, int>> intSelector = document => document.SomeValue;
private readonly Expression<Func<TestDocument, decimal>> decimalSelector = document => document.SomeDecimalValue;
private readonly Expression<Func<TestDocumentWithKey<int>, bool>> filter = document => document.SomeContent == "SomeContent";
private readonly Expression<Func<TestDocumentWithKey<int>, int>> intSelector = document => document.SomeValue;
private readonly Expression<Func<TestDocumentWithKey<int>, decimal>> decimalSelector = document => document.SomeDecimalValue;
[Fact]
public async Task Int_WithFilterAndSelector_Sums()
@@ -32,7 +32,7 @@ public class SumByAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.SumByAsync<TestDocument, Guid>(filter, intSelector, null, CancellationToken.None),
x => x.SumByAsync<TestDocumentWithKey<int>, int>(filter, intSelector, null, CancellationToken.None),
Times.Once);
}
@@ -51,7 +51,7 @@ public class SumByAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.SumByAsync<TestDocument, Guid>(filter, intSelector, null, token),
x => x.SumByAsync<TestDocumentWithKey<int>, int>(filter, intSelector, null, token),
Times.Once);
}
@@ -70,7 +70,7 @@ public class SumByAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.SumByAsync<TestDocument, Guid>(filter, intSelector, partitionKey, CancellationToken.None),
x => x.SumByAsync<TestDocumentWithKey<int>, int>(filter, intSelector, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -90,7 +90,7 @@ public class SumByAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.SumByAsync<TestDocument, Guid>(filter, intSelector, partitionKey, token),
x => x.SumByAsync<TestDocumentWithKey<int>, int>(filter, intSelector, partitionKey, token),
Times.Once);
}
@@ -108,7 +108,7 @@ public class SumByAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.SumByAsync<TestDocument, Guid>(filter, decimalSelector, null, CancellationToken.None),
x => x.SumByAsync<TestDocumentWithKey<int>, int>(filter, decimalSelector, null, CancellationToken.None),
Times.Once);
}
@@ -127,7 +127,7 @@ public class SumByAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.SumByAsync<TestDocument, Guid>(filter, decimalSelector, null, token),
x => x.SumByAsync<TestDocumentWithKey<int>, int>(filter, decimalSelector, null, token),
Times.Once);
}
@@ -146,7 +146,7 @@ public class SumByAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.SumByAsync<TestDocument, Guid>(filter, decimalSelector, partitionKey, CancellationToken.None),
x => x.SumByAsync<TestDocumentWithKey<int>, int>(filter, decimalSelector, partitionKey, CancellationToken.None),
Times.Once);
}
@@ -166,7 +166,7 @@ public class SumByAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
// Assert
result.Should().Be(expected);
Reader.Verify(
x => x.SumByAsync<TestDocument, Guid>(filter, decimalSelector, partitionKey, token),
x => x.SumByAsync<TestDocumentWithKey<int>, int>(filter, decimalSelector, partitionKey, token),
Times.Once);
}
@@ -175,9 +175,9 @@ public class SumByAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.SumByAsync<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument,int>>>(),
x => x.SumByAsync<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>,int>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(expected);
@@ -188,9 +188,9 @@ public class SumByAsyncTests : TestKeyedReadOnlyMongoRepositoryContext<Guid>
Reader = new Mock<IMongoDbReader>();
Reader
.Setup(
x => x.SumByAsync<TestDocument, Guid>(
It.IsAny<Expression<Func<TestDocument, bool>>>(),
It.IsAny<Expression<Func<TestDocument, decimal>>>(),
x => x.SumByAsync<TestDocumentWithKey<int>, int>(
It.IsAny<Expression<Func<TestDocumentWithKey<int>, bool>>>(),
It.IsAny<Expression<Func<TestDocumentWithKey<int>, decimal>>>(),
It.IsAny<string>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(expected);