I'm having trouble mocking File.WriteAllBytes. Here's my test code:
var called =
false
;
var ccr =
new
Ccr { Pdf =
new
byte
[73], SubmissionId = 3 };
Mock.Replace<
string
,
byte
[]>((s, b) => File.WriteAllBytes(s, b)).In<CcrFileWriter>(x => x.WriteToDisk(ccr));
Mock.Arrange(() => File.WriteAllBytes(
null
,
null
)).IgnoreArguments().DoInstead(()=> called =
true
);
var writer =
new
CcrFileWriter();
writer.WriteToDisk(ccr);
Assert.IsTrue(called);
It's not working. It's not bypassing File.WriteAllBytes and the test fails.
Maybe I'm not understanding how this should work?