public virtual ApprovalException Approve(string approvedPath, string receivedPath)
{
if (!File.Exists(approvedPath))
{
return new ApprovalMissingException(receivedPath, approvedPath);
}
if (this.normalizeLineEndingsForTextFiles && GenericDiffReporter.IsTextFile(approvedPath))
{
var receivedText = File.ReadAllText(receivedPath).Replace("\r\n", "\n");
var approvedText = File.ReadAllText(approvedPath).Replace("\r\n", "\n");
return !Compare(receivedText.ToCharArray(), approvedText.ToCharArray()) ?
new ApprovalMismatchException(receivedPath, approvedPath) :
null;
}
return !Compare(File.ReadAllBytes(receivedPath), File.ReadAllBytes(approvedPath)) ?
new ApprovalMismatchException(receivedPath, approvedPath) :
null;
}