public void CreatePOST_GivenValidModel_WorkflowHandlerShouldBeCalled() { var model = new AssessmentViewModel(); var assessmentCommand = new AddAssessmentCommand(); A.CallTo(() => _assessmentBuilder.BuildAddAssessmentCommand(model)).Returns(assessmentCommand); _assessmentController.Create(model); A.CallTo(() => _workflowHandler.SetAssessmentWorkflow(assessmentCommand)).MustHaveHappened(Repeated.Exactly.Once); }
public void SetAssessmentWorkflow(AddAssessmentCommand command) { var currentWorkflowVersion = _queryDispatcher.Dispatch <CurrentWorkflowQuery, WorkflowVersion>(new CurrentWorkflowQuery()); command.WorkflowVersionId = currentWorkflowVersion.WorkflowVersionId; command.CurrentWorkflowQuestionId = currentWorkflowVersion.InitialWorkflowQuestionId; _commandDispatcher.Dispatch(command); SaveChanges(); }
public void Execute_GivenAddAssessmentCommand_AssessmentShouldBeAddedToContext() { var fakeContext = A.Fake <DbContext>(); var set = A.Fake <DbSet <Assessment> >(); var workflowVersionId = Guid.NewGuid(); var initialQuestion = Guid.NewGuid(); var assessmentId = Guid.NewGuid(); var patientId = Guid.NewGuid(); var assessmentCommand = new AddAssessmentCommand() { AssessmentId = assessmentId, DateAssessmentStarted = new DateTime(2015, 01, 01), Stage1DecisionToBeMade = "decision", Stage1DecisionClearlyMade = true, Stage1DecisionConfirmation = "confirmation", Stage1InfoText = "info", WorkflowVersionId = workflowVersionId, CurrentWorkflowQuestionId = initialQuestion, StatusId = 1, PatientId = patientId }; A.CallTo(() => _unitOfWork.Context).Returns(fakeContext); A.CallTo(() => fakeContext.Set <Assessment>()).Returns(set); A.CallTo(() => _activeDirectoryPrincipalProvider.DisplayNameForCurrentUser()).Returns("user"); _handler.Execute(assessmentCommand); A.CallTo(() => fakeContext.Set <Assessment>().Add(A <Assessment> .That.Matches( x => x.DateAssessmentStarted.Equals(new DateTime(2015, 01, 01)) && x.Stage1DecisionClearlyMade && x.Stage1DecisionToBeMade == "decision" && x.Stage1DecisionConfirmation == "confirmation" && x.Stage1InfoText == "info" && x.WorkflowVersionId == workflowVersionId && x.CurrentWorkflowQuestionId == initialQuestion && x.StatusId == 1 && x.AssessorName == "user" && x.AssessmentId == assessmentId && x.PatientId == patientId))).MustHaveHappened(Repeated.Exactly.Once); }