コード例 #1
0
        public void PriceDataLock_IsMapped()
        {
            //Act
            _dataLocksWithPriceMismatch = new List <DataLock>
            {
                new DataLock {
                    IsResolved           = false,
                    DataLockStatus       = Status.Fail,
                    ErrorCode            = DataLockErrorCode.Dlock07,
                    IlrEffectiveFromDate = DateTime.Now.Date.AddDays(7),
                    ApprenticeshipId     = 123,
                    IlrTotalCost         = 1500.00M
                }
            };
            _dataLockSummariesResponse = _fixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithOnlyPriceMismatch, _dataLocksWithPriceMismatch)
                                         .Create();

            var result = _priceEpisodesResponse.PriceEpisodes.MapPriceDataLock(_dataLockSummariesResponse.DataLocksWithOnlyPriceMismatch);

            //Assert
            var priceDataLock = result.FirstOrDefault();

            Assert.AreEqual(_priceEpisodes.FirstOrDefault().FromDate, priceDataLock.CurrentStartDate);
            Assert.AreEqual(null, priceDataLock.CurrentEndDate);
            Assert.AreEqual(_priceEpisodes.FirstOrDefault().Cost, priceDataLock.CurrentCost);
            Assert.AreEqual(_dataLockSummariesResponse.DataLocksWithOnlyPriceMismatch.FirstOrDefault().IlrEffectiveFromDate, priceDataLock.IlrEffectiveFromDate);
            Assert.AreEqual(null, priceDataLock.IlrEffectiveToDate);
            Assert.AreEqual(_dataLockSummariesResponse.DataLocksWithOnlyPriceMismatch.FirstOrDefault().IlrTotalCost, priceDataLock.IlrTotalCost);
        }
コード例 #2
0
        public void CourseDataLock_IsMapped()
        {
            //Arrange
            _dataLocksWithCourseMismatch = new List <DataLock>
            {
                new DataLock {
                    IsResolved            = false,
                    DataLockStatus        = Status.Fail,
                    ErrorCode             = DataLockErrorCode.Dlock04,
                    IlrEffectiveFromDate  = DateTime.Now.Date.AddDays(7),
                    IlrTrainingCourseCode = "548"
                }
            };

            _dataLockSummariesResponse = _fixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithCourseMismatch, _dataLocksWithCourseMismatch)
                                         .With(x => x.DataLocksWithOnlyPriceMismatch, _dataLocksWithPriceMismatch)
                                         .Create();

            //Act
            var dataLockSummary = _dataLockSummariesResponse.MapDataLockSummary(_allTrainingProgrammeResponse);
            var result          = _apprenticeshipResponse.MapCourseDataLock(dataLockSummary.DataLockWithCourseMismatch, _priceEpisodes);

            //Assert
            var courseDataLock = result.FirstOrDefault();

            Assert.AreEqual(_priceEpisodes.FirstOrDefault().FromDate, courseDataLock.CurrentStartDate);
            Assert.AreEqual(null, courseDataLock.CurrentEndDate);
            Assert.AreEqual(_apprenticeshipResponse.CourseName, courseDataLock.CurrentTrainingName);
            Assert.AreEqual(dataLockSummary.DataLockWithCourseMismatch.FirstOrDefault().IlrEffectiveFromDate, courseDataLock.IlrEffectiveFromDate);
            Assert.AreEqual(null, courseDataLock.IlrEffectiveToDate);
            Assert.AreEqual(_allTrainingProgrammeResponse.TrainingProgrammes.FirstOrDefault().Name, courseDataLock.IlrTrainingName);
        }
コード例 #3
0
        public void Multiple_CourseDataLocks_AreMapped()
        {
            //Arrange
            _dataLocksWithCourseMismatch = new List <DataLock>
            {
                new DataLock {
                    IsResolved            = false,
                    DataLockStatus        = Status.Fail,
                    ErrorCode             = DataLockErrorCode.Dlock04,
                    IlrEffectiveFromDate  = DateTime.Now.Date.AddDays(7),
                    ApprenticeshipId      = 123,
                    IlrTrainingCourseCode = "548"
                },
                new DataLock {
                    IsResolved            = false,
                    DataLockStatus        = Status.Fail,
                    ErrorCode             = DataLockErrorCode.Dlock05,
                    IlrEffectiveFromDate  = DateTime.Now.Date.AddDays(7),
                    ApprenticeshipId      = 123,
                    IlrTrainingCourseCode = "548"
                }
            };
            _dataLockSummariesResponse = _fixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithCourseMismatch, _dataLocksWithCourseMismatch)
                                         .Create();

            //Act
            var dataLockSummary = _dataLockSummariesResponse.MapDataLockSummary(_allTrainingProgrammeResponse);
            var result          = _apprenticeshipResponse.MapCourseDataLock(dataLockSummary.DataLockWithCourseMismatch, _priceEpisodes);

            //Assert
            Assert.AreEqual(2, result.Count());
        }
