コード例 #1
0
        public async Task FindById__if_report_not_found__Return_NotFound_Status()
        {
            // Arrange
            int model = 1;

            IConfirmationReportWorker worker = Substitute.For <IConfirmationReportWorker>();

            worker.FindById(model).Returns(null as ConfirmationReportViewModel);
            var controller = new ConfirmationReportController(worker);

            // Act
            var actual = await controller.FindById(model);

            // Assert
            Assert.IsAssignableFrom <NotFoundResult>(actual);
        }
        public async Task <IHttpActionResult> FindById(int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ConfirmationReportViewModel report = await worker.FindById(id);

            if (report != null)
            {
                return(Ok(report));
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #3
0
        public async Task FindById__if_report_found__Return_Ok_Status()
        {
            // Arrange
            int model = 1;

            IConfirmationReportWorker worker = Substitute.For <IConfirmationReportWorker>();

            worker.FindById(model).Returns(new ConfirmationReportViewModel {
                Id = 1
            });

            var controller = new ConfirmationReportController(worker);

            // Act
            var actual = await controller.FindById(model);

            // Assert
            Assert.IsAssignableFrom <OkNegotiatedContentResult <ConfirmationReportViewModel> >(actual);
        }
コード例 #4
0
        public async Task FindById__if_report_found__Return_report_with_same_reportNumber()
        {
            // Arrange
            int model = 1;

            IConfirmationReportWorker worker = Substitute.For <IConfirmationReportWorker>();

            worker.FindById(model).Returns(new ConfirmationReportViewModel {
                Id = 1
            });

            var controller = new ConfirmationReportController(worker);

            // Act
            var actual = await controller.FindById(model) as OkNegotiatedContentResult <ConfirmationReportViewModel>;

            // Assert
            Assert.IsNotNull(actual.Content);
            Assert.AreEqual(model, actual.Content.Id);
        }