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(); }
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(); }
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(); }
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); }
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); }