コード例 #4
0
        public async Task Course_Datalock_Mismatch_IsMapped()
        {
            //Arrange
            _dataLocksWithCourseMismatch = new List <DataLock>
            {
                new DataLock {
                    IsResolved            = false,
                    DataLockStatus        = Status.Fail,
                    ErrorCode             = DataLockErrorCode.Dlock04,
                    IlrEffectiveFromDate  = DateTime.Now.Date.AddDays(7),
                    ApprenticeshipId      = 123,
                    IlrTrainingCourseCode = "548"
                }
            };
            _dataLockSummariesResponse = _fixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithCourseMismatch, _dataLocksWithCourseMismatch)
                                         .Create();

            _mockCommitmentsApiClient.Setup(m => m.GetApprenticeshipDatalockSummariesStatus(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_dataLockSummariesResponse);

            //Act
            var result = await _mapper.Map(_updateDataLockRequest);

            //Assert
            Assert.AreEqual(1, result.CourseDataLocks.Count());
            Assert.AreEqual(result.CourseDataLocks.FirstOrDefault().CurrentTrainingName, _apprenticeshipResponse.CourseName);
            Assert.AreEqual(result.CourseDataLocks.FirstOrDefault().CurrentEndDate, _priceEpisodes.FirstOrDefault().ToDate);
            Assert.AreEqual(result.CourseDataLocks.FirstOrDefault().IlrTrainingName, _allTrainingProgrammesResponse.TrainingProgrammes.FirstOrDefault().Name);
            Assert.AreEqual(result.CourseDataLocks.FirstOrDefault().IlrEffectiveFromDate, _dataLockSummariesResponse.DataLocksWithCourseMismatch.FirstOrDefault().IlrEffectiveFromDate);
        }
        public void Arrange()
        {
            var _autoFixture = new Fixture();

            _confirmDataLockChangesRequest = _autoFixture.Create <ConfirmDataLockChangesRequest>();

            DataLocksWithCourseMismatch = new List <DataLock>
            {
                new DataLock
                {
                    IsResolved            = false,
                    DataLockStatus        = Status.Fail,
                    ErrorCode             = DataLockErrorCode.Dlock04,
                    IlrTrainingCourseCode = "454-3-1",
                    IlrEffectiveFromDate  = DateTime.Now.Date.AddDays(15)
                }
            };
            _getDataLockSummariesResponse = _autoFixture.Build <GetDataLockSummariesResponse>().With(x => x.DataLocksWithCourseMismatch, DataLocksWithCourseMismatch).Create();

            _getApprenticeshipResponse = _autoFixture.Build <GetApprenticeshipResponse>()
                                         .With(p => p.CourseCode, "111")
                                         .With(p => p.CourseName, "Training 111")
                                         .With(p => p.EndDate, DateTime.Now.Date.AddDays(100))
                                         .Create();


            TrainingProgrammes = new List <TrainingProgramme>
            {
                new TrainingProgramme {
                    CourseCode = "454-3-1", ProgrammeType = ProgrammeType.Standard, Name = "Training 111"
                }
            };
            _getAllTrainingProgrammesResponse = _autoFixture.Build <GetAllTrainingProgrammesResponse>().With(x => x.TrainingProgrammes, TrainingProgrammes).Create();

            PriceEpisodes.Add(new PriceEpisode {
                FromDate = DateTime.Now.Date, ToDate = null, Cost = 1000.0M
            });
            _getPriceEpisodesResponse = _autoFixture.Build <GetPriceEpisodesResponse>()
                                        .With(x => x.PriceEpisodes, PriceEpisodes)
                                        .Create();


            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _mockCommitmentsApiClient.Setup(m => m.GetApprenticeshipDatalockSummariesStatus(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getDataLockSummariesResponse);
            _mockCommitmentsApiClient.Setup(m => m.GetApprenticeship(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getApprenticeshipResponse);
            _mockCommitmentsApiClient.Setup(m => m.GetAllTrainingProgrammes(It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getAllTrainingProgrammesResponse);
            _mockCommitmentsApiClient.Setup(m => m.GetPriceEpisodes(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getPriceEpisodesResponse);

            _mapper = new ConfirmDataLockChangesViewModelMapper(_mockCommitmentsApiClient.Object);
        }
コード例 #6
0
        public DataLockRequestChangesRequestToViewModelMapperTestsFixture()
        {
            // Arrange
            AutoFixture = new Fixture();
            _request    = AutoFixture.Build <DataLockRequestChangesRequest>()
                          .With(x => x.AccountHashedId, "123")
                          .With(x => x.ApprenticeshipHashedId, "456")
                          .Create();

            _dataLockSummariesResponse = AutoFixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithCourseMismatch, DataLocksWithCourseMismatch)
                                         .With(x => x.DataLocksWithOnlyPriceMismatch, DataLocksWithOnlyPriceMismatch)
                                         .Create();

            PriceEpisodes.Add(new PriceEpisode {
                FromDate = DateTime.Now.Date, ToDate = null, Cost = 1000.0M
            });
            _priceEpisodesResponse = AutoFixture.Build <GetPriceEpisodesResponse>()
                                     .With(x => x.PriceEpisodes, PriceEpisodes)
                                     .Create();

            TrainingProgrammes.Add(new TrainingProgramme {
                CourseCode = "111", ProgrammeType = ProgrammeType.Standard, Name = "Training 111"
            });
            _allTrainingProgrammeResponse = AutoFixture.Build <GetAllTrainingProgrammesResponse>()
                                            .With(x => x.TrainingProgrammes, TrainingProgrammes)
                                            .Create();

            _apprenticeshipResponse = AutoFixture.Build <GetApprenticeshipResponse>()
                                      .With(p => p.CourseCode, "111")
                                      .With(p => p.CourseName, "Training 111")
                                      .With(p => p.EndDate, DateTime.Now.Date.AddDays(100))
                                      .Create();

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();

            _mockCommitmentsApiClient.Setup(r => r.GetApprenticeshipDatalockSummariesStatus(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_dataLockSummariesResponse);

            _mockCommitmentsApiClient.Setup(c => c.GetPriceEpisodes(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_priceEpisodesResponse);

            _mockCommitmentsApiClient.Setup(c => c.GetApprenticeship(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_apprenticeshipResponse);

            _mockCommitmentsApiClient.Setup(t => t.GetAllTrainingProgrammes(It.IsAny <CancellationToken>()))
            .ReturnsAsync(_allTrainingProgrammeResponse);

            _mapper = new DataLockRequestChangesRequestToViewModelMapper(_mockCommitmentsApiClient.Object);
        }
コード例 #7
0
        public DataLockRequestChangesRequestToViewModelMapperTestsFixture WithPriceDataLock()
        {
            DataLocksWithOnlyPriceMismatch.Add(
                new DataLock {
                IsResolved = false, DataLockStatus = Status.Fail, ErrorCode = DataLockErrorCode.Dlock07
            });

            _dataLockSummariesResponse = AutoFixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithCourseMismatch, DataLocksWithCourseMismatch)
                                         .With(x => x.DataLocksWithOnlyPriceMismatch, DataLocksWithOnlyPriceMismatch)
                                         .Create();

            _mockCommitmentsApiClient.Setup(r => r.GetApprenticeshipDatalockSummariesStatus(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_dataLockSummariesResponse);

            return(this);
        }
コード例 #8
0
        public void Multiple_PriceDataLocks_AreMapped()
        {
            //Arrange
            _dataLocksWithPriceMismatch = new List <DataLock>
            {
                new DataLock
                {
                    IsResolved           = false,
                    DataLockStatus       = Status.Fail,
                    ErrorCode            = DataLockErrorCode.Dlock07,
                    IlrEffectiveFromDate = DateTime.Now.Date.AddDays(7),
                    ApprenticeshipId     = 123,
                    IlrTotalCost         = 1500.00M
                },
                new DataLock {
                    IsResolved           = false,
                    DataLockStatus       = Status.Fail,
                    ErrorCode            = DataLockErrorCode.Dlock07,
                    IlrEffectiveFromDate = DateTime.Now.Date.AddDays(7),
                    ApprenticeshipId     = 123,
                    IlrTotalCost         = 1300.00M
                }
            };
            _dataLockSummariesResponse = _fixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithOnlyPriceMismatch, _dataLocksWithPriceMismatch)
                                         .Create();

            _priceEpisodes = new List <PriceEpisode>
            {
                new PriceEpisode {
                    ApprenticeshipId = 123, FromDate = DateTime.Now.Date, ToDate = null, Cost = 1000.0M
                },
                new PriceEpisode {
                    ApprenticeshipId = 123, FromDate = DateTime.Now.Date, ToDate = null, Cost = 1200.0M
                }
            };
            _priceEpisodesResponse = _fixture.Build <GetPriceEpisodesResponse>()
                                     .With(x => x.PriceEpisodes, _priceEpisodes)
                                     .Create();

            //Act
            var result = _priceEpisodesResponse.PriceEpisodes.MapPriceDataLock(_dataLockSummariesResponse.DataLocksWithOnlyPriceMismatch);

            //Assert
            Assert.AreEqual(2, result.Count());
        }
        public static UpdateDateLockSummaryViewModel MapDataLockSummary(this GetDataLockSummariesResponse dataLockSummaries, GetAllTrainingProgrammesResponse trainingProgrammes)
        {
            var result = new UpdateDateLockSummaryViewModel
            {
                DataLockWithCourseMismatch = new List <DataLockViewModel>(),
            };

            foreach (var dataLock in dataLockSummaries.DataLocksWithCourseMismatch)
            {
                var training = trainingProgrammes.TrainingProgrammes.SingleOrDefault(x => x.CourseCode == dataLock.IlrTrainingCourseCode);
                if (training == null)
                {
                    throw new InvalidOperationException(
                              $"Datalock {dataLock.Id} IlrTrainingCourseCode {dataLock.IlrTrainingCourseCode} not found; possible expiry");
                }
                result.DataLockWithCourseMismatch.Add(MapDataLockStatus(dataLock, training));
            }

            return(result);
        }
コード例 #10
0
        public void DataLockSummary_Throws_Exception_If_DataLock_CourseCode_Not_Exists()
        {
            //Arrange
            _dataLocksWithCourseMismatch = new List <DataLock>
            {
                new DataLock {
                    IsResolved = false, DataLockStatus = Status.Fail, ErrorCode = DataLockErrorCode.Dlock04
                }
            };

            _dataLockSummariesResponse = _fixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithCourseMismatch, _dataLocksWithCourseMismatch)
                                         .Create();

            var expectedMessage = $"Datalock {_dataLockSummariesResponse.DataLocksWithCourseMismatch.FirstOrDefault().Id} IlrTrainingCourseCode {_dataLockSummariesResponse.DataLocksWithCourseMismatch.FirstOrDefault().IlrTrainingCourseCode} not found; possible expiry";

            //Act
            var exception = Assert.Throws <InvalidOperationException>(() => _dataLockSummariesResponse.MapDataLockSummary(_allTrainingProgrammeResponse));

            //Assert
            Assert.AreEqual(expectedMessage, exception.Message);
        }
コード例 #11
0
        public void DataLockSummary_IsMapped()
        {
            //Arrange
            _dataLocksWithCourseMismatch = new List <DataLock>
            {
                new DataLock {
                    IsResolved            = false,
                    DataLockStatus        = Status.Fail,
                    ErrorCode             = DataLockErrorCode.Dlock04,
                    IlrTrainingCourseCode = "548"
                }
            };

            _dataLockSummariesResponse = _fixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithCourseMismatch, _dataLocksWithCourseMismatch)
                                         .Create();

            //Act
            var result = _dataLockSummariesResponse.MapDataLockSummary(_allTrainingProgrammeResponse);

            //Assert
            Assert.AreEqual(1, result.DataLockWithCourseMismatch.Count());
        }
コード例 #12
0
        public DataLockRequestChangesRequestToViewModelMapperTestsFixture WithCourseAndPriceDataLock(DateTime IlrEffectiveFromDate, decimal totalCost, string ilrTrainingCourseCode, TriageStatus triageStatus, DataLockErrorCode courseDataLockErrorCode)
        {
            DataLocksWithCourseMismatch.Add(
                new DataLock
            {
                IsResolved            = false,
                DataLockStatus        = Status.Fail,
                IlrEffectiveFromDate  = IlrEffectiveFromDate,
                IlrTotalCost          = totalCost,
                IlrTrainingCourseCode = ilrTrainingCourseCode,
                TriageStatus          = triageStatus,
                ErrorCode             = courseDataLockErrorCode | DataLockErrorCode.Dlock07
            });

            _dataLockSummariesResponse = AutoFixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithCourseMismatch, DataLocksWithCourseMismatch)
                                         .With(x => x.DataLocksWithOnlyPriceMismatch, DataLocksWithOnlyPriceMismatch)
                                         .Create();

            _mockCommitmentsApiClient.Setup(r => r.GetApprenticeshipDatalockSummariesStatus(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_dataLockSummariesResponse);

            return(this);
        }
コード例 #13
0
        public async Task Multiple_Price_Datalock_Mismatch_IsMapped()
        {
            //Arrange
            _dataLocksWithPriceMismatch = new List <DataLock>
            {
                new DataLock {
                    IsResolved           = false,
                    DataLockStatus       = Status.Fail,
                    ErrorCode            = DataLockErrorCode.Dlock07,
                    IlrEffectiveFromDate = DateTime.Now.Date.AddDays(7),
                    ApprenticeshipId     = 123,
                    IlrTotalCost         = 1500.00M
                },
                new DataLock {
                    IsResolved           = false,
                    DataLockStatus       = Status.Fail,
                    ErrorCode            = DataLockErrorCode.Dlock07,
                    IlrEffectiveFromDate = DateTime.Now.Date.AddDays(7),
                    ApprenticeshipId     = 123,
                    IlrTotalCost         = 1300.00M
                }
            };
            _dataLockSummariesResponse = _fixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithCourseMismatch, _dataLocksWithCourseMismatch)
                                         .With(x => x.DataLocksWithOnlyPriceMismatch, _dataLocksWithPriceMismatch)
                                         .Create();

            _mockCommitmentsApiClient.Setup(m => m.GetApprenticeshipDatalockSummariesStatus(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_dataLockSummariesResponse);

            //Act
            var result = await _mapper.Map(_updateDataLockRequest);

            //Assert
            Assert.AreEqual(2, result.PriceDataLocks.Count());
        }
コード例 #14
0
        public void Arrange()
        {
            _fixture = new Fixture();

            _updateDataLockRequest      = _fixture.Create <UpdateDateLockRequest>();
            _dataLocksWithPriceMismatch = new List <DataLock>
            {
                new DataLock
                {
                    IsResolved           = false,
                    DataLockStatus       = Status.Fail,
                    ErrorCode            = DataLockErrorCode.Dlock07,
                    IlrEffectiveFromDate = DateTime.Now.Date.AddDays(7),
                    ApprenticeshipId     = 123,
                    IlrTotalCost         = 1500.00M
                }
            };

            _dataLocksWithCourseMismatch = new List <DataLock>
            {
                new DataLock
                {
                    IsResolved            = false,
                    DataLockStatus        = Status.Fail,
                    ErrorCode             = DataLockErrorCode.Dlock04,
                    IlrTrainingCourseCode = "548",
                    IlrEffectiveFromDate  = DateTime.Now.Date.AddDays(15)
                }
            };

            _dataLockSummariesResponse = _fixture.Build <GetDataLockSummariesResponse>()
                                         .With(x => x.DataLocksWithCourseMismatch, _dataLocksWithCourseMismatch)
                                         .With(x => x.DataLocksWithOnlyPriceMismatch, _dataLocksWithPriceMismatch)
                                         .Create();

            _apprenticeshipResponse = _fixture.Build <GetApprenticeshipResponse>()
                                      .With(p => p.CourseCode, "548")
                                      .With(p => p.CourseName, "DevOps engineer")
                                      .With(p => p.HasHadDataLockSuccess, false)
                                      .With(p => p.EndDate, DateTime.Now.Date.AddDays(100))
                                      .Create();

            _trainingProgrammes = new List <TrainingProgramme>
            {
                new TrainingProgramme {
                    CourseCode = "548", ProgrammeType = ProgrammeType.Standard, Name = "DevOps engineer"
                }
            };
            _allTrainingProgrammesResponse = _fixture.Build <GetAllTrainingProgrammesResponse>().With(x => x.TrainingProgrammes, _trainingProgrammes).Create();

            _priceEpisodes = new List <PriceEpisode>
            {
                new PriceEpisode {
                    FromDate = DateTime.Now.Date, ToDate = null, Cost = 1000.0M
                }
            };
            _priceEpisodesResponse = _fixture.Build <GetPriceEpisodesResponse>()
                                     .With(x => x.PriceEpisodes, _priceEpisodes)
                                     .Create();

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _mockCommitmentsApiClient.Setup(m => m.GetApprenticeshipDatalockSummariesStatus(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_dataLockSummariesResponse);
            _mockCommitmentsApiClient.Setup(m => m.GetApprenticeship(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_apprenticeshipResponse);
            _mockCommitmentsApiClient.Setup(m => m.GetAllTrainingProgrammes(It.IsAny <CancellationToken>()))
            .ReturnsAsync(_allTrainingProgrammesResponse);
            _mockCommitmentsApiClient.Setup(m => m.GetPriceEpisodes(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_priceEpisodesResponse);

            _mapper = new UpdateDataLockRequestViewModelMapper(_mockCommitmentsApiClient.Object);
        }