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

                decoratedSagaStore.Setup(mock => mock.TryGetSaga(type, id, out saga)).Returns(true);

                Assert.True(sagaStore.TryGetSaga(type, id, out saga));
            }
            public void InvokePreGetHooksBeforeDecoratedGet()
            {
                var id                 = Guid.NewGuid();
                var type               = typeof(Saga);
                var saga               = default(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.TryGetSaga(type, id, out saga));

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

                decoratedSagaStore.Setup(mock => mock.TryGetSaga(type, id, out saga)).Returns(true);

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

                decoratedSagaStore.Setup(mock => mock.TryGetSaga(type, id, out saga)).Returns(true);
                pipelineHook.Setup(mock => mock.PostGet(saga)).Throws(new InvalidOperationException());

                Assert.Throws<InvalidOperationException>(() => sagaStore.TryGetSaga(type, id, out saga));

                decoratedSagaStore.Verify(mock => mock.TryGetSaga(type, id, out saga), Times.Once());
            }