Пример #1
0
        public async Task Save__If_Model_is_invalid__Return_BadRequest()
        {
            // Arrange
            var model = new ConfirmationReportViewModel {
                Id = 5
            };

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

            worker.SaveDraft(model).Returns(new ConfirmationReportViewModel {
                Id = 5
            });

            var controller = new ConfirmationReportController(worker);

            controller.ModelState.AddModelError("fakeError", "fakeError");

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

            // Assert
            Assert.IsAssignableFrom <InvalidModelStateResult>(actual);
        }
Пример #2
0
        public async Task Save__Report_With_Id_Not_0__Return_Ok_Status()
        {
            // Arrange
            var model = new ConfirmationReportViewModel {
                Id = 5
            };

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

            worker.SaveDraft(model).Returns(new ConfirmationReportViewModel {
                Id = 5
            });

            var controller = new ConfirmationReportController(worker);

            SubstituteUrlHelper(controller, "http://localhost/api/Reports/id/5");

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

            // Assert
            Assert.IsAssignableFrom <OkNegotiatedContentResult <ConfirmationReportViewModel> >(actual);
        }