|
|
@@ -7,6 +7,7 @@ using System.Threading.Tasks; |
|
|
|
using Xunit; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Moq; |
|
|
|
using System.Threading; |
|
|
|
|
|
|
|
namespace Cap.Consistency.Test |
|
|
|
{ |
|
|
@@ -49,5 +50,26 @@ namespace Cap.Consistency.Test |
|
|
|
: base(new Mock<IConsistencyMessageStore<TestConsistencyMessage>>().Object, null, null) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task CreateCallsStore() { |
|
|
|
var store = new Mock<IConsistencyMessageStore<TestConsistencyMessage>>(); |
|
|
|
var message = new TestConsistencyMessage { Time = DateTime.Now }; |
|
|
|
store.Setup(x => x.CreateAsync(message, CancellationToken.None)).ReturnsAsync(OperateResult.Success).Verifiable(); |
|
|
|
var messageManager = TestConsistencyMessageManager(store.Object); |
|
|
|
|
|
|
|
var result = await messageManager.CreateAsync(message); |
|
|
|
|
|
|
|
Assert.True(result.Succeeded); |
|
|
|
store.VerifyAll(); |
|
|
|
} |
|
|
|
|
|
|
|
public ConsistencyMessageManager<TMessage> TestConsistencyMessageManager<TMessage>(IConsistencyMessageStore<TMessage> store = null) |
|
|
|
where TMessage : class { |
|
|
|
store = store ?? new Mock<IConsistencyMessageStore<TMessage>>().Object; |
|
|
|
var mockLogger = new Mock<ILogger<ConsistencyMessageManager<TMessage>>>().Object; |
|
|
|
var manager = new ConsistencyMessageManager<TMessage>(store, null, mockLogger); |
|
|
|
return manager; |
|
|
|
} |
|
|
|
} |
|
|
|
} |