CQRS.Tests.CQRS.EventSourcing.EventRefactoring.Migrations.EventStreamMutatorTestsBase.AssertStreamsAreIdentical C# (CSharp) Метод

AssertStreamsAreIdentical() защищенный статический Метод

protected static AssertStreamsAreIdentical ( IEnumerable expected, IEnumerable migratedHistory, string descriptionOfHistory ) : void
expected IEnumerable
migratedHistory IEnumerable
descriptionOfHistory string
Результат void
        protected static void AssertStreamsAreIdentical(IEnumerable<IAggregateRootEvent> expected, IEnumerable<IAggregateRootEvent> migratedHistory, string descriptionOfHistory)
        {

            try
            {
                expected.ForEach(
                   (@event, index) =>
                   {
                       if (@event.GetType() != migratedHistory.ElementAt(index).GetType())
                       {
                           Assert.Fail(
                               $"Expected event at postion {index} to be of type {@event.GetType()} but it was of type: {migratedHistory.ElementAt(index).GetType()}");
                       }
                   });

                migratedHistory.Cast<AggregateRootEvent>().ShouldAllBeEquivalentTo(
                    expected,
                    config => config.RespectingRuntimeTypes()
                                    .WithStrictOrdering()
                                    .Excluding(@event => @event.EventId)
                                    //.Excluding(@event => @event.UtcTimeStamp)
                                    .Excluding(@event => @event.InsertionOrder)
                                    .Excluding(@event => @event.InsertAfter)
                                    .Excluding(@event => @event.InsertBefore)
                                    .Excluding(@event => @event.Replaces)
                                    .Excluding(@event => @event.InsertedVersion)
                                    .Excluding(@event => @event.ManualVersion)
                                    .Excluding(@event => @event.EffectiveVersion)
                                    .Excluding(subjectInfo => subjectInfo.SelectedMemberPath.EndsWith(".TimeStamp")));
            }
            catch(Exception)
            {
                Console.WriteLine($"   Failed comparing with {descriptionOfHistory}");
                Console.WriteLine($"   Expected: ");
                expected.ForEach(e => Console.WriteLine($"      {e.ToNewtonSoftDebugString(Formatting.None)}"));
                Console.WriteLine($"\n   Actual: ");
                migratedHistory.ForEach(e => Console.WriteLine($"      {e.ToNewtonSoftDebugString(Formatting.None)}"));
                Console.WriteLine("\n");               

                throw;
            }
        }
    }