public void RunMigrationTest ( IEnumerable<Type> originalHistory, IEnumerable<Type> expectedHistory, params IEventMigration[] manualMigrations) { var migrationInstances = manualMigrations; var aggregateId = Guid.NewGuid(); var aggregate = TestAggregate.FromEvents(aggregateId, originalHistory); var mutatedHistory = new SingleAggregateEventStreamMutator(aggregate.Id, migrationInstances) .MutateCompleteAggregateHistory(aggregate.History).ToList(); var expected = TestAggregate.FromEvents(aggregateId, expectedHistory).History.ToList(); Console.WriteLine($"Expected: "); expected.ForEach(e => Console.WriteLine($" {e}")); Console.WriteLine($"\nActual: "); mutatedHistory.ForEach(e => Console.WriteLine($" {e}")); expected.ForEach( (@event, index) => { if(@event.GetType() != mutatedHistory[index].GetType()) { Assert.Fail( $"Expected event at postion {index} to be of type {@event.GetType()} but it was of type: {mutatedHistory[index].GetType()}"); } }); mutatedHistory.ShouldAllBeEquivalentTo( expected, config => config.RespectingRuntimeTypes() .WithStrictOrdering() .Excluding(@event => @event.EventId) .Excluding(@event => @event.TimeStamp)); }
public void RunMigrationTest ( IEnumerable <Type> originalHistory, IEnumerable <Type> expectedHistory, params IEventMigration[] manualMigrations) { var migrationInstances = manualMigrations; var aggregateId = Guid.NewGuid(); var aggregate = TestAggregate.FromEvents(aggregateId, originalHistory); var mutatedHistory = new SingleAggregateEventStreamMutator(aggregate.Id, migrationInstances) .MutateCompleteAggregateHistory(aggregate.History).ToList(); var expected = TestAggregate.FromEvents(aggregateId, expectedHistory).History.ToList(); Console.WriteLine($"Expected: "); expected.ForEach(e => Console.WriteLine($" {e}")); Console.WriteLine($"\nActual: "); mutatedHistory.ForEach(e => Console.WriteLine($" {e}")); expected.ForEach( (@event, index) => { if (@event.GetType() != mutatedHistory[index].GetType()) { Assert.Fail( $"Expected event at postion {index} to be of type {@event.GetType()} but it was of type: {mutatedHistory[index].GetType()}"); } }); mutatedHistory.ShouldAllBeEquivalentTo( expected, config => config.RespectingRuntimeTypes() .WithStrictOrdering() .Excluding(@event => @event.EventId) .Excluding(@event => @event.TimeStamp)); }