public async Task SagaStore_FindAsyncWhenSagaHasPendingCommandPutThemToBus() { var options = PopulateContext(); using (var context = new InfrastructureContext(options)) { var mockBus = new Mock <ICommandBus>(); var stubSagaSerializer = new Mock <ISagaSerializer>(); stubSagaSerializer.Setup(s => s.Deserialize <FakeSaga>(It.IsAny <byte[]>())) .Returns <byte[]>((v) => { var payload = Encoding.UTF8.GetString(v); return(JsonConvert.DeserializeObject <FakeSaga>( payload, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All })); }); var sut = new SagaStore(mockBus.Object, stubSagaSerializer.Object, context); await sut.FindAsync <FakeSaga>(ToGuid(2)); mockBus.Verify(s => s.SendCommandAsync <Command>(It.IsAny <FakeCommand>())); } }
public async Task SagaStore_FindAsyncWhenSagaIsCompletedReturnsNull() { var options = PopulateContext(); using (var context = new InfrastructureContext(options)) { var stubSagaSerializer = new Mock <ISagaSerializer>(); stubSagaSerializer.Setup(s => s.Deserialize <FakeSaga>(It.IsAny <byte[]>())) .Returns <byte[]>((v) => { var payload = Encoding.UTF8.GetString(v); return(JsonConvert.DeserializeObject <FakeSaga>( payload, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All })); }); var sut = new SagaStore(Mock.Of <ICommandBus>(), stubSagaSerializer.Object, context); var saga = await sut.FindAsync <FakeSaga>(ToGuid(3)); Assert.Null(saga); } }