public void CreatePost_CalledWithInvalidModel_ShouldNotCallViewModelBuilder()
        {
            _controller.ModelState.AddModelError("error", "error");
            var result = _controller.Create(new AssessmentViewModel()) as ViewResult;

            A.CallTo(() => _assessmentViewModelBuilder.BuildAssessmentViewModel(A <Assessment> ._)).MustNotHaveHappened();
        }
Beispiel #2
0
        public void CreatePOST_GivenValidModel_AssessmentCommandShouldBeBuilt()
        {
            var model = new AssessmentViewModel();

            _assessmentController.Create(model);

            A.CallTo(() => _assessmentBuilder.BuildAddAssessmentCommand(model)).MustHaveHappened(Repeated.Exactly.Once);
        }
Beispiel #3
0
        public void CanCreateAssessment()
        {
            // Arrange
            var patientKey                 = Guid.NewGuid();
            var workflowKey                = Guid.NewGuid();
            var assessmentInstanceKey      = Guid.NewGuid();
            var asyncRequestDispatcherMock = new Mock <IAsyncRequestDispatcher>();

            asyncRequestDispatcherMock.Setup(rd => rd.GetAsync <CreateAssessmentResponse>())
            .Returns(
                Task.FromResult(new CreateAssessmentResponse
            {
                AssessmentInstanceKey = assessmentInstanceKey
            }));
            var requestDisplatcherFactoryMock = new Mock <IRequestDispatcherFactory>();

            requestDisplatcherFactoryMock.Setup(r => r.CreateRequestDispatcher())
            .Returns(asyncRequestDispatcherMock.Object);

            var controller = new AssessmentController(requestDisplatcherFactoryMock.Object,
                                                      new Mock <IResourcesManager>().Object,
                                                      new Mock <IDbConnectionFactory>().Object);

            ActionResult actionResult = null;
            var          wait         = new ManualResetEvent(false);


            // Act
            var task = controller.Create(patientKey, Guid.NewGuid(), workflowKey);

            task.ContinueWith(result =>
            {
                actionResult = result.Result;
                wait.Set();
            });
            wait.WaitOne();


            // Assert
            var redirectToRouteResult = actionResult as RedirectToRouteResult;
            var routes = new RouteCollection();

            RouteConfig.RegisterRoutes(routes);
            RouteTestHelper.AssertRoute(routes, redirectToRouteResult.RouteValues, new { key = assessmentInstanceKey, patientKey, action = "Edit" });
        }
Beispiel #4
0
 public void WhenHeClicksOnCreateButton()
 {
     _result = _controller.Create(_assessmentModel);
 }