AggregateSource.Testing.Comparers.CompareNetObjectsBasedFactComparer.Compare C# (CSharp) Method

Compare() public method

Compares the expected to the actual fact.
public Compare ( Fact expected, Fact actual ) : IEnumerable
expected Fact The expected fact.
actual Fact The actual fact.
return IEnumerable
        public IEnumerable<FactComparisonDifference> Compare(Fact expected, Fact actual)
        {
            if (string.CompareOrdinal(expected.Identifier, actual.Identifier) != 0)
            {
                yield return new FactComparisonDifference(
                    expected,
                    actual,
                    string.Format("Expected.Identifier != Actual.Identifier ({0},{1})", expected.Identifier, actual.Identifier));
            }

            var result = _logic.Compare(expected.Event, actual.Event);
            if (!result.AreEqual)
            {
                foreach (var difference in result.Differences)
                {
                    yield return new FactComparisonDifference(
                        expected,
                        actual,
                        difference.ToString());
                }
            }
        }
    }

Usage Example

        public void CompareReturnsExpectedFactWhenIdentifiersDiffer()
        {
            var comparer = new CompareObjects();
            var sut      = new CompareNetObjectsBasedFactComparer(comparer);

            var @event = new Event {
                Value = "1"
            };
            var expected = new Fact("123", @event);
            var actual   = new Fact("456", @event);
            var result   = sut.Compare(expected, actual);

            Assert.That(result,
                        Is.EquivalentTo(new[]
            {
                new FactComparisonDifference(expected, actual, "Expected.Identifier != Actual.Identifier (123,456)")
            }).Using(FactComparisonDifferenceComparer.Instance));
        }
All Usage Examples Of AggregateSource.Testing.Comparers.CompareNetObjectsBasedFactComparer::Compare
CompareNetObjectsBasedFactComparer