added some missing cancellation tokens and fixed incorrect tests

This commit is contained in:
Sean Garrett
2023-06-16 22:40:46 +01:00
parent f09cfc53c2
commit 23780697fb
25 changed files with 1077 additions and 175 deletions
@@ -0,0 +1,14 @@
namespace CoreUnitTests.Infrastructure;
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using MongoDB.Driver;
public static class FilterDefinitionExtensions
{
public static string RenderToJson<TDocument>(this FilterDefinition<TDocument> filter)
=> filter.Render(BsonSerializer.SerializerRegistry.GetSerializer<TDocument>(), BsonSerializer.SerializerRegistry).ToJson();
public static bool EquivalentTo<TDocument>(this FilterDefinition<TDocument> filter, FilterDefinition<TDocument> other)
=> filter.RenderToJson() == other.RenderToJson();
}
@@ -0,0 +1,23 @@
using AutoFixture;
using AutoFixture.AutoMoq;
using Moq;
namespace CoreUnitTests.Infrastructure;
public class GenericTestContext<TSut>
{
public GenericTestContext()
{
Fixture = new Fixture().Customize(new AutoMoqCustomization());
}
protected Mock<T> MockOf<T>()
where T : class
{
return Fixture.Freeze<Mock<T>>();
}
protected IFixture Fixture { get; set; }
protected TSut Sut { get => Fixture.Create<TSut>(); }
}
@@ -0,0 +1,9 @@
using MongoDbGenericRepository.Models;
namespace CoreUnitTests.Infrastructure.Model;
public class PartitionedTestDocument : TestDocument, IPartitionedDocument
{
/// <inheritdoc />
public string PartitionKey { get; set; } = "PartitionedTestDocument";
}