Add project files.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa.MongoDb\Elsa.MongoDb.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,38 @@
|
||||
using Elsa.Common.Multitenancy;
|
||||
using Elsa.KeyValues.Entities;
|
||||
using Elsa.MongoDb.Common;
|
||||
using Elsa.MongoDb.Modules.Runtime;
|
||||
using MongoDB.Driver;
|
||||
using NSubstitute;
|
||||
|
||||
namespace Elsa.MongoDb.UnitTests;
|
||||
|
||||
public class MongoKeyValueStoreTests
|
||||
{
|
||||
private readonly MongoDbStore<SerializedKeyValuePair> _mongoDbStore;
|
||||
|
||||
public MongoKeyValueStoreTests()
|
||||
{
|
||||
var mongoCollectionMock = Substitute.For<IMongoCollection<SerializedKeyValuePair>>();
|
||||
var tenantAccessorMock = Substitute.For<ITenantAccessor>();
|
||||
mongoCollectionMock.FindOneAndReplaceAsync(
|
||||
Arg.Any<FilterDefinition<SerializedKeyValuePair>>(),
|
||||
Arg.Any<SerializedKeyValuePair>(),
|
||||
Arg.Any<FindOneAndReplaceOptions<SerializedKeyValuePair>>()
|
||||
)
|
||||
.Returns(new SerializedKeyValuePair());
|
||||
_mongoDbStore = new MongoDbStore<SerializedKeyValuePair>(mongoCollectionMock, tenantAccessorMock);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "When saving a SerializedKeyValuePair document, don't throw an exception of missing ID property")]
|
||||
public async Task SaveAsync_WithSerializedKeyValuePairDocument_DoesNotThrowException()
|
||||
{
|
||||
var mongoKeyValueStore = new MongoKeyValueStore(_mongoDbStore);
|
||||
var keyValuePair = new SerializedKeyValuePair();
|
||||
|
||||
var exception = await Record.ExceptionAsync(
|
||||
async () => await mongoKeyValueStore.SaveAsync(keyValuePair, default));
|
||||
|
||||
Assert.Null(exception);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
global using Xunit;
|
||||
Reference in New Issue
Block a user