Menu

#5 Received and Approved files are equal but diff complains

open
nobody
None
5
2012-08-30
2012-08-30
Anonymous
No

When using a custom method to create a string to approve, the TortoiseMerge diff says the files are not equal even if they are. Or at least they are equal to the eye, I assume there is some minor invisible diffrence since the differ says so. See the example. I can run it many times in a row, and the test fails with that message every time.

How to fix?

The string is built using methods like this one:

public string ApprovalString()
{
return GetType().GetProperties().Aggregate(string.Format("\n\n{0}\n\n", GetType().Name), (current, prop) => current + string.Format("* {0}: {1}\n", prop.Name, prop.GetValue(this, null)));
}

Approvals.Verify(myObject.ApprovalString());

Discussion

  • Anonymous

    Anonymous - 2012-08-30

    Actually, I get the same issue with this simple test:

    [Test]
    [UseReporter(typeof(DiffReporter))]
    public void StringTest()
    {
    Approvals.Verify("abc");
    }

    while the following test is OK:

    [Test]
    [UseReporter(typeof(DiffReporter))]
    public void StringTest()
    {
    const string text = "abc";
    Approvals.Verify(text);
    }