In my controller I have an ActionResult method, that looks like this:
public ActionResult Well(string slideid, string path)
{
var model = slideRepository.GetWells(slideid);
var firstPath = slideRepository.MapPath(path);
byte[] firstImageByteData = System.IO.File.ReadAllBytes(firstPath + "/" + slideid + "_first.jpg");
string firstImageBase64Data = Convert.ToBase64String(firstImageByteData);
string firstImageDataUrl = string.Format("data:image/png;base64,{0}", firstImageBase64Data);
ViewBag.firstImageData = firstImageDataUrl;
return View("Well", model);
}
I use the Repository pattern and I've unit tested it successfully up until the model, but suddenly a new requirement has risen where I need to go fetch an image and display it in the view as well. I'm aware that unit testing file IO is something that can be discussed whether it's a good idea or not, but as the method looks right now, I'm not sure how to test it. Any suggestions?