Compare commits

..

18 Commits

Author SHA1 Message Date
UltimateCoder b69cc9ea75 Add .github/workflows/nuget-preview.yml 2024-11-26 22:19:05 +01:00
UltimateCoder 68ce5b04d9 Update .github/workflows/nuget-ci.yml 2024-11-26 22:17:37 +01:00
UltimateCoder 6c33537060 Update .github/workflows/nuget-ci.yml 2024-11-26 22:15:25 +01:00
UltimateCoder 00bd61e220 Update .github/workflows/nuget-ci.yml
/ build (push) Successful in 45s
2024-11-26 22:08:40 +01:00
UltimateCoder c5240aea9a Update .github/workflows/nuget-ci.yml
/ build (push) Failing after 45s
2024-11-26 21:48:22 +01:00
UltimateCoder a748189f84 Update .github/workflows/nuget-ci.yml
/ build (push) Failing after 48s
2024-11-26 21:41:18 +01:00
UltimateCoder 6ce49c378d Update MongoDbGenericRepository/MongoDbGenericRepository.csproj
/ build (push) Failing after 44s
2024-11-26 21:34:23 +01:00
UltimateCoder c45b0a49d7 Update .github/workflows/nuget-ci.yml
/ build (push) Failing after 44s
2024-11-26 21:26:47 +01:00
UltimateCoder e5f65e8f19 Add .github/workflows/nuget-ci.yml
/ build (push) Failing after 24s
2024-11-26 21:26:29 +01:00
UltimateCoder 720e09bdbc NuGet Cleanup 2024-11-26 00:26:46 +01:00
UltimateCoder 2b0b04ec7b Updated to .Net Core 8 2024-11-26 00:18:00 +01:00
Alexandre SPIESER e8842f8991 Merge pull request #61 from alexandre-spieser/alex/updateToDriverToV2-28
update driver to 2.28
2024-11-23 16:27:22 +00:00
Alexandre Spieser a54b702841 update driver to 2.28 2024-11-23 16:01:33 +00:00
Alexandre SPIESER 9c48653dc6 Merge pull request #57 from mrtaikandi/mongodriver-2.25
Upgrade MongoDb driver and its related packages to 2.25.0
2024-05-28 15:16:53 +01:00
Mohammadreza Taikandi b083988509 Upgrade MongoDb driver and its related packages to 2.25.0 2024-05-28 15:07:12 +01:00
Alexandre SPIESER 7bd356c7da Merge pull request #56 from mrtaikandi/mongodriver-2.20
Upgrade to MongoDb Driver 2.20 and use GuidRepresentationMode.V3 as the default representation.
This potentially can cause a breaking change to the package consumer, but the behaviour can be set to V2 by overriding the void SetGuidRepresentation(GuidRepresentation guidRepresentation) method.
GuidRepresentation and GuidRepresentationMode will be removed in the next major release of the MongoDB Driver:
https://www.mongodb.com/community/forums/t/c-guid-style-dont-work/126901/2
What's new in 2.20 and 2.19:
https://www.mongodb.com/docs/drivers/csharp/current/whats-new/#std-label-csharp-whats-new
2023-08-11 11:07:13 +01:00
Mohammadreza Taikandi f59cccb3d9 Upgrade to MongoDb Driver 2.20 and use GuidRepresentationMode.V3 as default representation. 2023-08-07 11:34:35 +01:00
Alexandre Spieser 710b7b992f upgrade to MongoDb Driver 2.18 - 2.19 seems to have some broken some tests, investigating. 2023-08-02 22:56:58 +01:00
39 changed files with 454 additions and 480 deletions
+33
View File
@@ -0,0 +1,33 @@
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
env:
PACKAGE_VERSION: ${GITHUB_REF/refs\/tags\/v/}
PACKAGE_OWNER: ${{ github.repository_owner }}
PACKAGE_NAME: MongoDbGenericRepository.${{ env.PACKAGE_VERSION }}.nupkg
PACKAGE_SOURCE: https://git.home.cuco.li/api/packages/${{ env.PACKAGE_OWNER }}/nuget/index.json
PACKAGE_TOKEN: ${{ secrets.PACKAGE_PUSH_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x.x'
- name: Verify commit exists in origin/master
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
git branch --remote --contains | grep origin/master
- name: Build
run: dotnet build --configuration Release /p:Version=${{ env.PACKAGE_VERSION }}
- name: Test
run: dotnet test --configuration Release /p:Version=${{ env.PACKAGE_VERSION }} --no-build
- name: Pack
run: dotnet pack --configuration Release /p:Version=${{ env.PACKAGE_VERSION }} --no-build --output .
- name: Push
run: dotnet nuget push ${{ env.PACKAGE_NAME }} --source ${{ env.PACKAGE_SOURCE }} --api-key ${{ env.PACKAGE_TOKEN }}
+25
View File
@@ -0,0 +1,25 @@
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+-preview[0-9][0-9][0-9]"
env:
PACKAGE_VERSION: ${GITHUB_REF/refs\/tags\/v/}
PACKAGE_OWNER: ${{ github.repository_owner }}
PACKAGE_NAME: MongoDbGenericRepository.${{ env.PACKAGE_VERSION }}.nupkg
PACKAGE_SOURCE: https://git.home.cuco.li/api/packages/${{ env.PACKAGE_OWNER }}/nuget/index.json
PACKAGE_TOKEN: ${{ secrets.PACKAGE_PUSH_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x.x'
- name: Pack
run: dotnet pack --configuration Release /p:Version=${{ env.PACKAGE_VERSION }} --output .
- name: Push
run: dotnet nuget push ${{ env.PACKAGE_NAME }} --source ${{ env.PACKAGE_SOURCE }} --api-key ${{ env.PACKAGE_TOKEN }}
-10
View File
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="MongoDbTests" connectionString="mongodb://localhost:27017" />
</connectionStrings>
</configuration>
@@ -1,29 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.2" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.1.2" />
<PackageReference Include="MongoDB.Driver" Version="2.15.0" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.console" Version="2.5.0">
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.11" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageReference Include="MongoDB.Driver" Version="3.0.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.console" Version="2.9.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
</ItemGroup>
<ItemGroup>
<None Update="App.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
</ItemGroup>
<ItemGroup>
@@ -11,10 +11,8 @@ using Xunit;
namespace CoreIntegrationTests.Infrastructure
{
public abstract partial class MongoDbDocumentTestBase<T>
where T : TestDoc, new()
public abstract partial class MongoDbDocumentTestBase<T> where T : TestDoc, new()
{
private readonly MongoDbTestFixture<T, Guid> _fixture;
protected MongoDbDocumentTestBase(MongoDbTestFixture<T, Guid> fixture)
@@ -14,8 +14,7 @@ using Xunit;
namespace CoreIntegrationTests.Infrastructure
{
public abstract partial class MongoDbDocumentTestBase<T> :
IClassFixture<MongoDbTestFixture<T, Guid>>
where T : TestDoc, new()
IClassFixture<MongoDbTestFixture<T, Guid>> where T : TestDoc, new()
{
#region Update One
@@ -40,7 +40,7 @@ namespace CoreIntegrationTests.Infrastructure
public class TestDoc : Document
{
public TestDoc()
protected TestDoc()
{
Version = 2;
Nested = new Nested
@@ -12,7 +12,7 @@ namespace CoreIntegrationTests.Infrastructure
public class TestTKeyRepository<TKey> : BaseMongoRepository<TKey>, ITestRepository<TKey> where TKey : IEquatable<TKey>
{
const string connectionString = "mongodb://localhost:27017/MongoDbTests";
const string connectionString = "mongodb://test:Test123!@10.0.3.4:27017/MongoDbTests";
private static readonly ITestRepository<TKey> _instance = new TestTKeyRepository<TKey>(connectionString);
/// <inheritdoc />
private TestTKeyRepository(string connectionString) : base(connectionString)
@@ -44,7 +44,7 @@ namespace CoreIntegrationTests.Infrastructure
public sealed class TestRepository : BaseMongoRepository, ITestRepository
{
const string connectionString = "mongodb://localhost:27017";
const string connectionString = "mongodb://test:Test123!@10.0.3.4:27017";
private static readonly ITestRepository _instance = new TestRepository(connectionString, "MongoDbTests");
// Explicit static constructor to tell C# compiler
+11 -10
View File
@@ -1,30 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>warnings</Nullable>
<IsPackable>false</IsPackable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.18.0" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.18.0" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.console" Version="2.5.0">
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.18.1" />
<PackageReference Include="FluentAssertions" Version="6.12.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.console" Version="2.9.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
@@ -531,8 +531,8 @@ public class UpdateManyAsyncTests : GenericTestContext<MongoDbUpdater>
private Mock<IMongoCollection<TestDocument>> SetupCollection(long count, string partitionKey = null)
{
var replacedId = Fixture.Create<Guid>();
var replaceResult = new ReplaceOneResult.Acknowledged(count, count, BsonValue.Create(replacedId));
var updateResult = new UpdateResult.Acknowledged(count, count, BsonValue.Create(replacedId));
var replaceResult = new ReplaceOneResult.Acknowledged(count, count, new BsonBinaryData(replacedId, GuidRepresentation.Standard));
var updateResult = new UpdateResult.Acknowledged(count, count, new BsonBinaryData(replacedId, GuidRepresentation.Standard));
var collection = MockOf<IMongoCollection<TestDocument>>();
collection
@@ -530,8 +530,8 @@ public class UpdateManyTests : GenericTestContext<MongoDbUpdater>
private Mock<IMongoCollection<TestDocument>> SetupCollection(long count, string partitionKey = null)
{
var replacedId = Fixture.Create<Guid>();
var replaceResult = new ReplaceOneResult.Acknowledged(count, count, BsonValue.Create(replacedId));
var updateResult = new UpdateResult.Acknowledged(count, count, BsonValue.Create(replacedId));
var replaceResult = new ReplaceOneResult.Acknowledged(count, count, new BsonBinaryData(replacedId, GuidRepresentation.Standard));
var updateResult = new UpdateResult.Acknowledged(count, count, new BsonBinaryData(replacedId, GuidRepresentation.Standard));
var collection = MockOf<IMongoCollection<TestDocument>>();
collection
@@ -755,8 +755,8 @@ public class UpdateOneAsyncTests : GenericTestContext<MongoDbUpdater>
{
var replacedId = Fixture.Create<Guid>();
var count = Fixture.Create<long>();
var replaceResult = new ReplaceOneResult.Acknowledged(count, 1, BsonValue.Create(replacedId));
var updateResult = new UpdateResult.Acknowledged(count, 1, BsonValue.Create(replacedId));
var replaceResult = new ReplaceOneResult.Acknowledged(count, 1, new BsonBinaryData(replacedId, GuidRepresentation.Standard));
var updateResult = new UpdateResult.Acknowledged(count, 1, new BsonBinaryData(replacedId, GuidRepresentation.Standard));
var collection = MockOf<IMongoCollection<TestDocument>>();
collection
@@ -754,8 +754,8 @@ public class UpdateOneTests : GenericTestContext<MongoDbUpdater>
{
var replacedId = Fixture.Create<Guid>();
var count = Fixture.Create<long>();
var replaceResult = new ReplaceOneResult.Acknowledged(count, 1, BsonValue.Create(replacedId));
var updateResult = new UpdateResult.Acknowledged(count, 1, BsonValue.Create(replacedId));
var replaceResult = new ReplaceOneResult.Acknowledged(count, 1, new BsonBinaryData(replacedId, GuidRepresentation.Standard));
var updateResult = new UpdateResult.Acknowledged(count, 1, new BsonBinaryData(replacedId, GuidRepresentation.Standard));
var collection = MockOf<IMongoCollection<TestDocument>>();
collection
@@ -7,7 +7,7 @@ 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();
=> filter.Render(new RenderArgs<TDocument>(BsonSerializer.SerializerRegistry.GetSerializer<TDocument>(), BsonSerializer.SerializerRegistry)).ToJson();
public static bool EquivalentTo<TDocument>(this FilterDefinition<TDocument> filter, FilterDefinition<TDocument> other)
=> filter.RenderToJson() == other.RenderToJson();
@@ -59,9 +59,7 @@ public static class IndexExtensions
private static string RenderIndexModelKeys<TDocument>(IndexKeysDefinition<TDocument> keys)
{
var indexModelRendered = keys.Render(
BsonSerializer.SerializerRegistry.GetSerializer<TDocument>(),
BsonSerializer.SerializerRegistry);
var indexModelRendered = keys.Render(new RenderArgs<TDocument>(BsonSerializer.SerializerRegistry.GetSerializer<TDocument>(), BsonSerializer.SerializerRegistry));
var result = indexModelRendered.ToString();
return result.Replace(" ", "");
@@ -8,13 +8,9 @@ public static class UpdateDefinitionExtensions
{
public static bool EquivalentTo<TDocument>(this UpdateDefinition<TDocument> update, UpdateDefinition<TDocument> expected)
{
var renderedUpdate = update.Render(
BsonSerializer.SerializerRegistry.GetSerializer<TDocument>(),
BsonSerializer.SerializerRegistry);
var renderedUpdate = update.Render(new RenderArgs<TDocument>(BsonSerializer.SerializerRegistry.GetSerializer<TDocument>(), BsonSerializer.SerializerRegistry));
var renderedExpected = expected.Render(
BsonSerializer.SerializerRegistry.GetSerializer<TDocument>(),
BsonSerializer.SerializerRegistry);
var renderedExpected = expected.Render(new RenderArgs<TDocument>(BsonSerializer.SerializerRegistry.GetSerializer<TDocument>(), BsonSerializer.SerializerRegistry) );
return renderedUpdate.Equals(renderedExpected);
}
+45 -4
View File
@@ -4,14 +4,55 @@
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="MongoDbTests" connectionString="mongodb://localhost:27017" />
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Win32.Registry" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MongoDB.Bson" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.20.0.0" newVersion="2.20.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MongoDB.Driver.Core" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.20.0.0" newVersion="2.20.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MongoDB.Libmongocrypt" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.9.0.0" newVersion="1.9.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="mscorlib" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.AccessControl" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Principal.Windows" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ZstdSharp" publicKeyToken="8d151af33a4ad5cf" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-0.7.3.0" newVersion="0.7.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
@@ -1,8 +1,9 @@
using IntegrationTests.Infrastructure;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Attributes;
using MongoDbGenericRepository.Attributes;
using MongoDbGenericRepository.Models;
using System;
using IntegrationTests.Infrastructure;
using TestDoc = IntegrationTests.Infrastructure.TestDoc;
namespace IntegrationTests
{
+1
View File
@@ -1,5 +1,6 @@
using IntegrationTests.Infrastructure;
using MongoDbGenericRepository.Models;
using TestDoc = IntegrationTests.Infrastructure.TestDoc;
namespace IntegrationTests
{
+2
View File
@@ -1,5 +1,7 @@
using IntegrationTests.Infrastructure;
using NUnit.Framework;
using NUnit.Framework.Internal;
using TestDoc = IntegrationTests.Infrastructure.TestDoc;
namespace IntegrationTests
{
@@ -41,8 +41,7 @@ namespace IntegrationTests.Infrastructure
[OneTimeSetUp]
public void Init()
{
var connectionString = ConfigurationManager.ConnectionStrings["MongoDbTests"].ConnectionString;
SUT = new TestRepository(connectionString, "MongoDbTests");
SUT = new TestRepository("mongodb://test:Test123!@10.0.3.4:27017", "MongoDbTests");
}
[OneTimeTearDown]
@@ -7,6 +7,7 @@ using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using NUnit.Framework.Legacy;
namespace IntegrationTests.Infrastructure
{
@@ -65,8 +66,7 @@ namespace IntegrationTests.Infrastructure
[OneTimeSetUp]
public void Init()
{
var connectionString = ConfigurationManager.ConnectionStrings["MongoDbTests"].ConnectionString;
SUT = new TestRepository(connectionString, "MongoDbTests");
SUT = new TestRepository("mongodb://test:Test123!@10.0.3.4:27017/", "MongoDbTests");
}
[OneTimeTearDown]
@@ -95,7 +95,7 @@ namespace IntegrationTests.Infrastructure
// Assert
long count = string.IsNullOrEmpty(PartitionKey) ? SUT.Count<T>(e => e.Id.Equals(document.Id))
: SUT.Count<T>(e => e.Id.Equals(document.Id), PartitionKey);
Assert.AreEqual(1, count, GetTestName());
Assert.That(count, Is.EqualTo(1), GetTestName());
}
[Test]
@@ -108,7 +108,7 @@ namespace IntegrationTests.Infrastructure
// Assert
long count = string.IsNullOrEmpty(PartitionKey) ? SUT.Count<T>(e => e.Id.Equals(document.Id))
: SUT.Count<T>(e => e.Id.Equals(document.Id), PartitionKey);
Assert.AreEqual(1, count, GetTestName());
Assert.That(count, Is.EqualTo(1), GetTestName());
}
[Test]
@@ -123,7 +123,7 @@ namespace IntegrationTests.Infrastructure
|| e.Id.Equals(documents[1].Id))
: SUT.Count<T>(e => e.Id.Equals(documents[0].Id)
|| e.Id.Equals(documents[1].Id), PartitionKey);
Assert.AreEqual(2, count, GetTestName());
Assert.That(count, Is.EqualTo(2), GetTestName());
}
[Test]
@@ -138,7 +138,7 @@ namespace IntegrationTests.Infrastructure
|| e.Id.Equals(documents[1].Id))
: SUT.Count<T>(e => e.Id.Equals(documents[0].Id)
|| e.Id.Equals(documents[1].Id), PartitionKey);
Assert.AreEqual(2, count, GetTestName());
Assert.That(count, Is.EqualTo(2), GetTestName());
}
@@ -155,7 +155,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.GetByIdAsync<T>(document.Id, PartitionKey);
// Assert
Assert.IsNotNull(result, GetTestName());
ClassicAssert.IsNotNull(result, GetTestName());
}
[Test]
@@ -167,7 +167,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.GetById<T>(document.Id, PartitionKey);
// Assert
Assert.IsNotNull(result, GetTestName());
ClassicAssert.IsNotNull(result, GetTestName());
}
[Test]
@@ -179,7 +179,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.GetOneAsync<T>(x => x.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.IsNotNull(result, GetTestName());
ClassicAssert.IsNotNull(result, GetTestName());
}
[Test]
@@ -191,7 +191,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.GetOne<T>(x => x.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.IsNotNull(result, GetTestName());
ClassicAssert.IsNotNull(result, GetTestName());
}
[Test]
@@ -204,7 +204,7 @@ namespace IntegrationTests.Infrastructure
var cursor = SUT.GetCursor<T>(x => x.Id.Equals(document.Id), PartitionKey);
var count = cursor.CountDocuments();
// Assert
Assert.AreEqual(1, count, GetTestName());
Assert.That(count, Is.EqualTo(1), GetTestName());
}
[Test]
@@ -216,7 +216,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.AnyAsync<T>(x => x.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.AreEqual(true, result, GetTestName());
Assert.That(result, Is.EqualTo(true), GetTestName());
}
[Test]
@@ -228,7 +228,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.AnyAsync<T>(x => x.Id.Equals(Guid.NewGuid()), PartitionKey);
// Assert
Assert.AreEqual(false, result, GetTestName());
Assert.That(result, Is.EqualTo(false), GetTestName());
}
[Test]
@@ -240,7 +240,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.Any<T>(x => x.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.AreEqual(true, result, GetTestName());
Assert.That(result, Is.EqualTo(true), GetTestName());
}
[Test]
@@ -252,7 +252,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.Any<T>(x => x.Id.Equals(Guid.NewGuid()), PartitionKey);
// Assert
Assert.AreEqual(false, result, GetTestName());
Assert.That(result, Is.EqualTo(false), GetTestName());
}
[Test]
@@ -266,7 +266,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.GetAllAsync<T>(x => x.SomeContent == content, PartitionKey);
// Assert
Assert.AreEqual(5, result.Count, GetTestName());
Assert.That(result.Count, Is.EqualTo(5), GetTestName());
}
[Test]
@@ -280,7 +280,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.GetAll<T>(x => x.SomeContent == content, PartitionKey);
// Assert
Assert.AreEqual(5, result.Count, GetTestName());
Assert.That(result.Count, Is.EqualTo(5), GetTestName());
}
[Test]
@@ -294,7 +294,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.CountAsync<T>(x => x.SomeContent == content, PartitionKey);
// Assert
Assert.AreEqual(5, result, GetTestName());
Assert.That(result, Is.EqualTo(5), GetTestName());
}
[Test]
@@ -308,7 +308,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.Count<T>(x => x.SomeContent == content, PartitionKey);
// Assert
Assert.AreEqual(5, result, GetTestName());
Assert.That(result, Is.EqualTo(5), GetTestName());
}
#endregion Read
@@ -326,10 +326,10 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.UpdateOne<T>(document);
// Assert
Assert.IsTrue(result);
ClassicAssert.IsTrue(result);
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument, GetTestName());
Assert.AreEqual(content, updatedDocument.SomeContent, GetTestName());
ClassicAssert.IsNotNull(updatedDocument, GetTestName());
Assert.That(updatedDocument.SomeContent, Is.EqualTo(content), GetTestName());
}
[Test]
@@ -343,10 +343,10 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.UpdateOneAsync<T>(document);
// Assert
Assert.IsTrue(result);
ClassicAssert.IsTrue(result);
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument, GetTestName());
Assert.AreEqual(content, updatedDocument.SomeContent, GetTestName());
ClassicAssert.IsNotNull(updatedDocument, GetTestName());
Assert.That(updatedDocument.SomeContent, Is.EqualTo(content), GetTestName());
}
[Test]
@@ -359,10 +359,10 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.UpdateOne<T, string>(document, x => x.SomeContent, content);
// Assert
Assert.IsTrue(result, GetTestName());
ClassicAssert.IsTrue(result, GetTestName());
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument, GetTestName());
Assert.AreEqual(content, updatedDocument.SomeContent, GetTestName());
ClassicAssert.IsNotNull(updatedDocument, GetTestName());
Assert.That(updatedDocument.SomeContent, Is.EqualTo(content), GetTestName());
}
[Test]
@@ -375,10 +375,10 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.UpdateOneAsync<T, string>(document, x => x.SomeContent, content);
// Assert
Assert.IsTrue(result, GetTestName());
ClassicAssert.IsTrue(result, GetTestName());
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument, GetTestName());
Assert.AreEqual(content, updatedDocument.SomeContent, GetTestName());
ClassicAssert.IsNotNull(updatedDocument, GetTestName());
Assert.That(updatedDocument.SomeContent, Is.EqualTo(content), GetTestName());
}
[Test]
@@ -391,10 +391,10 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.UpdateOne<T, string>(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.IsTrue(result, GetTestName());
ClassicAssert.IsTrue(result, GetTestName());
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument, GetTestName());
Assert.AreEqual(content, updatedDocument.SomeContent, GetTestName());
ClassicAssert.IsNotNull(updatedDocument, GetTestName());
Assert.That(updatedDocument.SomeContent, Is.EqualTo(content), GetTestName());
}
[Test]
@@ -407,10 +407,10 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.UpdateOneAsync<T, string>(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.IsTrue(result, GetTestName());
ClassicAssert.IsTrue(result, GetTestName());
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument, GetTestName());
Assert.AreEqual(content, updatedDocument.SomeContent, GetTestName());
ClassicAssert.IsNotNull(updatedDocument, GetTestName());
Assert.That(updatedDocument.SomeContent, Is.EqualTo(content), GetTestName());
}
[Test]
@@ -430,13 +430,13 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.UpdateOneAsync<T>(document, updateDef);
// Assert
Assert.IsTrue(result);
ClassicAssert.IsTrue(result);
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument);
Assert.AreEqual(childrenToAdd[0].Type, updatedDocument.Children[0].Type, GetTestName());
Assert.AreEqual(childrenToAdd[0].Value, updatedDocument.Children[0].Value, GetTestName());
Assert.AreEqual(childrenToAdd[1].Type, updatedDocument.Children[1].Type, GetTestName());
Assert.AreEqual(childrenToAdd[1].Value, updatedDocument.Children[1].Value, GetTestName());
ClassicAssert.IsNotNull(updatedDocument);
Assert.That(updatedDocument.Children[0].Type, Is.EqualTo(childrenToAdd[0].Type), GetTestName());
Assert.That(updatedDocument.Children[0].Value, Is.EqualTo(childrenToAdd[0].Value), GetTestName());
Assert.That(updatedDocument.Children[1].Type, Is.EqualTo(childrenToAdd[1].Type), GetTestName());
Assert.That(updatedDocument.Children[1].Value, Is.EqualTo(childrenToAdd[1].Value), GetTestName());
}
[Test]
@@ -456,13 +456,13 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.UpdateOne<T>(document, updateDef);
// Assert
Assert.IsTrue(result);
ClassicAssert.IsTrue(result);
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument);
Assert.AreEqual(childrenToAdd[0].Type, updatedDocument.Children[0].Type, GetTestName());
Assert.AreEqual(childrenToAdd[0].Value, updatedDocument.Children[0].Value, GetTestName());
Assert.AreEqual(childrenToAdd[1].Type, updatedDocument.Children[1].Type, GetTestName());
Assert.AreEqual(childrenToAdd[1].Value, updatedDocument.Children[1].Value, GetTestName());
ClassicAssert.IsNotNull(updatedDocument);
Assert.That(updatedDocument.Children[0].Type, Is.EqualTo(childrenToAdd[0].Type), GetTestName());
Assert.That(updatedDocument.Children[0].Value, Is.EqualTo(childrenToAdd[0].Value), GetTestName());
Assert.That(updatedDocument.Children[1].Type, Is.EqualTo(childrenToAdd[1].Type), GetTestName());
Assert.That(updatedDocument.Children[1].Value, Is.EqualTo(childrenToAdd[1].Value), GetTestName());
}
#endregion Update
@@ -478,8 +478,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.DeleteOne<T>(document);
// Assert
Assert.AreEqual(1, result);
Assert.IsFalse(SUT.Any<T>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(1));
ClassicAssert.IsFalse(SUT.Any<T>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
}
[Test]
@@ -491,8 +491,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.DeleteOne<T>(e => e.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.AreEqual(1, result);
Assert.IsFalse(SUT.Any<T>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(1));
ClassicAssert.IsFalse(SUT.Any<T>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
}
[Test]
@@ -504,8 +504,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.DeleteOneAsync<T>(document);
// Assert
Assert.AreEqual(1, result);
Assert.IsFalse(SUT.Any<T>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(1));
ClassicAssert.IsFalse(SUT.Any<T>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
}
[Test]
@@ -517,8 +517,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.DeleteOneAsync<T>(e => e.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.AreEqual(1, result);
Assert.IsFalse(SUT.Any<T>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(1));
ClassicAssert.IsFalse(SUT.Any<T>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
}
[Test]
@@ -532,8 +532,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.DeleteManyAsync<T>(e => e.SomeContent == criteria, PartitionKey);
// Assert
Assert.AreEqual(5, result);
Assert.IsFalse(SUT.Any<T>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(5));
ClassicAssert.IsFalse(SUT.Any<T>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
}
[Test]
@@ -547,8 +547,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.DeleteManyAsync<T>(documents);
// Assert
Assert.AreEqual(5, result);
Assert.IsFalse(SUT.Any<T>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(5));
ClassicAssert.IsFalse(SUT.Any<T>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
}
[Test]
@@ -562,8 +562,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.DeleteMany<T>(e => e.SomeContent == criteria, PartitionKey);
// Assert
Assert.AreEqual(5, result);
Assert.IsFalse(SUT.Any<T>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(5));
ClassicAssert.IsFalse(SUT.Any<T>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
}
[Test]
@@ -577,8 +577,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.DeleteMany<T>(documents);
// Assert
Assert.AreEqual(5, result);
Assert.IsFalse(SUT.Any<T>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(5));
ClassicAssert.IsFalse(SUT.Any<T>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
}
#endregion Delete
@@ -605,10 +605,10 @@ namespace IntegrationTests.Infrastructure
},
PartitionKey);
// Assert
Assert.IsNotNull(result, GetTestName());
Assert.AreEqual(someContent, result.SomeContent, GetTestName());
Assert.AreEqual(someDate.Minute, result.SomeDate.Minute, GetTestName());
Assert.AreEqual(someDate.Second, result.SomeDate.Second, GetTestName());
ClassicAssert.IsNotNull(result, GetTestName());
Assert.That(result.SomeContent, Is.EqualTo(someContent), GetTestName());
Assert.That(result.SomeDate.Minute, Is.EqualTo(someDate.Minute), GetTestName());
Assert.That(result.SomeDate.Second, Is.EqualTo(someDate.Second), GetTestName());
}
[Test]
@@ -631,10 +631,10 @@ namespace IntegrationTests.Infrastructure
},
PartitionKey);
// Assert
Assert.IsNotNull(result, GetTestName());
Assert.AreEqual(someContent, result.SomeContent, GetTestName());
Assert.AreEqual(someDate.Minute, result.SomeDate.Minute, GetTestName());
Assert.AreEqual(someDate.Second, result.SomeDate.Second, GetTestName());
ClassicAssert.IsNotNull(result, GetTestName());
Assert.That(result.SomeContent, Is.EqualTo(someContent), GetTestName());
Assert.That(result.SomeDate.Minute, Is.EqualTo(someDate.Minute), GetTestName());
Assert.That(result.SomeDate.Second, Is.EqualTo(someDate.Second), GetTestName());
}
[Test]
@@ -661,10 +661,10 @@ namespace IntegrationTests.Infrastructure
},
PartitionKey);
// Assert
Assert.AreEqual(5, result.Count, GetTestName());
Assert.AreEqual(someContent, result.First().SomeContent, GetTestName());
Assert.AreEqual(someDate.Minute, result.First().SomeDate.Minute, GetTestName());
Assert.AreEqual(someDate.Second, result.First().SomeDate.Second, GetTestName());
Assert.That(result.Count, Is.EqualTo(5), GetTestName());
Assert.That(result.First().SomeContent, Is.EqualTo(someContent), GetTestName());
Assert.That(result.First().SomeDate.Minute, Is.EqualTo(someDate.Minute), GetTestName());
Assert.That(result.First().SomeDate.Second, Is.EqualTo(someDate.Second), GetTestName());
}
[Test]
@@ -691,10 +691,10 @@ namespace IntegrationTests.Infrastructure
},
PartitionKey);
// Assert
Assert.AreEqual(5, result.Count, GetTestName());
Assert.AreEqual(someContent, result.First().SomeContent, GetTestName());
Assert.AreEqual(someDate.Minute, result.First().SomeDate.Minute, GetTestName());
Assert.AreEqual(someDate.Second, result.First().SomeDate.Second, GetTestName());
Assert.That(result.Count, Is.EqualTo(5), GetTestName());
Assert.That(result.First().SomeContent, Is.EqualTo(someContent), GetTestName());
Assert.That(result.First().SomeDate.Minute, Is.EqualTo(someDate.Minute), GetTestName());
Assert.That(result.First().SomeDate.Second, Is.EqualTo(someDate.Second), GetTestName());
}
#endregion Project
@@ -730,11 +730,11 @@ namespace IntegrationTests.Infrastructure
// Assert
var key1Group = result.First(e => e.Key == 1);
Assert.NotNull(key1Group);
Assert.AreEqual(3, key1Group.Content.Count);
ClassicAssert.NotNull(key1Group);
Assert.That(key1Group.Content.Count, Is.EqualTo(3));
var key2Group = result.First(e => e.Key == 2);
Assert.NotNull(key2Group);
Assert.AreEqual(2, key2Group.Content.Count);
ClassicAssert.NotNull(key2Group);
Assert.That(key2Group.Content.Count, Is.EqualTo(2));
}
[Test]
@@ -775,11 +775,11 @@ namespace IntegrationTests.Infrastructure
// Assert
var key1Group = result.First(e => e.Key == 4);
Assert.NotNull(key1Group);
Assert.AreEqual(3, key1Group.Content.Count);
ClassicAssert.NotNull(key1Group);
Assert.That(key1Group.Content.Count, Is.EqualTo(3));
var key2Group = result.First(e => e.Key == 5);
Assert.NotNull(key2Group);
Assert.AreEqual(1, key2Group.Content.Count);
ClassicAssert.NotNull(key2Group);
Assert.That(key2Group.Content.Count, Is.EqualTo(1));
}
#endregion Group By
@@ -7,6 +7,7 @@ using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using NUnit.Framework.Legacy;
namespace IntegrationTests.Infrastructure
{
@@ -66,8 +67,7 @@ namespace IntegrationTests.Infrastructure
[OneTimeSetUp]
public void Init()
{
var connectionString = ConfigurationManager.ConnectionStrings["MongoDbTests"].ConnectionString;
SUT = new TestRepository(connectionString, "MongoDbTests");
SUT = new TestRepository("mongodb://test:Test123!@10.0.3.4:27017", "MongoDbTests");
}
[OneTimeTearDown]
@@ -96,7 +96,7 @@ namespace IntegrationTests.Infrastructure
// Assert
long count = string.IsNullOrEmpty(PartitionKey) ? SUT.Count<T, TKey>(e => e.Id.Equals(document.Id))
: SUT.Count<T, TKey>(e => e.Id.Equals(document.Id), PartitionKey);
Assert.AreEqual(1, count, GetTestName());
Assert.That(count, Is.EqualTo(1), GetTestName());
}
[Test]
@@ -109,7 +109,7 @@ namespace IntegrationTests.Infrastructure
// Assert
long count = string.IsNullOrEmpty(PartitionKey) ? SUT.Count<T, TKey>(e => e.Id.Equals(document.Id))
: SUT.Count<T, TKey>(e => e.Id.Equals(document.Id), PartitionKey);
Assert.AreEqual(1, count, GetTestName());
Assert.That(count, Is.EqualTo(1), GetTestName());
}
[Test]
@@ -124,7 +124,7 @@ namespace IntegrationTests.Infrastructure
|| e.Id.Equals(documents[1].Id))
: SUT.Count<T, TKey>(e => e.Id.Equals(documents[0].Id)
|| e.Id.Equals(documents[1].Id), PartitionKey);
Assert.AreEqual(2, count, GetTestName());
Assert.That(count, Is.EqualTo(2), GetTestName());
}
[Test]
@@ -139,7 +139,7 @@ namespace IntegrationTests.Infrastructure
|| e.Id.Equals(documents[1].Id))
: SUT.Count<T, TKey>(e => e.Id.Equals(documents[0].Id)
|| e.Id.Equals(documents[1].Id), PartitionKey);
Assert.AreEqual(2, count, GetTestName());
Assert.That(count, Is.EqualTo(2), GetTestName());
}
@@ -156,7 +156,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.GetByIdAsync<T, TKey>(document.Id, PartitionKey);
// Assert
Assert.IsNotNull(result, GetTestName());
ClassicAssert.IsNotNull(result, GetTestName());
}
[Test]
@@ -168,7 +168,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.GetById<T, TKey>(document.Id, PartitionKey);
// Assert
Assert.IsNotNull(result, GetTestName());
ClassicAssert.IsNotNull(result, GetTestName());
}
[Test]
@@ -180,7 +180,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.GetOneAsync<T, TKey>(x => x.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.IsNotNull(result, GetTestName());
ClassicAssert.IsNotNull(result, GetTestName());
}
[Test]
@@ -192,7 +192,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.GetOne<T, TKey>(x => x.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.IsNotNull(result, GetTestName());
ClassicAssert.IsNotNull(result, GetTestName());
}
[Test]
@@ -205,7 +205,7 @@ namespace IntegrationTests.Infrastructure
var cursor = SUT.GetCursor<T, TKey>(x => x.Id.Equals(document.Id), PartitionKey);
var count = cursor.CountDocuments();
// Assert
Assert.AreEqual(1, count, GetTestName());
Assert.That(count, Is.EqualTo(1), GetTestName());
}
[Test]
@@ -217,7 +217,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.AnyAsync<T, TKey>(x => x.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.AreEqual(true, result, GetTestName());
Assert.That(result, Is.EqualTo(true), GetTestName());
}
[Test]
@@ -229,7 +229,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.AnyAsync<T, TKey>(x => x.Id.Equals(document.Init<TKey>()), PartitionKey);
// Assert
Assert.AreEqual(false, result, GetTestName());
Assert.That(result, Is.EqualTo(false), GetTestName());
}
[Test]
@@ -241,7 +241,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.Any<T, TKey>(x => x.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.AreEqual(true, result, GetTestName());
Assert.That(result, Is.EqualTo(true), GetTestName());
}
[Test]
@@ -253,7 +253,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.Any<T, TKey>(x => x.Id.Equals(document.Init<TKey>()), PartitionKey);
// Assert
Assert.AreEqual(false, result, GetTestName());
Assert.That(result, Is.EqualTo(false), GetTestName());
}
[Test]
@@ -267,7 +267,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.GetAllAsync<T, TKey>(x => x.SomeContent == content, PartitionKey);
// Assert
Assert.AreEqual(5, result.Count, GetTestName());
Assert.That(result.Count, Is.EqualTo(5), GetTestName());
}
[Test]
@@ -281,7 +281,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.GetAll<T, TKey>(x => x.SomeContent == content, PartitionKey);
// Assert
Assert.AreEqual(5, result.Count, GetTestName());
Assert.That(result.Count, Is.EqualTo(5), GetTestName());
}
[Test]
@@ -295,7 +295,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.CountAsync<T, TKey>(x => x.SomeContent == content, PartitionKey);
// Assert
Assert.AreEqual(5, result, GetTestName());
Assert.That(result, Is.EqualTo(5), GetTestName());
}
[Test]
@@ -309,7 +309,7 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.Count<T, TKey>(x => x.SomeContent == content, PartitionKey);
// Assert
Assert.AreEqual(5, result, GetTestName());
Assert.That(result, Is.EqualTo(5), GetTestName());
}
#endregion Read
@@ -327,10 +327,10 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.UpdateOne<T, TKey>(document);
// Assert
Assert.IsTrue(result);
Assert.That(result, Is.True);
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument, GetTestName());
Assert.AreEqual(content, updatedDocument.SomeContent, GetTestName());
ClassicAssert.IsNotNull(updatedDocument, GetTestName());
Assert.That(updatedDocument.SomeContent, Is.EqualTo(content), GetTestName());
}
[Test]
@@ -344,10 +344,10 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.UpdateOneAsync<T, TKey>(document);
// Assert
Assert.IsTrue(result);
Assert.That(result, Is.True);
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument, GetTestName());
Assert.AreEqual(content, updatedDocument.SomeContent, GetTestName());
ClassicAssert.IsNotNull(updatedDocument, GetTestName());
Assert.That(updatedDocument.SomeContent, Is.EqualTo(content), GetTestName());
}
[Test]
@@ -360,10 +360,10 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.UpdateOne<T, TKey, string>(document, x => x.SomeContent, content);
// Assert
Assert.IsTrue(result, GetTestName());
ClassicAssert.IsTrue(result, GetTestName());
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument, GetTestName());
Assert.AreEqual(content, updatedDocument.SomeContent, GetTestName());
ClassicAssert.IsNotNull(updatedDocument, GetTestName());
Assert.That(updatedDocument.SomeContent, Is.EqualTo(content), GetTestName());
}
[Test]
@@ -376,10 +376,10 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.UpdateOneAsync<T, TKey, string>(document, x => x.SomeContent, content);
// Assert
Assert.IsTrue(result, GetTestName());
ClassicAssert.IsTrue(result, GetTestName());
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument, GetTestName());
Assert.AreEqual(content, updatedDocument.SomeContent, GetTestName());
ClassicAssert.IsNotNull(updatedDocument, GetTestName());
Assert.That(updatedDocument.SomeContent, Is.EqualTo(content), GetTestName());
}
[Test]
@@ -392,10 +392,10 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.UpdateOne<T, TKey, string>(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.IsTrue(result, GetTestName());
ClassicAssert.IsTrue(result, GetTestName());
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument, GetTestName());
Assert.AreEqual(content, updatedDocument.SomeContent, GetTestName());
ClassicAssert.IsNotNull(updatedDocument, GetTestName());
Assert.That(updatedDocument.SomeContent, Is.EqualTo(content), GetTestName());
}
[Test]
@@ -408,10 +408,10 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.UpdateOneAsync<T, TKey, string>(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.IsTrue(result, GetTestName());
ClassicAssert.IsTrue(result, GetTestName());
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument, GetTestName());
Assert.AreEqual(content, updatedDocument.SomeContent, GetTestName());
ClassicAssert.IsNotNull(updatedDocument, GetTestName());
Assert.That(updatedDocument.SomeContent, Is.EqualTo(content), GetTestName());
}
[Test]
@@ -431,13 +431,13 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.UpdateOneAsync<T, TKey>(document, updateDef);
// Assert
Assert.IsTrue(result);
ClassicAssert.IsTrue(result);
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument);
Assert.AreEqual(childrenToAdd[0].Type, updatedDocument.Children[0].Type, GetTestName());
Assert.AreEqual(childrenToAdd[0].Value, updatedDocument.Children[0].Value, GetTestName());
Assert.AreEqual(childrenToAdd[1].Type, updatedDocument.Children[1].Type, GetTestName());
Assert.AreEqual(childrenToAdd[1].Value, updatedDocument.Children[1].Value, GetTestName());
ClassicAssert.IsNotNull(updatedDocument);
Assert.That(updatedDocument.Children[0].Type, Is.EqualTo(childrenToAdd[0].Type), GetTestName());
Assert.That(updatedDocument.Children[0].Value, Is.EqualTo(childrenToAdd[0].Value), GetTestName());
Assert.That(updatedDocument.Children[1].Type, Is.EqualTo(childrenToAdd[1].Type), GetTestName());
Assert.That(updatedDocument.Children[1].Value, Is.EqualTo(childrenToAdd[1].Value), GetTestName());
}
[Test]
@@ -457,13 +457,13 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.UpdateOne<T, TKey>(document, updateDef);
// Assert
Assert.IsTrue(result);
ClassicAssert.IsTrue(result);
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.IsNotNull(updatedDocument);
Assert.AreEqual(childrenToAdd[0].Type, updatedDocument.Children[0].Type, GetTestName());
Assert.AreEqual(childrenToAdd[0].Value, updatedDocument.Children[0].Value, GetTestName());
Assert.AreEqual(childrenToAdd[1].Type, updatedDocument.Children[1].Type, GetTestName());
Assert.AreEqual(childrenToAdd[1].Value, updatedDocument.Children[1].Value, GetTestName());
ClassicAssert.IsNotNull(updatedDocument);
Assert.That(updatedDocument.Children[0].Type, Is.EqualTo(childrenToAdd[0].Type), GetTestName());
Assert.That(updatedDocument.Children[0].Value, Is.EqualTo(childrenToAdd[0].Value), GetTestName());
Assert.That(updatedDocument.Children[1].Type, Is.EqualTo(childrenToAdd[1].Type), GetTestName());
Assert.That(updatedDocument.Children[1].Value, Is.EqualTo(childrenToAdd[1].Value), GetTestName());
}
#endregion Update
@@ -479,8 +479,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.DeleteOne<T, TKey>(document);
// Assert
Assert.AreEqual(1, result);
Assert.IsFalse(SUT.Any<T, TKey>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(1));
ClassicAssert.IsFalse(SUT.Any<T, TKey>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
}
[Test]
@@ -492,8 +492,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.DeleteOne<T, TKey>(e => e.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.AreEqual(1, result);
Assert.IsFalse(SUT.Any<T, TKey>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(1));
ClassicAssert.IsFalse(SUT.Any<T, TKey>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
}
[Test]
@@ -505,8 +505,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.DeleteOneAsync<T, TKey>(document);
// Assert
Assert.AreEqual(1, result);
Assert.IsFalse(SUT.Any<T, TKey>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(1));
ClassicAssert.IsFalse(SUT.Any<T, TKey>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
}
[Test]
@@ -518,8 +518,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.DeleteOneAsync<T, TKey>(e => e.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.AreEqual(1, result);
Assert.IsFalse(SUT.Any<T, TKey>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(1));
ClassicAssert.IsFalse(SUT.Any<T, TKey>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
}
[Test]
@@ -533,8 +533,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.DeleteManyAsync<T, TKey>(e => e.SomeContent == criteria, PartitionKey);
// Assert
Assert.AreEqual(5, result);
Assert.IsFalse(SUT.Any<T, TKey>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(5));
ClassicAssert.IsFalse(SUT.Any<T, TKey>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
}
[Test]
@@ -548,8 +548,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = await SUT.DeleteManyAsync<T, TKey>(documents);
// Assert
Assert.AreEqual(5, result);
Assert.IsFalse(SUT.Any<T, TKey>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(5));
ClassicAssert.IsFalse(SUT.Any<T, TKey>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
}
[Test]
@@ -563,8 +563,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.DeleteMany<T, TKey>(e => e.SomeContent == criteria, PartitionKey);
// Assert
Assert.AreEqual(5, result);
Assert.IsFalse(SUT.Any<T, TKey>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(5));
ClassicAssert.IsFalse(SUT.Any<T, TKey>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
}
[Test]
@@ -578,8 +578,8 @@ namespace IntegrationTests.Infrastructure
// Act
var result = SUT.DeleteMany<T, TKey>(documents);
// Assert
Assert.AreEqual(5, result);
Assert.IsFalse(SUT.Any<T, TKey>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
Assert.That(result, Is.EqualTo(5));
ClassicAssert.IsFalse(SUT.Any<T, TKey>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
}
#endregion Delete
@@ -606,10 +606,10 @@ namespace IntegrationTests.Infrastructure
},
PartitionKey);
// Assert
Assert.IsNotNull(result, GetTestName());
Assert.AreEqual(someContent, result.SomeContent, GetTestName());
Assert.AreEqual(someDate.Minute, result.SomeDate.Minute, GetTestName());
Assert.AreEqual(someDate.Second, result.SomeDate.Second, GetTestName());
ClassicAssert.IsNotNull(result, GetTestName());
Assert.That(result.SomeContent, Is.EqualTo(someContent), GetTestName());
Assert.That(result.SomeDate.Minute, Is.EqualTo(someDate.Minute), GetTestName());
Assert.That(result.SomeDate.Second, Is.EqualTo(someDate.Second), GetTestName());
}
[Test]
@@ -632,10 +632,10 @@ namespace IntegrationTests.Infrastructure
},
PartitionKey);
// Assert
Assert.IsNotNull(result, GetTestName());
Assert.AreEqual(someContent, result.SomeContent, GetTestName());
Assert.AreEqual(someDate.Minute, result.SomeDate.Minute, GetTestName());
Assert.AreEqual(someDate.Second, result.SomeDate.Second, GetTestName());
ClassicAssert.IsNotNull(result, GetTestName());
Assert.That(result.SomeContent, Is.EqualTo(someContent), GetTestName());
Assert.That(result.SomeDate.Minute, Is.EqualTo(someDate.Minute), GetTestName());
Assert.That(result.SomeDate.Second, Is.EqualTo(someDate.Second), GetTestName());
}
[Test]
@@ -662,10 +662,10 @@ namespace IntegrationTests.Infrastructure
},
PartitionKey);
// Assert
Assert.AreEqual(5, result.Count, GetTestName());
Assert.AreEqual(someContent, result.First().SomeContent, GetTestName());
Assert.AreEqual(someDate.Minute, result.First().SomeDate.Minute, GetTestName());
Assert.AreEqual(someDate.Second, result.First().SomeDate.Second, GetTestName());
Assert.That(result.Count, Is.EqualTo(5), GetTestName());
Assert.That(result.First().SomeContent, Is.EqualTo(someContent), GetTestName());
Assert.That(result.First().SomeDate.Minute, Is.EqualTo(someDate.Minute), GetTestName());
Assert.That(result.First().SomeDate.Second, Is.EqualTo(someDate.Second), GetTestName());
}
[Test]
@@ -692,10 +692,10 @@ namespace IntegrationTests.Infrastructure
},
PartitionKey);
// Assert
Assert.AreEqual(5, result.Count, GetTestName());
Assert.AreEqual(someContent, result.First().SomeContent, GetTestName());
Assert.AreEqual(someDate.Minute, result.First().SomeDate.Minute, GetTestName());
Assert.AreEqual(someDate.Second, result.First().SomeDate.Second, GetTestName());
Assert.That(result.Count, Is.EqualTo(5), GetTestName());
Assert.That(result.First().SomeContent, Is.EqualTo(someContent), GetTestName());
Assert.That(result.First().SomeDate.Minute, Is.EqualTo(someDate.Minute), GetTestName());
Assert.That(result.First().SomeDate.Second, Is.EqualTo(someDate.Second), GetTestName());
}
#endregion Project
@@ -23,20 +23,5 @@ namespace IntegrationTests.Infrastructure
{
MongoDbContext.DropCollection<TDocument>(partitionKey);
}
/// <summary>
/// Gets the max of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <returns></returns>
public async Task<TDocument> GetByMaxAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> orderByDescending)
where TDocument : IDocument<TKey>
where TKey : System.IEquatable<TKey>
{
return await GetCollection<TDocument, TKey>().Find(Builders<TDocument>.Filter.Where(filter))
.SortByDescending(orderByDescending)
.FirstOrDefaultAsync();
}
}
}
+36 -133
View File
@@ -1,146 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit3TestAdapter.4.0.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.4.0.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="..\packages\NUnit.3.13.2\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.13.2\build\NUnit.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A484A355-A015-40CC-9B35-A4E872421128}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IntegrationTests</RootNamespace>
<AssemblyName>IntegrationTests</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<Reference Include="Crc32C.NET, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Crc32C.NET.1.0.5.0\lib\net20\Crc32C.NET.dll</HintPath>
</Reference>
<Reference Include="DnsClient, Version=1.4.0.0, Culture=neutral, PublicKeyToken=4574bb5573c51424, processorArchitecture=MSIL">
<HintPath>..\packages\DnsClient.1.4.0\lib\net45\DnsClient.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Bson, Version=2.13.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Bson.2.13.2\lib\net452\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=2.13.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Driver.2.13.2\lib\net452\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver.Core, Version=2.13.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Driver.Core.2.13.2\lib\net452\MongoDB.Driver.Core.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Libmongocrypt, Version=1.2.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Libmongocrypt.1.2.2\lib\net452\MongoDB.Libmongocrypt.dll</HintPath>
</Reference>
<Reference Include="MongoDbGenericRepository, Version=1.4.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.4.8\lib\net452\MongoDbGenericRepository.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.13.2.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.13.2\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="SharpCompress, Version=0.23.0.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
<HintPath>..\packages\SharpCompress.0.23.0\lib\net45\SharpCompress.dll</HintPath>
</Reference>
<Reference Include="Snappy.NET, Version=1.1.1.8, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Snappy.NET.1.1.1.8\lib\net45\Snappy.NET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<PackageReference Include="AWSSDK.Core" Version="3.7.400.57" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Crc32.NET" Version="1.2.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MongoDB.Driver" Version="3.0.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.401.6" />
</ItemGroup>
<ItemGroup>
<Compile Include="CRUDObjectIdTests.cs" />
<Compile Include="CRUDPartitionedTests.cs" />
<Compile Include="CRUDTKeyPartitionedCollectionNameAttributeTests.cs" />
<Compile Include="CRUDTests.cs" />
<Compile Include="CRUDPartitionedCollectionNameAttributeTests.cs" />
<Compile Include="CRUDTKeyPartitionedTests.cs" />
<Compile Include="CRUDTKeyTests.cs" />
<Compile Include="Infrastructure\BaseMongoDbRepositoryTests.cs" />
<Compile Include="Infrastructure\GlobalVariables.cs" />
<Compile Include="Infrastructure\ITestRepository.cs" />
<Compile Include="Infrastructure\MongoDbDocumentTestBase.cs" />
<Compile Include="Infrastructure\MongoDbTKeyDocumentTestBase.cs" />
<Compile Include="Infrastructure\RandomExtensions.cs" />
<Compile Include="Infrastructure\TestClasses.cs" />
<Compile Include="Infrastructure\TestRepository.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Using Include="NUnit.Framework"/>
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<None Update="App.config">
<SubType>Designer</SubType>
</None>
<None Include="libmongocrypt.dylib" />
<None Include="libmongocrypt.so" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<ProjectReference Include="..\CoreIntegrationTests\CoreIntegrationTests.csproj" />
<ProjectReference Include="..\MongoDbGenericRepository\MongoDbGenericRepository.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="Core\Compression\Snappy\lib\win\snappy32.dll" />
<Content Include="Core\Compression\Snappy\lib\win\snappy64.dll" />
<Content Include="Core\Compression\Zstandard\lib\win\libzstd.dll" />
<Content Include="mongocrypt.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MongoDB.Libmongocrypt.1.2.2\build\MongoDB.Libmongocrypt.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MongoDB.Libmongocrypt.1.2.2\build\MongoDB.Libmongocrypt.targets'))" />
<Error Condition="!Exists('..\packages\NUnit.3.13.2\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.13.2\build\NUnit.props'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.4.0.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.4.0.0\build\net35\NUnit3TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MongoDB.Driver.Core.2.13.2\build\MongoDB.Driver.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MongoDB.Driver.Core.2.13.2\build\MongoDB.Driver.Core.targets'))" />
</Target>
<Import Project="..\packages\MongoDB.Libmongocrypt.1.2.2\build\MongoDB.Libmongocrypt.targets" Condition="Exists('..\packages\MongoDB.Libmongocrypt.1.2.2\build\MongoDB.Libmongocrypt.targets')" />
<Import Project="..\packages\MongoDB.Driver.Core.2.13.2\build\MongoDB.Driver.Core.targets" Condition="Exists('..\packages\MongoDB.Driver.Core.2.13.2\build\MongoDB.Driver.Core.targets')" />
</Project>
@@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("IntegrationTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IntegrationTests")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
[assembly: Guid("a484a355-a015-40cc-9b35-a4e872421128")]
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Binary file not shown.
Binary file not shown.
Binary file not shown.
-24
View File
@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Crc32C.NET" version="1.0.5.0" targetFramework="net461" />
<package id="DnsClient" version="1.4.0" targetFramework="net461" />
<package id="MongoDB.Bson" version="2.13.2" targetFramework="net461" />
<package id="MongoDB.Driver" version="2.13.2" targetFramework="net461" />
<package id="MongoDB.Driver.Core" version="2.13.2" targetFramework="net461" />
<package id="MongoDB.Libmongocrypt" version="1.2.2" targetFramework="net461" />
<package id="MongoDbGenericRepository" version="1.4.8" targetFramework="net461" />
<package id="NUnit" version="3.13.2" targetFramework="net461" />
<package id="NUnit.ConsoleRunner" version="3.12.0" targetFramework="net461" />
<package id="NUnit3TestAdapter" version="4.0.0" targetFramework="net461" />
<package id="SharpCompress" version="0.23.0" targetFramework="net461" />
<package id="Snappy.NET" version="1.1.1.8" targetFramework="net461" />
<package id="System.Buffers" version="4.5.1" targetFramework="net461" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net461" />
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net461" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net461" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net461" />
</packages>
+6 -6
View File
@@ -3,24 +3,20 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTests", "IntegrationTests\IntegrationTests.csproj", "{A484A355-A015-40CC-9B35-A4E872421128}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoDbGenericRepository", "MongoDbGenericRepository\MongoDbGenericRepository.csproj", "{EFC776C4-2AF3-440C-BE80-3FBE335817A5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreIntegrationTests", "CoreIntegrationTests\CoreIntegrationTests.csproj", "{C640C106-7A25-4E49-A0CF-E4F248E5A97F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreUnitTests", "CoreUnitTests\CoreUnitTests.csproj", "{8BE513ED-84F4-47E1-946D-84958CF95E6B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTests", "IntegrationTests\IntegrationTests.csproj", "{B3146094-8062-45C4-8FF9-4E1CBDDCAB59}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A484A355-A015-40CC-9B35-A4E872421128}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A484A355-A015-40CC-9B35-A4E872421128}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A484A355-A015-40CC-9B35-A4E872421128}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A484A355-A015-40CC-9B35-A4E872421128}.Release|Any CPU.Build.0 = Release|Any CPU
{EFC776C4-2AF3-440C-BE80-3FBE335817A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFC776C4-2AF3-440C-BE80-3FBE335817A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFC776C4-2AF3-440C-BE80-3FBE335817A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -33,6 +29,10 @@ Global
{8BE513ED-84F4-47E1-946D-84958CF95E6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BE513ED-84F4-47E1-946D-84958CF95E6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8BE513ED-84F4-47E1-946D-84958CF95E6B}.Release|Any CPU.Build.0 = Release|Any CPU
{B3146094-8062-45C4-8FF9-4E1CBDDCAB59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3146094-8062-45C4-8FF9-4E1CBDDCAB59}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3146094-8062-45C4-8FF9-4E1CBDDCAB59}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3146094-8062-45C4-8FF9-4E1CBDDCAB59}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -2,6 +2,7 @@
using MongoDB.Driver.Linq;
using MongoDbGenericRepository.Models;
using System;
using System.Linq;
using System.Linq.Expressions;
namespace MongoDbGenericRepository.DataAccess.Base
@@ -35,7 +36,7 @@ namespace MongoDbGenericRepository.DataAccess.Base
/// <param name="filter">The filter definition.</param>
/// <param name="partitionKey">The collection partition key.</param>
/// <returns></returns>
public virtual IMongoQueryable<TDocument> GetQuery<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
public virtual IQueryable<TDocument> GetQuery<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Linq.Expressions;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
@@ -19,7 +20,7 @@ namespace MongoDbGenericRepository.DataAccess.Base
/// <param name="filter">The filter definition.</param>
/// <param name="partitionKey">The collection partition key.</param>
/// <returns></returns>
IMongoQueryable<TDocument> GetQuery<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
IQueryable<TDocument> GetQuery<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
@@ -0,0 +1,59 @@
using System;
using System.Collections.Concurrent;
using MongoDB.Bson.Serialization;
namespace MongoDbGenericRepository.Internals
{
/// <summary>
/// An <see cref="IBsonSerializationProvider"/> that can handle multiple serializer registration calls.
/// </summary>
internal class RepositorySerializationProvider : IBsonSerializationProvider
{
private static volatile RepositorySerializationProvider _instance;
private static readonly object LockObject = new object();
private readonly ConcurrentDictionary<Type, IBsonSerializer> _cache;
private RepositorySerializationProvider()
{
_cache = new ConcurrentDictionary<Type, IBsonSerializer>();
}
public static RepositorySerializationProvider Instance
{
get
{
if (_instance == null)
{
lock (LockObject)
{
if (_instance == null)
{
_instance = new RepositorySerializationProvider();
BsonSerializer.RegisterSerializationProvider(_instance);
}
}
}
return _instance;
}
}
/// <inheritdoc />
public IBsonSerializer GetSerializer(Type type)
{
if (type == null)
{
throw new ArgumentNullException(nameof(type));
}
return _cache.TryGetValue(type, out var serializer) ? serializer : null;
}
internal void RegisterSerializer<T>(IBsonSerializer<T> serializer) =>
RegisterSerializer(typeof(T), serializer);
internal void RegisterSerializer(Type type, IBsonSerializer serializer) =>
_cache.TryAdd(type, serializer);
}
}
+10 -4
View File
@@ -3,6 +3,9 @@ using MongoDbGenericRepository.Attributes;
using MongoDbGenericRepository.Utils;
using System.Linq;
using System.Reflection;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Serializers;
using MongoDbGenericRepository.Internals;
namespace MongoDbGenericRepository
{
@@ -21,7 +24,6 @@ namespace MongoDbGenericRepository
/// </summary>
public IMongoDatabase Database { get; }
/// <summary>
/// The constructor of the MongoDbContext, it needs an object implementing <see cref="IMongoDatabase"/>.
/// </summary>
@@ -90,9 +92,13 @@ namespace MongoDbGenericRepository
/// Sets the Guid representation of the MongoDB Driver.
/// </summary>
/// <param name="guidRepresentation">The new value of the GuidRepresentation</param>
public virtual void SetGuidRepresentation(MongoDB.Bson.GuidRepresentation guidRepresentation)
public virtual void SetGuidRepresentation(GuidRepresentation guidRepresentation)
{
MongoDefaults.GuidRepresentation = guidRepresentation;
// GuidRepresentation and GuidRepresentationMode will be removed in the next major release of the MongoDB Driver.
// We can safely replace this with RepositorySerializationProvider.Instance.RegisterSerializer once we upgrade to the next major release.
#pragma warning disable CS0618
RepositorySerializationProvider.Instance.RegisterSerializer(new GuidSerializer(guidRepresentation));
#pragma warning restore CS0618
}
/// <summary>
@@ -114,7 +120,7 @@ namespace MongoDbGenericRepository
protected virtual void InitializeGuidRepresentation()
{
// by default, avoid legacy UUID representation: use Binary 0x04 subtype.
MongoDefaults.GuidRepresentation = MongoDB.Bson.GuidRepresentation.Standard;
SetGuidRepresentation(GuidRepresentation.Standard);
}
/// <summary>
@@ -1,10 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;netstandard2.0;</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>MongoDbGenericRepository</PackageId>
<PackageVersion>1.4.8</PackageVersion>
<Authors>Alexandre Spieser</Authors>
<PackageTitle>MongoDb Generic Repository</PackageTitle>
<Description>A generic repository implementation using the MongoDB C# Sharp 2.0 driver.</Description>
@@ -12,12 +10,13 @@
<PackageProjectUrl>http://www.opensource.org/licenses/mit-license.php</PackageProjectUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>Release notes are at https://github.com/alexandre-spieser/mongodb-generic-repository/releases </PackageReleaseNotes>
<Copyright>Copyright 2021 (c) Alexandre Spieser. All rights reserved.</Copyright>
<Copyright>Copyright 2023 (c) Alexandre Spieser. All rights reserved.</Copyright>
<PackageTags>MongoDb Repository Generic NoSql</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.4.8</Version>
<RepositoryUrl>https://github.com/alexandre-spieser/mongodb-generic-repository</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<PropertyGroup>
@@ -25,7 +24,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.15.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageReference Include="MongoDB.Driver" Version="3.0.0" />
</ItemGroup>
</Project>