bool Compare(object expected, object actual, string member, IWriter writer) { try { _elementStack.Push(member); var linkContext = new LinkComparisonContext { Expected = expected, Actual = actual, ComparisonContext = this, MemberPath = GetExpectedMemberPath(), Configuration = _configurationContext, IgnoreTypeInformation = _ignoreTypeInformation }; var result = _strategyChain.Process(linkContext); if (_elementStack.Count > 0) { writer.Write(new EqualityResult(result.Result, GetMemberPath(), result.ExpectedResult ?? expected, actual)); } return(result.Result); } finally { if (_elementStack.Count > 0) { _elementStack.Pop(); } } }
public LinkComparisonResult Compare(LinkComparisonContext linkComparisonContext, Func <LinkComparisonContext, LinkComparisonResult> next) { var actual = linkComparisonContext.Actual; if (actual is IMissing) { return(LinkComparisonResult.False); } return(next(linkComparisonContext)); }
public LinkComparisonResult Compare(LinkComparisonContext linkComparisonContext, Func <LinkComparisonContext, LinkComparisonResult> next) { var expected = linkComparisonContext.Expected; var actual = linkComparisonContext.Actual; if (!linkComparisonContext.IgnoreTypeInformation && !expected.GetType().IsInstanceOfType(actual)) { return(LinkComparisonResult.False); } return(next(linkComparisonContext)); }
public LinkComparisonResult Compare(LinkComparisonContext linkComparisonContext, Func <LinkComparisonContext, LinkComparisonResult> next) { var expected = linkComparisonContext.Expected; if (expected == null) { return(new LinkComparisonResult() { Result = false }); } return(next(linkComparisonContext)); }
public LinkComparisonResult Compare(LinkComparisonContext linkComparisonContext, Func <LinkComparisonContext, LinkComparisonResult> next) { var expected = linkComparisonContext.Expected; var actual = linkComparisonContext.Actual; if (ReferenceEquals(expected, actual)) { return(new LinkComparisonResult() { Result = true }); } return(next(linkComparisonContext)); }
public LinkComparisonResult Compare(LinkComparisonContext linkComparisonContext, Func <LinkComparisonContext, LinkComparisonResult> next) { var expected = linkComparisonContext.Expected; var actual = linkComparisonContext.Actual; if (expected is IComparison comparison) { var areEqual = comparison.AreEqual(actual); return(new LinkComparisonResult { Result = areEqual, ExpectedResult = !areEqual?comparison.GetExpectedResult() : string.Empty }); } return(next(linkComparisonContext)); }
public LinkComparisonResult Compare(LinkComparisonContext linkComparisonContext, Func <LinkComparisonContext, LinkComparisonResult> next) { var expected = linkComparisonContext.Expected; var actual = linkComparisonContext.Actual; if (expected != null) { var typeStrategy = linkComparisonContext.Configuration.GetTypeStrategy(expected.GetType()); if (typeStrategy != null) { return(new LinkComparisonResult { Result = typeStrategy.AreEqual(expected, actual, linkComparisonContext.ComparisonContext) }); } } return(next(linkComparisonContext)); }
public LinkComparisonResult Compare(LinkComparisonContext linkComparisonContext, Func <LinkComparisonContext, LinkComparisonResult> next) { var actual = linkComparisonContext.Actual; var memberComparison = GetMemberComparison(linkComparisonContext.MemberPath, linkComparisonContext.Configuration); if (memberComparison != null) { var areEqual = memberComparison.AreEqual(actual); return(new LinkComparisonResult { Result = areEqual, ExpectedResult = !areEqual?memberComparison.GetExpectedResult() : string.Empty }); } return(next(linkComparisonContext)); }
public LinkComparisonResult Compare(LinkComparisonContext linkComparisonContext, Func <LinkComparisonContext, LinkComparisonResult> next) { var expected = linkComparisonContext.Expected; var actual = linkComparisonContext.Actual; foreach (var strategy in linkComparisonContext.Configuration.ComparisonStrategies) { if (strategy.CanCompare(expected, actual)) { var areEqual = strategy.AreEqual(expected, actual, linkComparisonContext.ComparisonContext); return(new LinkComparisonResult { Result = areEqual }); } } return(next(linkComparisonContext)); }
public LinkComparisonResult Compare(LinkComparisonContext linkComparisonContext, Func <LinkComparisonContext, LinkComparisonResult> next) { return(LinkComparisonResult.True); }