Skip to content

Instantly share code, notes, and snippets.

@jamesrcounts
Created October 2, 2012 03:25
Show Gist options
  • Select an option

  • Save jamesrcounts/3815982 to your computer and use it in GitHub Desktop.

Select an option

Save jamesrcounts/3815982 to your computer and use it in GitHub Desktop.
A dumbed down version of FileApprover, that makes Verifying two arbitrary text files easier.
public class TheoryApprover : IApprovalApprover
{
private readonly string approved;
private readonly string received;
private ApprovalException failure;
public TheoryApprover(string approved, string received)
{
this.received = received;
this.approved = approved;
}
public bool Approve()
{
this.failure = FileApprover.Approve(approved, received);
return this.failure == null;
}
public void CleanUpAfterSucess(IApprovalFailureReporter reporter)
{
// TODO: Remove duplication with FileApprover.
File.Delete(received);
if (reporter is IApprovalReporterWithCleanUp)
{
((IApprovalReporterWithCleanUp)reporter).CleanUp(approved, received);
}
}
public void Fail()
{
throw failure;
}
public void ReportFailure(IApprovalFailureReporter reporter)
{
reporter.Report(approved, received);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment