Beispiel #1
0
        public async Task AddReportShouldAddReport()
        {
            var report = new Report();

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

            Assert.IsAssignableFrom <CreatedAtActionResult>(result);
            _userBLMock.Verify(x => x.AddReportAsync((It.IsAny <Report>())));
        }
Beispiel #2
0
        public async Task AddReportAsync_ShouldReturnStatusCode400_WhenInvalid()
        {
            //arrange
            var    userBLMock = new Mock <IUserBL>();
            Report report     = null;

            userBLMock.Setup(i => i.AddReportAsync(report)).Throws(new Exception());
            var reportController = new ReportController(userBLMock.Object);

            //act
            var result = await reportController.AddReportAsync(report);


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