public CreateApprenticeshipParameters MapFromRequest(CreateApprenticeshipRequest request, EmployerInformation employerInformation) { var parameters = new CreateApprenticeshipParameters { Title = request.Title, ShortDescription = request.ShortDescription, Description = request.LongDescription, ApplicationClosingDate = request.ApplicationClosingDate.Date, DesiredSkills = request.DesiredSkills, DesiredPersonalQualities = request.DesiredPersonalQualities, DesiredQualifications = request.DesiredQualifications, FutureProspects = request.FutureProspects, ThingsToConsider = request.ThingsToConsider, TrainingToBeProvided = request.TrainingToBeProvided, DurationValue = request.ExpectedDuration, DurationTypeId = (int)_durationMapper.MapTypeToDomainType(request.DurationType), ExpectedStartDate = request.ExpectedStartDate.Date, WorkingWeek = request.WorkingWeek, HoursPerWeek = request.HoursPerWeek, WageType = (int)_wageTypeMapper.MapToLegacy(request), WageTypeReason = request.WageTypeReason, WageUnitId = (int)request.WageUnit, WeeklyWage = request.FixedWage, WageLowerBound = request.MinWage, WageUpperBound = request.MaxWage, WageText = _wageTextFormatter.GetWageText(request), LocationTypeId = request.LocationType == LocationType.Nationwide ? NationwideLocationType : StandardLocationType, NumberOfPositions = request.NumberOfPositions, VacancyOwnerRelationshipId = employerInformation.VacancyOwnerRelationshipId, EmployerDescription = string.IsNullOrWhiteSpace(request.EmployerDescription) ? employerInformation.EmployerDescription : request.EmployerDescription, EmployerWebsite = string.IsNullOrWhiteSpace(request.EmployerWebsiteUrl) ? employerInformation.EmployerWebsite : request.EmployerWebsiteUrl, ProviderId = employerInformation.ProviderId, ProviderSiteId = employerInformation.ProviderSiteId, ApplyOutsideNAVMS = request.ApplicationMethod == ApplicationMethod.Offline, SupplementaryQuestion1 = request.SupplementaryQuestion1, SupplementaryQuestion2 = request.SupplementaryQuestion2, EmployersRecruitmentWebsite = request.ExternalApplicationUrl, EmployersApplicationInstructions = request.ExternalApplicationInstructions, ContactName = request.ContactName, ContactEmail = request.ContactEmail, ContactNumber = request.ContactNumber, TrainingTypeId = (int)request.TrainingType, ApprenticeshipType = GetApprenticeshipType(request.EducationLevel), IsDisabilityConfident = request.IsEmployerDisabilityConfident.GetValueOrDefault(), AdditionalLocationInformation = request.AdditionalLocationInformation, HistoryUserName = request.UserEmail }; MapLocationFields(request, employerInformation, parameters); MapTrainingCode(request, parameters); return(parameters); }
public async Task WillReturnExpectedEmployer() { const string id = "QWERTYUIOP"; var employer = new EmployerInformation { CompanyNumber = id, CompanyName = "Qwerty Corp", DateOfIncorporation = new DateTime(1999, 5, 8), RegisteredAddress = new Address { Line1 = "1 The Strand", Line2 = "London", PostCode = "N1 2TT" }, CompanyStatus = "active" }; _employerService.Setup(x => x.GetInformation(id)).ReturnsAsync(employer); var response = await _handler.Handle(new GetEmployerInformationRequest { Id = id }); Assert.That(response.CompanyNumber, Is.EqualTo(employer.CompanyNumber)); Assert.That(response.CompanyName, Is.EqualTo(employer.CompanyName)); Assert.That(response.DateOfIncorporation, Is.EqualTo(employer.DateOfIncorporation)); Assert.That(response.AddressLine1, Is.EqualTo(employer.RegisteredAddress.Line1)); Assert.That(response.AddressLine2, Is.EqualTo(employer.RegisteredAddress.Line2)); Assert.That(response.AddressPostcode, Is.EqualTo(employer.RegisteredAddress.PostCode)); Assert.AreEqual(employer.CompanyStatus, response.CompanyStatus); }
public void Setup() { var fixture = new Fixture().Customize(new AutoMoqCustomization()); _createApprenticeshipRequest = fixture.Build <CreateApprenticeshipRequest>() .With(request => request.LocationType, LocationType.OtherLocation) .Create(); _employerInformation = fixture.Create <EmployerInformation>(); var mapper = fixture.Create <CreateApprenticeshipParametersMapper>(); _mappedParameters = mapper.MapFromRequest(_createApprenticeshipRequest, _employerInformation); }
public async Task SetUp() { _fixture = new Fixture().Customize(new AutoMoqCustomization()); _employerInformation = _fixture.Create <EmployerInformation>(); _expectedRefNumber = _fixture.Create <int>(); _expectedParameters = _fixture.Freeze <CreateApprenticeshipParameters>(); _validRequest = _fixture.Create <CreateApprenticeshipRequest>(); _mockValidator = _fixture.Freeze <Mock <IValidator <CreateApprenticeshipRequest> > >(composer => composer.Do(mock => mock .Setup(validator => validator.ValidateAsync(It.IsAny <CreateApprenticeshipRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new ValidationResult()))); _mockVacancyOwnerService = _fixture.Freeze <Mock <IVacancyOwnerService> >(composer => composer.Do(mock => mock .Setup(svc => svc.GetEmployersInformationAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(_employerInformation))); _mockMapper = _fixture.Freeze <Mock <ICreateApprenticeshipParametersMapper> >(composer => composer.Do(mock => mock .Setup(mapper => mapper.MapFromRequest(It.IsAny <CreateApprenticeshipRequest>(), It.IsAny <EmployerInformation>())) .Returns(_expectedParameters))); _mockService = _fixture.Freeze <Mock <ICreateApprenticeshipService> >(composer => composer.Do(mock => mock .Setup(repository => repository.CreateApprenticeshipAsync(It.IsAny <CreateApprenticeshipParameters>())) .ReturnsAsync(_expectedRefNumber))); _trainingDetails = new List <TrainingDetail>() { new TrainingDetail() { TrainingCode = _validRequest.TrainingCode, Level = 1 } }; _mockTrainingDetailService = _fixture.Freeze <Mock <ITrainingDetailService> >(composer => composer.Do(mock => { mock .Setup(svc => svc.GetAllFrameworkDetailsAsync()) .ReturnsAsync(_trainingDetails); mock .Setup(svc => svc.GetAllStandardDetailsAsync()) .ReturnsAsync(_trainingDetails); })); _handler = _fixture.Create <CreateApprenticeshipCommandHandler>(); _createApprenticeshipResponse = await _handler.Handle(_validRequest); }
private XmlElement createDocumentEmployerInformation(SubsidyControl subsidyControl) { EmployerInformation employerInformation = new EmployerInformation { EmployerID = subsidyControl.employerIdCard, EmployerName = subsidyControl.employerName, EmployerPosition = subsidyControl.employerPosition }; XmlSerializerNamespaces xmlSerializerNamespaces = new XmlSerializerNamespaces(); xmlSerializerNamespaces.Add("", ""); XmlDocument xmlDocument = new XmlDocument(); XmlSerializer xmlSerializer = new XmlSerializer(typeof(EmployerInformation)); using (XmlWriter writer = xmlDocument.CreateNavigator().AppendChild()) { xmlSerializer.Serialize(writer, employerInformation, xmlSerializerNamespaces); } //xmlDoc.AppendChild(xmlDoc.OwnerDocument.ImportNode(xmlDocument.DocumentElement, true)); return(xmlDocument.DocumentElement); }
private static void MapLocationFields(CreateApprenticeshipRequest request, EmployerInformation employerInformation, CreateApprenticeshipParameters parameters) { if (request.LocationType == LocationType.OtherLocation) { parameters.AddressLine1 = request.AddressLine1; parameters.AddressLine2 = request.AddressLine2; parameters.AddressLine3 = request.AddressLine3; parameters.AddressLine4 = request.AddressLine4; parameters.AddressLine5 = request.AddressLine5; parameters.Town = request.Town; parameters.Postcode = request.Postcode; } else { parameters.AddressLine1 = employerInformation.AddressLine1; parameters.AddressLine2 = employerInformation.AddressLine2; parameters.AddressLine3 = employerInformation.AddressLine3; parameters.AddressLine4 = employerInformation.AddressLine4; parameters.AddressLine5 = employerInformation.AddressLine5; parameters.Town = employerInformation.Town; parameters.Postcode = employerInformation.Postcode; } }
public void SetUp() { var fixture = new Fixture().Customize(new AutoMoqCustomization()); _randomWageType = fixture.Create <int>(); _randomLegacyWageType = fixture.Create <int>(); _randomWageUnit = fixture.Create <int>(); _randomDurationType = (DurationType) new Random().Next(1, 4); var durationTypeMapper = new DurationMapper(); _randomDomainDurationType = durationTypeMapper.MapTypeToDomainType(_randomDurationType); _request = fixture.Build <CreateApprenticeshipRequest>() .With(request => request.WageType, (WageType)_randomWageType) .With(request => request.WageUnit, (WageUnit)_randomWageUnit) .With(request => request.DurationType, _randomDurationType) .With(request => request.IsEmployerDisabilityConfident, fixture.Create <bool>()) .Create(); _mockWageTypeMapper = fixture.Freeze <Mock <IWageTypeMapper> >(); _mockWageTypeMapper .Setup(typeMapper => typeMapper.MapToLegacy(It.IsAny <CreateApprenticeshipRequest>())) .Returns((LegacyWageType)_randomLegacyWageType); _mockWageTextFormatter = fixture.Freeze <Mock <IWageTextFormatter> >(); fixture.Inject <IDurationMapper>(durationTypeMapper); _employerInformation = fixture.Create <EmployerInformation>(); var mapper = fixture.Create <CreateApprenticeshipParametersMapper>(); _mappedParameters = mapper.MapFromRequest(_request, _employerInformation); }