public void ReturnSagaIfNoExceptionsThrown()
            {
                var id                 = Guid.NewGuid();
                var type               = typeof(Saga);
                var saga               = new Mock <Saga>();
                var pipelineHook       = new Mock <PipelineHook>();
                var decoratedSagaStore = new Mock <IStoreSagas>();
                var sagaStore          = new HookableSagaStore(decoratedSagaStore.Object, new[] { pipelineHook.Object });

                decoratedSagaStore.Setup(mock => mock.CreateSaga(type, id)).Returns(saga.Object);

                Assert.Same(saga.Object, sagaStore.CreateSaga(type, id));
            }
            public void InvokePreGetHooksBeforeDecoratedGet()
            {
                var id                 = Guid.NewGuid();
                var type               = typeof(Saga);
                var pipelineHook       = new Mock <PipelineHook>();
                var decoratedSagaStore = new Mock <IStoreSagas>();
                var sagaStore          = new HookableSagaStore(decoratedSagaStore.Object, new[] { pipelineHook.Object });

                pipelineHook.Setup(mock => mock.PreGet(type, id)).Throws(new InvalidOperationException());

                Assert.Throws <InvalidOperationException>(() => sagaStore.CreateSaga(type, id));

                decoratedSagaStore.Verify(mock => mock.CreateSaga(type, id), Times.Never());
            }
            public void ReturnSagaIfNoExceptionsThrown()
            {
                var id = Guid.NewGuid();
                var type = typeof(Saga);
                var saga = new Mock<Saga>();
                var pipelineHook = new Mock<PipelineHook>();
                var decoratedSagaStore = new Mock<IStoreSagas>();
                var sagaStore = new HookableSagaStore(decoratedSagaStore.Object, new[] { pipelineHook.Object });

                decoratedSagaStore.Setup(mock => mock.CreateSaga(type, id)).Returns(saga.Object);

                Assert.Same(saga.Object, sagaStore.CreateSaga(type, id));
            }
            public void InvokePostGetHooksAfterDecoratedGet()
            {
                var id = Guid.NewGuid();
                var type = typeof(Saga);
                var saga = new Mock<Saga>();
                var pipelineHook = new Mock<PipelineHook>();
                var decoratedSagaStore = new Mock<IStoreSagas>();
                var sagaStore = new HookableSagaStore(decoratedSagaStore.Object, new[] { pipelineHook.Object });

                decoratedSagaStore.Setup(mock => mock.CreateSaga(type, id)).Returns(saga.Object);
                pipelineHook.Setup(mock => mock.PostGet(saga.Object)).Throws(new InvalidOperationException());

                Assert.Throws<InvalidOperationException>(() => sagaStore.CreateSaga(type, id));

                decoratedSagaStore.Verify(mock => mock.CreateSaga(type, id), Times.Once());
            }