Skip to content

WinMerge Report

GregFinzer edited this page Dec 20, 2017 · 1 revision

Compare .NET objects offers the ability to output the results as text files and then launch the third party difference tool WinMerge.

http://winmerge.org/

Example

[Test]
public void WinMergeReportTest()
{
	string expected = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "winMergeExpected.txt");
	string actual = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "winMergeActual.txt");

	if (File.Exists(expected))
		File.Delete(expected);

	if (File.Exists(actual))
		File.Delete(actual);

	Movie winMergeExpected = new Movie();
	winMergeExpected.Name = "Oblivion";
	winMergeExpected.PaymentForTomCruise = 2000000M;

	Movie winMergeActual = new Movie();
	winMergeActual.Name = "Edge of Tomorrow";
	winMergeActual.PaymentForTomCruise = 3000000M;

	CompareLogic compareLogic = new CompareLogic();
	compareLogic.Config.MaxDifferences = Int32.MaxValue;
	ComparisonResult result = compareLogic.Compare(winMergeExpected, winMergeActual);

	WinMergeReport winMergeReport = new WinMergeReport();
	winMergeReport.OutputFiles(result.Differences, expected, actual);

	Assert.IsTrue(File.Exists(expected));
	Assert.IsTrue(File.Exists(actual));

	if (!string.IsNullOrEmpty(winMergeReport.FindWinMerge()))
		winMergeReport.LaunchApplication(expected,actual);
}