コード例 #1
0
            public void PublishCommandsOnSuccessfulSave()
            {
                SagaStore.Setup(mock => mock.CreateSaga(typeof(FakeSaga), SagaId)).Returns(new FakeSaga());

                SagaEventHandler.Handle(EventContext);

                CommandPublisher.Verify(mock => mock.Publish(HeaderCollection.Empty, It.IsAny <CommandEnvelope>()), Times.Once());
            }
コード例 #2
0
            public void CommandsNotPublishedOnFailedSave()
            {
                var saga = new FakeSaga();

                SagaStore.Setup(mock => mock.CreateSaga(typeof(FakeSaga), SagaId)).Returns(saga);
                SagaStore.Setup(mock => mock.Save(saga, It.IsAny <SagaContext>())).Throws(new Exception());

                Assert.Throws <Exception>(() => SagaEventHandler.Handle(EventContext));

                CommandPublisher.Verify(mock => mock.Publish(HeaderCollection.Empty, It.IsAny <CommandEnvelope>()), Times.Never());
            }
コード例 #3
0
            public void IgnoreTimeoutIfTimeoutDoesNotMatchScheduled()
            {
                var timeout = SystemTime.Now.Subtract(TimeSpan.FromSeconds(1));
                var saga    = ConfigureSagaTimeout(timeout);

                using (var eventContext = CreateEventContext(saga, SystemTime.Now))
                {
                    SagaEventHandler.Handle(eventContext);

                    SagaStore.Verify(mock => mock.Save(saga, It.Is((SagaContext context) => !context.TimeoutChanged)), Times.Once);
                }

                Assert.Equal(timeout, saga.Timeout);
                Assert.False(Handled);
            }
コード例 #4
0
            public void IgnoreTimeoutIfNoTimeoutScheduled()
            {
                var timeout = SystemTime.Now;
                var saga    = ConfigureSagaTimeout(default(DateTime?));

                using (var eventContext = CreateEventContext(saga, timeout))
                {
                    SagaEventHandler.Handle(eventContext);

                    SagaStore.Verify(mock => mock.Save(saga, It.Is((SagaContext context) => !context.TimeoutChanged)), Times.Once);
                }

                Assert.Null(saga.Timeout);
                Assert.False(Handled);
            }
コード例 #5
0
            public void ClearTimeoutIfTimeoutScheduledAndMatchesExpectedTimeout()
            {
                var timeout = SystemTime.Now;
                var saga    = ConfigureSagaTimeout(timeout);

                using (var eventContext = CreateEventContext(saga, timeout))
                {
                    SagaEventHandler.Handle(eventContext);

                    SagaStore.Verify(mock => mock.Save(saga, It.Is((SagaContext context) => context.TimeoutChanged)), Times.Once);
                }

                Assert.Null(saga.Timeout);
                Assert.True(Handled);
            }
コード例 #6
0
            public void SagaIdExtractedFromEventConfiguration()
            {
                SagaEventHandler.Handle(EventContext);

                SagaStore.Verify(mock => mock.CreateSaga(typeof(FakeSaga), SagaId), Times.Once());
            }