Posted 19 Oct 2012 Link to this post
I'm having trouble mocking File.WriteAllBytes. Here's my test code:
var called =
false
;
var ccr =
new
Ccr { Pdf =
byte
[73], SubmissionId = 3 };
Mock.Replace<
string
,
[]>((s, b) => File.WriteAllBytes(s, b)).In<CcrFileWriter>(x => x.WriteToDisk(ccr));
Mock.Arrange(() => File.WriteAllBytes(
null
)).IgnoreArguments().DoInstead(()=> called =
true
);
var writer =
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?
Posted 24 Oct 2012 Link to this post
Thanks again for contacting us.
I have sent you a sample project in ticket # 571362 that should clarify the issue. In addition, make sure that you have updated all the references before running the test.
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.