Example #1
0
        public async Task DeleteReportShouldDeleteReport()
        {
            var report = new Report {
                Id = 1
            };

            _userBLMock.Setup(x => x.DeleteReportAsync(It.IsAny <Report>())).Returns(Task.FromResult <Report>(report));
            var reportController = new ReportController(_userBLMock.Object);
            var result           = await reportController.DeleteReportAsync(report.Id);

            Assert.IsAssignableFrom <NoContentResult>(result);
            _userBLMock.Verify(x => x.DeleteReportAsync((It.IsAny <Report>())));
        }
Example #2
0
        public async Task DeleteReportAsync_ShouldReturnStatusCode500_WhenIDIsInvalid()
        {
            //arrange
            var    userBLMock = new Mock <IUserBL>();
            int    id         = -71;
            User   user       = new User();
            Report report     = null;

            userBLMock.Setup(i => i.GetReportByIdAsync(id));
            userBLMock.Setup(i => i.DeleteReportAsync(report)).Throws(new Exception());
            ReportController reportController = new ReportController(userBLMock.Object);

            //act
            var result = await reportController.DeleteReportAsync(id);

            //assert
            Assert.IsType <StatusCodeResult>(result);
            Assert.Equal(500, ((StatusCodeResult)result).StatusCode);
        }