public void GetLogFileById_Exists_ShouldReturnSpecifiedLogContent() { //Arrange so that there is a mocked directory which contains mocked file const string id = "fakeFileName"; var logFileContent = "This is the content of the log."; var logFile = new LogFile(logFileContent); var logFinderMock = new Mock <ILogFinder>(); logFinderMock .Setup(x => x.GetLogFile(id)) .Returns(new GetLogFileResult.Success(logFile)); logFinderMock .Setup(x => x.GetLogIndex()) .Returns(GetTestLogIndex()); var controller = new LogFileController(logFinderMock.Object); var actionResult = controller.GetById(id); actionResult.Result.Should().BeOfType <OkObjectResult>(); var okObjectResult = actionResult.Result.As <OkObjectResult>(); okObjectResult.Value.Should().BeOfType <LogFile>(); var responseLogFile = okObjectResult.Value.As <LogFile>(); responseLogFile.Content.Should().Be(logFileContent); }
public void GetLogFileById_DoesNotExist_ShouldReturnNotFound() { const string id = "1"; var mockLogFinder = new Mock <ILogFinder>(); mockLogFinder .Setup(x => x.GetLogFile(id)) .Returns(new GetLogFileResult.LogFileNotFound()); var controller = new LogFileController(mockLogFinder.Object); var actionResult = controller.GetById(id); actionResult.Result.Should().BeOfType <NotFoundResult>(); }