Skip to content

Beyond Compare 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 Beyond Compare.

http://www.scootersoftware.com/index.php

Example

[Test]
public void BeyondCompareReportTest()
{
	string expected = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "beyondExpected.txt");
	string actual = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "beyondActual.txt");

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

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

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

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

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

	BeyondCompareReport beyondCompare = new BeyondCompareReport();
	beyondCompare.OutputFiles(result.Differences, expected, actual);

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

	if (!string.IsNullOrEmpty(beyondCompare.FindBeyondCompare()))
		beyondCompare.LaunchApplication(expected, actual);
}