-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfixes for heartbeats using MongoDB (#5337)
* Added failing unit test * Added fix for error 'Instance property 'Id' is not defined for type 'Elsa.KeyValues.Entities.SerializedKeyValuePair' (Parameter 'propertyName')' * Added Bson class map for SerializedKeyValuePair. Ignoring _id field mapping. --------- Co-authored-by: Stephan Melzer <s.melzer@mera-petfood.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
- Loading branch information
1 parent
33178f4
commit 016fa22
Showing
6 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
test/unit/Elsa.MongoDb.UnitTests/Elsa.MongoDb.UnitTests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="NSubstitute"/> | ||
</ItemGroup> | ||
|
||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\src\modules\Elsa.MongoDb\Elsa.MongoDb.csproj" /> | ||
</ItemGroup> | ||
</Project> |
36 changes: 36 additions & 0 deletions
36
test/unit/Elsa.MongoDb.UnitTests/MongoKeyValueStoreTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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>>(); | ||
mongoCollectionMock.FindOneAndReplaceAsync( | ||
Arg.Any<FilterDefinition<SerializedKeyValuePair>>(), | ||
Arg.Any<SerializedKeyValuePair>(), | ||
Arg.Any<FindOneAndReplaceOptions<SerializedKeyValuePair>>() | ||
) | ||
.Returns(new SerializedKeyValuePair()); | ||
_mongoDbStore = new MongoDbStore<SerializedKeyValuePair>(mongoCollectionMock); | ||
} | ||
|
||
[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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Xunit; |