Added first controller unit test as well as several mock services

This commit is contained in:
Cameron
2024-09-08 13:17:54 -05:00
parent 296190b79c
commit fd92d38cdd
6 changed files with 242 additions and 0 deletions

View File

@@ -313,6 +313,8 @@ public class ComicController(ComicsContext context, ILogger<ComicController> log
var comic = await _context.Comics.SingleOrDefaultAsync(c => c.Handle == handle);
if (comic is null)
return NotFound(RequestError.ComicNotFound);
//can't mock this easily, move to a service?
//maybe IComicAnalyzer should be used even just to read a file
var data = await System.IO.File.ReadAllBytesAsync(Path.Join(_config.LibraryRoot, comic.Filepath));
return File(data, "application/octet-stream", new FileInfo(comic.Filepath).Name);
}