Consider the following code:
[Test, UseReporter(typeof(WinMergeReporter))]
public void Test()
{
var fileToVerify = "test.csv";
Approvals.VerifyFile(fileToVerify);
}
Whenever I run this, the file "test.csv" gets deleted. In the ApprovalTests source code, I've seen that received files are getting deleted but I was under the impression that this applied to the .received. files which normally get created.
Incidentally, I don't see any .received. file created in this instance. My first question is what is actually going under the hood as the code isn't quite making sense. My next question is how do I prevent "test.csv" from getting deleted.
You are right that the received file get deleted on a successful verification. In the case of VerifyFile you are specifying the received file so there will be no special naming, but the file you pass is considered to be the received file.
This is normally the desired behavior as you will want to generate that file each time you run the test, otherwise what is the point of the test?
However, if you want the file to hang around because you are doing things to it after the test (not generally a great idea, but I don't know the full story) I would suggest making a temporary copy to verify.
File.Copy(from,to);
Happy Testing!
Llewellyn