public void TestUseCaseMakesAppropriateCallsToOurGateways()
        {
            _caseStatusesUseCase.ExecuteUpdate(_updateCaseStatusRequest);

            _mockCaseStatusGateway.Verify(x => x.GetCasesStatusByCaseStatusId(_caseStatus.Id), Times.Once);
            _mockCaseStatusGateway.Verify(x => x.UpdateCaseStatus(_updateCaseStatusRequest), Times.Once);
            _mockDatabaseGateway.Verify(x => x.GetWorkerByEmail(_worker.Email), Times.Once);
        }
コード例 #2
0
        public void WhenTypeIsCINandEndDateIsNotProvidedAndStartDateIsIntheFutureItThrowsInvalidStartDateException()
        {
            _updateCaseStatusRequest.StartDate = DateTime.Now.AddDays(1);
            _updateCaseStatusRequest.EndDate   = null;
            _caseStatus.Type = "CIN";

            _mockCaseStatusGateway.Setup(x => x.GetCasesStatusByCaseStatusId(_caseStatus.Id)).Returns(_caseStatus.ToDomain());

            Action act = () => _caseStatusesUseCase.ExecuteUpdate(_updateCaseStatusRequest);

            act.Should().Throw <InvalidStartDateException>()
            .WithMessage("Invalid start date. It cannot be in the future.");
        }
        public void WhenTypeIsLACAndProvidedEndIsBeforeTheCurrentlyActiveAnswersStartDateItThrowsInvalidEndDateException()
        {
            _caseStatus         = TestHelpers.CreateCaseStatus(resident: _resident, startDate: DateTime.Now.AddDays(1), type: "LAC");
            _caseStatus.Answers = new List <CaseStatusAnswer>();
            _caseStatus.Answers.AddRange(TestHelpers.CreateCaseStatusAnswers(min: 2, max: 2, startDate: new DateTime(2021, 11, 3)));

            _updateCaseStatusRequest = TestHelpers.CreateUpdateCaseStatusRequest(caseStatusId: _caseStatus.Id, email: _worker.Email, endDate: new DateTime(2021, 11, 1), min: 1, max: 1);

            _mockCaseStatusGateway
            .Setup(x => x.GetCasesStatusByCaseStatusId(_caseStatus.Id))
            .Returns(_caseStatus.ToDomain());

            _mockCaseStatusGateway.Setup(x => x.UpdateCaseStatus(It.IsAny <UpdateCaseStatusRequest>())).Returns(new DomainCaseStatus());

            Action act = () => _caseStatusesUseCase.ExecuteUpdate(_updateCaseStatusRequest);

            act.Should().Throw <InvalidEndDateException>()
            .WithMessage("requested end date is before the start date of the currently active answer");
        }