* 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>
36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
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);
|
|
}
|
|
} |