public void GetReportReturnsBadRequestResultWhenIdNull() { //Arrange var mock = new Mock <IDataBaseManager>(); var controller = new RefinanceApiController(mock.Object); //Act var result = controller.GetReport(null); //Assert Assert.IsType <BadRequestResult>(result); }
public void GetReportReturnsNotFoundResultWhenQuotaNotFound() { //Arrange int testId = 1; var mock = new Mock <IDataBaseManager>(); mock.Setup(repo => repo.GetQuota(testId)) .Returns(null as Quota); var controller = new RefinanceApiController(mock.Object); //Act var result = controller.GetReport(testId); //Assert Assert.IsType <NotFoundResult>(result); }
public void GetReportReturnsFileResult() { //Arrange int testId = 1; var testQ = GetQuotas(1).Single(o => o.Id == testId); var mock = new Mock <IDataBaseManager>(); mock.Setup(repo => repo.GetQuota(testId)) .Returns(testQ); var controller = new RefinanceApiController(mock.Object); //Act var result = controller.GetReport(testId); //Assert var fileResult = Assert.IsType <FileContentResult>(result); Assert.Equal("text/html", fileResult?.ContentType); Assert.Equal("report.html", fileResult?.FileDownloadName); }