protected ObjectComparison(string key, T item1, T item2, ObjectComparisonResult result, IReadOnlyCollection <Difference> differentProperties = null) { this.Key = key; this.Item1 = item1; this.Item2 = item2; this.Result = result; this.DifferentProperties = differentProperties ?? Array.Empty <Difference>(); }
private Color GetColor(ObjectComparisonResult result) { switch (result) { case ObjectComparisonResult.Equals: return(Color.FromArgb(198, 239, 206)); case ObjectComparisonResult.MatchingButDifferent: return(Color.FromArgb(255, 199, 206)); case ObjectComparisonResult.LeftMissing: return(Color.FromArgb(248, 203, 173)); case ObjectComparisonResult.RightMissing: return(Color.FromArgb(189, 215, 238)); default: return(Color.FromArgb(255, 235, 156)); } }
public static string GetMessage(this ObjectComparisonResult result) { switch (result) { case ObjectComparisonResult.Equals: return("The record is present in both environments, and the values of the attributes match"); case ObjectComparisonResult.MatchingButDifferent: return("The record is present in both environments, but the values of some attribute doesn't matches. Review unmatching attributes below."); case ObjectComparisonResult.LeftMissing: return("The record is present only on {1} (missing on {0})"); case ObjectComparisonResult.RightMissing: return("The record is present only on {0} (missing on {1})"); default: return(string.Empty); } }
public static Color GetColor(this ObjectComparisonResult result) { switch (result) { case ObjectComparisonResult.Equals: return(BackColorForEquals); case ObjectComparisonResult.MatchingButDifferent: return(BackColorForMatchingButDifferent); case ObjectComparisonResult.LeftMissing: return(BackColorForLeftMissing); case ObjectComparisonResult.RightMissing: return(BackColorForRightMissing); default: return(BackColorDefault); } }
public void Assert() { if (_entity != null) { using (var t = _context.OpenSession(_message)) { t.SaveAndPublishEvents(_entity); } } _context.ClearGeneratedEvents(); var expected = _expected(_entity, _message); /* * Invoke the message on the handler and retrieve the actual * events from the repository and eventbus, and compare both with the * expected events list passed-in using Inforigami.Regalo.ObjectCompare. */ InvokeHandler(); var eventsStoredToEventStore = _context.GetGeneratedEvents(); var comparer = ObjectComparerProvider.Create(); ObjectComparisonResult result = comparer.AreEqual(expected, eventsStoredToEventStore); if (!result.AreEqual) { var message = $"Actual events did not match expected events. {result.InequalityReason}"; if (expected.Any() && !eventsStoredToEventStore.Any()) { message += "\r\nCheck that your Scenario-based test is using the same IMesasageHandlerContext throughout, in case events are written to one assertions are performed against another."; } throw new AssertionException(message); } }
public void Assert() { /* * Plan is to invoke the command on the handler and retrieve the actual * events from the repository and eventbus, and compare both with the * expected events list passed-in using Regalo.Object compare. */ InvokeHandler(); var eventsStoredToEventStore = _context.GetGeneratedEvents(); var comparer = new ObjectComparer().Ignore <Event, Guid?>(x => x.ParentVersion) .Ignore <Event, Guid>(x => x.Version) .Ignore <Event, Guid>(x => x.Id); ObjectComparisonResult result = comparer.AreEqual(_expected, eventsStoredToEventStore); if (!result.AreEqual) { throw new AssertionException(string.Format("Actual events did not match expected events. {0}", result.InequalityReason)); } }
public void InvokingBehaviour_GivenSimpleAggregateRootThatInheritsAnother_ShouldRecordEvents() { // Arrange var user = new SuperUser(); user.Register(); // Act user.ChangePassword("newpassword"); IEnumerable <IEvent> actual = user.GetUncommittedEvents(); var expected = new EventChain { new UserRegistered(user.Id), new UserChangedPassword("newpassword") }; ObjectComparisonResult result = _comparer.AreEqual(expected, actual); if (!result.AreEqual) { throw new AssertionException(string.Format("Actual events did not match expected events. {0}", result.InequalityReason)); } }