Skip to content

User Friendly Report

GregFinzer edited this page Dec 20, 2017 · 1 revision

Sometimes you want to show the differences of an object to a user before they submit their changes to the database. The User Friendly report can be used to do this:

Example

[Test]
public void UserFriendlyReportTest()
{
	string expected = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "movie.txt");

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

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

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

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

	UserFriendlyReport friendlyReport = new UserFriendlyReport();
	friendlyReport.OutputFile(result.Differences, expected);

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

	Console.WriteLine(friendlyReport.OutputString(result.Differences));

	friendlyReport.LaunchApplication(expected);
}