public void SetUp() { //Arrange var autoFixture = new Fixture(); _request = autoFixture.Build <ApprenticeshipDetailsRequest>() .With(x => x.AccountHashedId, "123") .With(x => x.ApprenticeshipHashedId, "456") .Create(); _apprenticeshipResponse = autoFixture.Build <GetApprenticeshipResponse>() .With(x => x.CourseCode, "ABC") .With(x => x.DateOfBirth, autoFixture.Create <DateTime>()) .Create(); _priceEpisodesResponse = autoFixture.Build <GetPriceEpisodesResponse>() .With(x => x.PriceEpisodes, new List <PriceEpisode> { new PriceEpisode { Cost = 1000, ToDate = DateTime.Now.AddMonths(-1) } }) .Create(); _apprenticeshipUpdatesResponse = autoFixture.Build <GetApprenticeshipUpdatesResponse>() .With(x => x.ApprenticeshipUpdates, new List <ApprenticeshipUpdate> { new ApprenticeshipUpdate { OriginatingParty = Party.Employer } }) .Create(); _dataLocksResponse = autoFixture.Build <GetDataLocksResponse>().Create(); _changeOfPartyRequestsResponse = autoFixture.Build <GetChangeOfPartyRequestsResponse>().Create(); _trainingProgrammeResponse = autoFixture.Build <GetTrainingProgrammeResponse>().Create(); _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>(); _mockCommitmentsApiClient.Setup(r => r.GetApprenticeship(It.IsAny <long>(), CancellationToken.None)) .ReturnsAsync(_apprenticeshipResponse); _mockCommitmentsApiClient.Setup(c => c.GetPriceEpisodes(It.IsAny <long>(), CancellationToken.None)) .ReturnsAsync(_priceEpisodesResponse); _mockCommitmentsApiClient.Setup(c => c.GetApprenticeshipUpdates(It.IsAny <long>(), It.IsAny <GetApprenticeshipUpdatesRequest>(), CancellationToken.None)) .ReturnsAsync(_apprenticeshipUpdatesResponse); _mockCommitmentsApiClient.Setup(c => c.GetApprenticeshipDatalocksStatus(It.IsAny <long>(), CancellationToken.None)) .ReturnsAsync(_dataLocksResponse); _mockCommitmentsApiClient.Setup(c => c.GetChangeOfPartyRequests(It.IsAny <long>(), CancellationToken.None)) .ReturnsAsync(_changeOfPartyRequestsResponse); _mockCommitmentsApiClient.Setup(t => t.GetTrainingProgramme(_apprenticeshipResponse.CourseCode, It.IsAny <CancellationToken>())) .ReturnsAsync(_trainingProgrammeResponse); _mockEncodingService = new Mock <IEncodingService>(); _mapper = new ApprenticeshipDetailsRequestToViewModelMapper(_mockCommitmentsApiClient.Object, _mockEncodingService.Object, Mock.Of <ILogger <ApprenticeshipDetailsRequestToViewModelMapper> >()); }
public void SetUp() { //Arrange _request = autoFixture.Build <ApprenticeshipDetailsRequest>() .With(x => x.AccountHashedId, $"A123") .With(x => x.ApprenticeshipHashedId, $"A{ApprenticeshipIdFirst}") .Create(); _apprenticeshipResponse = autoFixture.Build <GetApprenticeshipResponse>() .With(x => x.Id, ApprenticeshipIdFirst) .With(x => x.CourseCode, "123") .With(x => x.StandardUId, "ST0001_1.0") .With(x => x.Version, "1.0") .With(x => x.DateOfBirth, autoFixture.Create <DateTime>()) .Create(); _priceEpisodesResponse = autoFixture.Build <GetPriceEpisodesResponse>() .With(x => x.PriceEpisodes, new List <PriceEpisode> { new PriceEpisode { Cost = 1000, ToDate = DateTime.Now.AddMonths(-1) } }) .Create(); _apprenticeshipUpdatesResponse = autoFixture.Build <GetApprenticeshipUpdatesResponse>() .With(x => x.ApprenticeshipUpdates, new List <ApprenticeshipUpdate> { new ApprenticeshipUpdate { OriginatingParty = Party.Employer } }) .Create(); _dataLocksResponse = autoFixture.Build <GetDataLocksResponse>().Create(); _changeOfPartyRequestsResponse = autoFixture.Build <GetChangeOfPartyRequestsResponse>().Create(); var trainingProgrammeByStandardUId = autoFixture.Build <TrainingProgramme>() .With(x => x.CourseCode, _apprenticeshipResponse.CourseCode) .With(x => x.StandardUId, "ST0001_1.0") .With(x => x.Version, "1.0") .Create(); _getTrainingProgrammeByStandardUId = new GetTrainingProgrammeResponse { TrainingProgramme = trainingProgrammeByStandardUId }; var framework = autoFixture.Build <TrainingProgramme>() .Without(x => x.Version) .Without(x => x.StandardUId) .With(x => x.CourseCode, "1-2-3") .Create(); _getTrainingProgrammeResponse = new GetTrainingProgrammeResponse { TrainingProgramme = framework }; var trainingProgrammeVersions = autoFixture.Build <TrainingProgramme>().CreateMany(2).ToList(); trainingProgrammeVersions[0].Version = "1.1"; trainingProgrammeVersions[1].Version = "1.2"; _newerTrainingProgrammeVersionsResponse = autoFixture.Build <GetNewerTrainingProgrammeVersionsResponse>() .With(x => x.NewerVersions, trainingProgrammeVersions).Create(); _changeOfProviderChainReponse = autoFixture.Build <GetChangeOfProviderChainResponse>().Create(); _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>(); _mockCommitmentsApiClient.Setup(r => r.GetApprenticeship(It.IsAny <long>(), CancellationToken.None)) .ReturnsAsync(_apprenticeshipResponse); _mockCommitmentsApiClient.Setup(c => c.GetPriceEpisodes(It.IsAny <long>(), CancellationToken.None)) .ReturnsAsync(_priceEpisodesResponse); _mockCommitmentsApiClient.Setup(c => c.GetApprenticeshipUpdates(It.IsAny <long>(), It.IsAny <GetApprenticeshipUpdatesRequest>(), CancellationToken.None)) .ReturnsAsync(_apprenticeshipUpdatesResponse); _mockCommitmentsApiClient.Setup(c => c.GetApprenticeshipDatalocksStatus(It.IsAny <long>(), CancellationToken.None)) .ReturnsAsync(_dataLocksResponse); _mockCommitmentsApiClient.Setup(c => c.GetChangeOfPartyRequests(It.IsAny <long>(), CancellationToken.None)) .ReturnsAsync(_changeOfPartyRequestsResponse); _mockCommitmentsApiClient.Setup(t => t.GetNewerTrainingProgrammeVersions(It.IsAny <string>(), It.IsAny <CancellationToken>())) .ReturnsAsync(_newerTrainingProgrammeVersionsResponse); _mockCommitmentsApiClient.Setup(t => t.GetChangeOfProviderChain(It.IsAny <long>(), CancellationToken.None)) .ReturnsAsync(_changeOfProviderChainReponse); _mockCommitmentsApiClient.Setup(c => c.GetTrainingProgrammeVersionByStandardUId(It.IsAny <string>(), CancellationToken.None)) .ReturnsAsync(_getTrainingProgrammeByStandardUId); _mockCommitmentsApiClient.Setup(c => c.GetTrainingProgramme(It.IsAny <string>(), CancellationToken.None)) .ReturnsAsync(_getTrainingProgrammeResponse); _mockEncodingService = new Mock <IEncodingService>(); _mockEncodingService.Setup(t => t.Encode(It.IsAny <long>(), It.IsAny <EncodingType>())) .Returns((long value, EncodingType encodingType) => $"A{value}"); _mockEncodingService.Setup(t => t.Decode(It.IsAny <string>(), It.IsAny <EncodingType>())) .Returns((string value, EncodingType encodingType) => long.Parse(Regex.Replace(value, "[A-Za-z ]", ""))); _mapper = new ApprenticeshipDetailsRequestToViewModelMapper(_mockCommitmentsApiClient.Object, _mockEncodingService.Object, Mock.Of <ILogger <ApprenticeshipDetailsRequestToViewModelMapper> >()); }