Suppose you might normally mock a repository call in NSubstitute like so...
Repo.GetLastName(Arg.Any<string>()).Returns("Smith");
Alight, well how would you emulate the repository just blowing up as if the database were unaccessible. What then? Try this:
Repo.GetLastName(Arg.Any<string>()).Returns(x => { throw new Exception(); });
No comments:
Post a Comment