public Task <Apprenticeship> CreateApprenticeship( Guid providerId, Standard standard, UserInfo createdBy, ApprenticeshipStatus status = ApprenticeshipStatus.Live, string marketingInformation = "Marketing info", string website = "http://provider.com/apprenticeship", string contactTelephone = "01234 567890", string contactEmail = "*****@*****.**", string contactWebsite = "http://provider.com", DateTime?createdOn = null, IEnumerable <CreateApprenticeshipLocation> locations = null) { locations ??= new[] { CreateApprenticeshipLocation.CreateNationalEmployerBased() }; return(WithSqlQueryDispatcher(async dispatcher => { var apprenticeshipId = Guid.NewGuid(); await dispatcher.ExecuteQuery(new CreateApprenticeship() { ApprenticeshipId = apprenticeshipId, ProviderId = providerId, Status = status, Standard = standard, MarketingInformation = marketingInformation, ApprenticeshipWebsite = website, ContactEmail = contactEmail, ContactTelephone = contactTelephone, ContactWebsite = contactWebsite, ApprenticeshipLocations = locations, CreatedBy = createdBy, CreatedOn = createdOn ?? _clock.UtcNow }); return await dispatcher.ExecuteQuery(new GetApprenticeship() { ApprenticeshipId = apprenticeshipId }); })); }
public async Task Initialize_NationalApprenticeship_PopulatesModelCorrectly() { // Arrange var contactTelephone = "1111 111 1111"; var website = "https://somerandomprovider.com/apprenticeship"; var contactWebsite = "https://somerandomprovider.com"; var marketingInfo = "Providing Online training"; var regions = new List <string> { "123" }; var contactEmail = "*****@*****.**"; var provider = await TestData.CreateProvider( providerName : "Provider 1", apprenticeshipQAStatus : ApprenticeshipQAStatus.Submitted); var providerUser = await TestData.CreateUser(providerId : provider.ProviderId); var adminUser = await TestData.CreateUser(); var standard = await TestData.CreateStandard(standardCode : 1234, version : 1, standardName : "Test Standard"); var apprenticeshipId = (await TestData.CreateApprenticeship(provider.ProviderId, standard, createdBy: providerUser, contactEmail: contactEmail, contactTelephone: contactTelephone, contactWebsite: contactWebsite, marketingInformation: marketingInfo, website: website, locations: new[] { CreateApprenticeshipLocation.CreateNationalEmployerBased() })).ApprenticeshipId; var standardsAndFrameworksCache = new StandardsCache(CosmosDbQueryDispatcher.Object); var submissionId = await TestData.CreateApprenticeshipQASubmission( provider.ProviderId, submittedOn : Clock.UtcNow, submittedByUserId : providerUser.UserId, providerMarketingInformation : "The overview", apprenticeshipIds : new[] { apprenticeshipId }); await WithSqlQueryDispatcher(async dispatcher => { var initializer = new FlowModelInitializer(CosmosDbQueryDispatcher.Object, dispatcher); // Act var model = await initializer.Initialize(provider.ProviderId); // Assert Assert.True(model.GotApprenticeshipDetails); Assert.Equal(contactEmail, model.ApprenticeshipContactEmail); Assert.Equal(contactTelephone, model.ApprenticeshipContactTelephone); Assert.Equal(contactWebsite, model.ApprenticeshipContactWebsite); Assert.Equal(apprenticeshipId, model.ApprenticeshipId); Assert.True(model.ApprenticeshipIsNational); Assert.Equal(ApprenticeshipLocationType.EmployerBased, model.ApprenticeshipLocationType); Assert.Equal(marketingInfo, model.ApprenticeshipMarketingInformation); Assert.Null(model.ApprenticeshipClassroomLocations); Assert.Equal(website, model.ApprenticeshipWebsite); }); }