public async Task TheTheRepositoryShouldBeCalledToRetrieveData() { //Arrange var request = new GetDataLockRequest(); //Act await _handler.Handle(request); //Assert _dataLockRepository.Verify(x => x.GetDataLock(It.IsAny <long>()), Times.Once); }
public async Task ThenTheRequestShouldBeValidated() { //Arrange var request = new GetDataLockRequest(); //Act await _handler.Handle(request); //Assert _validator.Verify(x => x.Validate(It.IsAny <GetDataLockRequest>()), Times.Once); }
public void ThenApprenticeshipIdMustBeSpecified() { //Arrange var request = new GetDataLockRequest(); //Act var result = _validator.Validate(request); //Arrange Assert.IsFalse(result.IsValid); Assert.IsTrue(result.Errors.Any(x => x.PropertyName.Contains( nameof(GetDataLockRequest.ApprenticeshipId)))); }
public async Task ThenTheResultShouldBeMapped() { //Arrange var dataLockStatus = new DataLockStatus { DataLockEventId = 1L, DataLockEventDatetime = new DateTime(2018, 3, 1), PriceEpisodeIdentifier = "PRICE_EPISODE_ID", ApprenticeshipId = 999L, IlrTrainingCourseCode = "TRAINING_COURSE_CODE", IlrTrainingType = TrainingType.Framework, IlrActualStartDate = new DateTime(2018, 1, 1), IlrEffectiveFromDate = new DateTime(2018, 12, 31), IlrTotalCost = decimal.One, Status = Status.Fail, TriageStatus = TriageStatus.Change, ErrorCode = DataLockErrorCode.Dlock01 }; _dataLockRepository.Setup(x => x.GetDataLock(It.IsAny <long>())) .ReturnsAsync(dataLockStatus); var request = new GetDataLockRequest { ApprenticeshipId = 999L, DataLockEventId = 1L }; //Act var result = await _handler.Handle(request); //Assert var dataLockResult = result.Data; Assert.AreEqual(dataLockStatus.DataLockEventId, dataLockResult.DataLockEventId); Assert.AreEqual(dataLockStatus.DataLockEventDatetime, dataLockResult.DataLockEventDatetime); Assert.AreEqual(dataLockStatus.PriceEpisodeIdentifier, dataLockResult.PriceEpisodeIdentifier); Assert.AreEqual(dataLockStatus.ApprenticeshipId, dataLockResult.ApprenticeshipId); Assert.AreEqual(dataLockStatus.IlrTrainingCourseCode, dataLockResult.IlrTrainingCourseCode); Assert.AreEqual(dataLockStatus.IlrTrainingType, (TrainingType)dataLockResult.IlrTrainingType); Assert.AreEqual(dataLockStatus.IlrActualStartDate, dataLockResult.IlrActualStartDate); Assert.AreEqual(dataLockStatus.IlrEffectiveFromDate, dataLockResult.IlrEffectiveFromDate); Assert.AreEqual(dataLockStatus.IlrTotalCost, dataLockResult.IlrTotalCost); Assert.AreEqual(dataLockStatus.Status, (Status)dataLockResult.Status); Assert.AreEqual(dataLockStatus.TriageStatus, (TriageStatus)dataLockResult.TriageStatus); Assert.AreEqual(dataLockStatus.ErrorCode, (DataLockErrorCode)dataLockResult.ErrorCode); }
public void ThenIfTheDataLockDoesNotBelongToTheApprenticeshipThenAnExceptionIsThrown() { //Arrange var request = new GetDataLockRequest { ApprenticeshipId = 1, DataLockEventId = 2 }; _dataLockRepository.Setup(x => x.GetDataLock(It.IsAny <long>())) .ReturnsAsync(new DataLockStatus { DataLockEventId = 2, ApprenticeshipId = 3 }); //Act & Assert Func <Task> act = async() => await _handler.Handle(request); act.ShouldThrow <ValidationException>(); }