public void UowDispatcherNoUow() { var uowAdapter = new FakeUowAdapter(); var storage = new MemoryStorage(); var context = Substitute.For <IDownstreamContext>(); var msg = new DispatchEvent(new FakeEvent()); var handler = new TransactionalHandler(uowAdapter, storage); handler.HandleDownstream(context, msg); context.Received().SendDownstream(msg); }
public void UowDispatcher_UowNotReleased() { var uowAdapter = new FakeUowAdapter(); var storage = Substitute.For <IDomainEventStorage>(); var context = Substitute.For <IDownstreamContext>(); var msg = new DispatchEvent(new FakeEvent()); var uowMapper = new ThreadBatchIdMapper(); var handler = new TransactionalHandler(uowAdapter, storage, uowMapper); uowAdapter.Observer.Create(uowAdapter); handler.HandleDownstream(context, msg); storage.Received().Hold(uowMapper.GetBatchId(), msg.DomainEvent); }
public void UowDispatcher_UowReleasedFailed() { var uowAdapter = new FakeUowAdapter(); var storage = Substitute.For <IDomainEventStorage>(); var context = Substitute.For <IDownstreamContext>(); var msg = new DispatchEvent(new FakeEvent()); var uowMapper = new ThreadBatchIdMapper(); var handler = new TransactionalHandler(uowAdapter, storage, uowMapper); uowAdapter.Observer.Create(uowAdapter); var batchId = uowMapper.GetBatchId(); storage.Release(batchId).Returns(new[] { new FakeEvent() }); handler.HandleDownstream(context, msg); context.DidNotReceive().SendDownstream(msg); uowAdapter.Observer.Released(uowAdapter, false); storage.Received().Hold(batchId, msg.DomainEvent); storage.Received().Delete(batchId); context.DidNotReceive().SendDownstream(Arg.Any <DispatchEvent>()); }