示例#1
0
            public void ReturnAggregateIfNoExceptionsThrown()
            {
                var id                      = Guid.NewGuid();
                var type                    = typeof(Aggregate);
                var aggregate               = new Mock <Aggregate>();
                var pipelineHook            = new Mock <PipelineHook>();
                var decoratedAggregateStore = new Mock <IStoreAggregates>();
                var aggregateStore          = new HookableAggregateStore(decoratedAggregateStore.Object, new[] { pipelineHook.Object });

                decoratedAggregateStore.Setup(mock => mock.Get(type, id)).Returns(aggregate.Object);

                Assert.Same(aggregate.Object, aggregateStore.Get(type, id));
            }
示例#2
0
            public void InvokePreGetHooksBeforeDecoratedGet()
            {
                var id                      = Guid.NewGuid();
                var type                    = typeof(Aggregate);
                var pipelineHook            = new Mock <PipelineHook>();
                var decoratedAggregateStore = new Mock <IStoreAggregates>();
                var aggregateStore          = new HookableAggregateStore(decoratedAggregateStore.Object, new[] { pipelineHook.Object });

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

                Assert.Throws <InvalidOperationException>(() => aggregateStore.Get(type, id));

                decoratedAggregateStore.Verify(mock => mock.Get(type, id), Times.Never());
            }
            public void ReturnAggregateIfNoExceptionsThrown()
            {
                var id = Guid.NewGuid();
                var type = typeof(Aggregate);
                var aggregate = new Mock<Aggregate>();
                var pipelineHook = new Mock<PipelineHook>();
                var decoratedAggregateStore = new Mock<IStoreAggregates>();
                var aggregateStore = new HookableAggregateStore(decoratedAggregateStore.Object, new[] { pipelineHook.Object });

                decoratedAggregateStore.Setup(mock => mock.Get(type, id)).Returns(aggregate.Object);

                Assert.Same(aggregate.Object, aggregateStore.Get(type, id));
            }
            public void InvokePostGetHooksAfterDecoratedGet()
            {
                var id = Guid.NewGuid();
                var type = typeof(Aggregate);
                var aggregate = new Mock<Aggregate>();
                var pipelineHook = new Mock<PipelineHook>();
                var decoratedAggregateStore = new Mock<IStoreAggregates>();
                var aggregateStore = new HookableAggregateStore(decoratedAggregateStore.Object, new[] { pipelineHook.Object });

                decoratedAggregateStore.Setup(mock => mock.Get(type, id)).Returns(aggregate.Object);
                pipelineHook.Setup(mock => mock.PostGet(aggregate.Object)).Throws(new InvalidOperationException());

                Assert.Throws<InvalidOperationException>(() => aggregateStore.Get(type, id));

                decoratedAggregateStore.Verify(mock => mock.Get(type, id), Times.Once());
            }