示例#1
0
        public async Task FindByNumber__if_report_not_found__Return_NotFound_Status()
        {
            // Arrange
            int model = 1;

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

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

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

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

            ConfirmationReportViewModel report = await worker.FindByNumber(reportNumber);

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

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

            worker.FindByNumber(model).Returns(new ConfirmationReportViewModel {
                Id = 5, ReportNumber = 1
            });

            var controller = new ConfirmationReportController(worker);

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

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

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

            worker.FindByNumber(model).Returns(new ConfirmationReportViewModel {
                Id = 5, ReportNumber = 1
            });

            var controller = new ConfirmationReportController(worker);

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

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