コード例 #1
0
        public void CanReplay_CalledWhenAllPartsOfChainCannotReplay_ExpectFalseIsReturned(
			AggregateRoot aggregateRootOrNull,
			DomainEvent domainEventOrNull,
			ConstructWith construct)
        {
            var aggregateRoot = aggregateRootOrNull.ToObject();
            var domainEvent = domainEventOrNull.ToObject();
            var innerReplays = AtLeastOneReplayStubbedForCannotReplay().ToArray();
            var chain = construct.WithChain(innerReplays);
            chain.CanReplay(aggregateRoot, domainEvent).Should().BeFalse();
        }
コード例 #2
0
        public void CanReplay_CalledWhenAnyPartOfChainCanReplay_ExpectTrueIsReturned(
			AggregateRoot aggregateRootOrNull,
			DomainEvent domainEventOrNull,
			ConstructWith construct)
        {
            var aggregateRoot = aggregateRootOrNull.ToObject();
            var domainEvent = domainEventOrNull.ToObject();
            var innerReplays =
                AtLeastOneReplayStubbedForCanReplay(aggregateRoot, domainEvent)
                .Concat(AnyNumberOfReplaysStubbedForCannotReplay())
                .Shuffle()
                .ToArray();

            var chain = construct.WithChain(innerReplays);
            chain.CanReplay(aggregateRoot, domainEvent).Should().BeTrue();
        }
コード例 #3
0
        public void CanReplay_CalledWhenChainIsEmpty_ExpectFalseIsReturned(
			AggregateRoot aggregateRootOrNull,
			DomainEvent domainEventOrNull,
			ConstructWith construct)
        {
            var aggregateRoot = aggregateRootOrNull.ToObject();
            var domainEvent = domainEventOrNull.ToObject();
            var chain = construct.WithChain(new IReplayDomainEvents<object>[0]);
            chain.CanReplay(aggregateRoot, domainEvent).Should().BeFalse();
        }
コード例 #4
0
        public void Replay_CalledWhenOnePartOfChainCanReplay_ExpectAggregateRootReturnedByMatchingChainEntryIsReturned(
			AggregateRoot aggregateRootOrNull,
			DomainEvent domainEventOrNull,
			ConstructWith construct)
        {
            var aggregateRoot = aggregateRootOrNull.ToObject();
            var domainEvent = domainEventOrNull.ToObject();
            var returnedAggregateRoot = new object();
            var innerReplays =
                new[] {CreateReplayStubbedForCanReplay(aggregateRoot, domainEvent, returnedAggregateRoot)}
                .Concat(AnyNumberOfReplaysStubbedForCannotReplay())
                .Shuffle()
                .ToArray();

            var chain = construct.WithChain(innerReplays);
            chain.Replay(aggregateRoot, domainEvent).Should().BeSameAs(returnedAggregateRoot);
        }
コード例 #5
0
        public void Replay_CalledWhenChainIsEmpty_ExpectDomainEventCannotBeReplayedExceptionWithCorrectDomainEvent(
			AggregateRoot aggregateRootOrNull,
			DomainEvent domainEventOrNull,
			ConstructWith construct)
        {
            var aggregateRoot = aggregateRootOrNull.ToObject();
            var domainEvent = domainEventOrNull.ToObject();
            var chain = construct.WithChain(new IReplayDomainEvents<object>[0]);
            chain.Invoking(x => x.Replay(aggregateRoot, domainEvent))
                .ShouldThrow<DomainEventCannotBeReplayedException>()
                .And.DomainEvent.Should().BeSameAs(domainEvent);
        }