public When_Qualification_Add_Qualification_Does_Not_Exist() { var providerVenueService = Substitute.For <IProviderVenueService>(); _qualificationService = Substitute.For <IQualificationService>(); _qualificationService.IsValidLarIdAsync("12345678").Returns(true); _qualificationService.GetQualificationAsync("12345678").ReturnsNull(); _qualificationService.IsValidOfqualLarIdAsync("12345678").Returns(true); _providerQualificationService = Substitute.For <IProviderQualificationService>(); var routePathService = Substitute.For <IRoutePathService>(); var qualificationController = new QualificationController(providerVenueService, _qualificationService, _providerQualificationService, routePathService); var controllerWithClaims = new ClaimsBuilder <QualificationController>(qualificationController) .AddUserName("username") .AddEmail("*****@*****.**") .Build(); var viewModel = new AddQualificationViewModel { ProviderVenueId = 1, LarId = "12345678", Postcode = "CV1 2WT" }; _result = controllerWithClaims.CreateQualificationAsync(viewModel).GetAwaiter().GetResult(); }
public When_Qualification_Save_MissingQualification_Is_Called() { _qualificationService = Substitute.For <IQualificationService>(); var providerVenueService = Substitute.For <IProviderVenueService>(); _providerQualificationService = Substitute.For <IProviderQualificationService>(); var routePathService = Substitute.For <IRoutePathService>(); var qualificationController = new QualificationController(providerVenueService, _qualificationService, _providerQualificationService, routePathService); var controllerWithClaims = new ClaimsBuilder <QualificationController>(qualificationController) .AddUserName("username") .AddEmail("*****@*****.**") .Build(); var viewModel = new MissingQualificationViewModel { ProviderVenueId = 1, LarId = "12345678", QualificationId = 1, Title = "Qualification title", ShortTitle = new string('X', 100), Routes = new List <RouteSummaryViewModel> { new RouteSummaryViewModel { Id = 1, Name = "Route 1", IsSelected = true } } }; _result = controllerWithClaims.SaveMissingQualificationAsync(viewModel).GetAwaiter().GetResult(); }
public When_ProviderVenueQualificationService_Is_Called_To_Update_ProviderVenue() { var providerService = Substitute.For <IProviderService>(); _providerVenueService = Substitute.For <IProviderVenueService>(); _providerQualificationService = Substitute.For <IProviderQualificationService>(); _qualificationRouteMappingService = Substitute.For <IQualificationRouteMappingService>(); _qualificationService = Substitute.For <IQualificationService>(); _routePathService = Substitute.For <IRoutePathService>(); providerService.SearchAsync(10000001) .Returns(new ProviderSearchResultDto { Id = 1, UkPrn = 10000001, Name = "ProviderName" }); providerService.GetProviderDetailByIdAsync(1) .Returns(new ProviderDetailViewModel { Id = 1, UkPrn = 10000001, Name = "Old Name", }); _providerVenueService .GetVenueWithTrimmedPostcodeAsync(1, "CV1 2WT") .Returns(new ProviderVenueDetailViewModel { Id = 1, ProviderId = 1, Postcode = "CV1 2WT", Name = null, IsEnabledForReferral = true, Source = "Import", Qualifications = new List <QualificationDetailViewModel>() }); _qualificationService.GetQualificationAsync(Arg.Any <string>()).Returns((QualificationDetailViewModel)null); _providerQualificationService.GetProviderQualificationAsync(Arg.Any <int>(), Arg.Any <int>()).Returns((ProviderQualificationDto)null); _routePathService.GetRouteSummaryByNameAsync(Arg.Any <string>()).Returns((RouteSummaryViewModel)null); var providerVenueQualificationService = new ProviderVenueQualificationService ( providerService, _providerVenueService, _providerQualificationService, _qualificationService, _routePathService, _qualificationRouteMappingService ); var dtoList = new ValidProviderVenueQualificationDtoListBuilder() .AddVenue() .Build(); _results = providerVenueQualificationService.UpdateAsync(dtoList).GetAwaiter().GetResult(); }
public QualificationController(IProviderVenueService providerVenueService, IQualificationService qualificationService, IProviderQualificationService providerQualificationService, IRoutePathService routePathService) { _providerVenueService = providerVenueService; _qualificationService = qualificationService; _providerQualificationService = providerQualificationService; _routePathService = routePathService; }
public ProviderVenueQualificationService(IProviderService providerService, IProviderVenueService providerVenueService, IProviderQualificationService providerQualificationService, IQualificationService qualificationService, IRoutePathService routePathService, IQualificationRouteMappingService qualificationRouteMappingService) { _providerService = providerService; _providerVenueService = providerVenueService; _providerQualificationService = providerQualificationService; _qualificationService = qualificationService; _routePathService = routePathService; _qualificationRouteMappingService = qualificationRouteMappingService; }
public When_Qualification_RemoveQualification_Is_Called() { var qualificationService = Substitute.For <IQualificationService>(); var providerVenueService = Substitute.For <IProviderVenueService>(); _providerQualificationService = Substitute.For <IProviderQualificationService>(); var routePathService = Substitute.For <IRoutePathService>(); var qualificationController = new QualificationController(providerVenueService, qualificationService, _providerQualificationService, routePathService); var controllerWithClaims = new ClaimsBuilder <QualificationController>(qualificationController) .AddUserName("username") .AddEmail("*****@*****.**") .Build(); _result = controllerWithClaims.RemoveQualificationAsync(1, 2).GetAwaiter().GetResult(); }
public When_Qualification_Add_Has_Invalid_LarId() { var providerVenueService = Substitute.For <IProviderVenueService>(); _qualificationService = Substitute.For <IQualificationService>(); _qualificationService.IsValidLarIdAsync("12345").Returns(false); _providerQualificationService = Substitute.For <IProviderQualificationService>(); var routePathService = Substitute.For <IRoutePathService>(); var qualificationController = new QualificationController(providerVenueService, _qualificationService, _providerQualificationService, routePathService); var viewModel = new AddQualificationViewModel { LarId = "12345", Postcode = "CV1 2WT" }; _result = qualificationController.CreateQualificationAsync(viewModel).GetAwaiter().GetResult(); }
public When_ProviderVenueQualificationService_Is_Called_With_New_Qualification() { _providerService = Substitute.For <IProviderService>(); _providerVenueService = Substitute.For <IProviderVenueService>(); _providerQualificationService = Substitute.For <IProviderQualificationService>(); _qualificationRouteMappingService = Substitute.For <IQualificationRouteMappingService>(); _qualificationService = Substitute.For <IQualificationService>(); _routePathService = Substitute.For <IRoutePathService>(); var dtoList = new ValidProviderVenueQualificationDtoListBuilder() .AddVenue() .AddQualificationWithRoutes() .Build(); var dto = dtoList.First(); _providerService.SearchAsync(10000001) .Returns(new ProviderSearchResultDto { Id = 1, UkPrn = dto.UkPrn, Name = dto.ProviderName }); _providerService.GetProviderDetailByIdAsync(1) .Returns(new ProviderDetailViewModel { UkPrn = dto.UkPrn, Name = dto.ProviderName, DisplayName = dto.DisplayName, IsCdfProvider = dto.IsCdfProvider, IsEnabledForReferral = dto.IsEnabledForReferral, PrimaryContact = dto.PrimaryContact, PrimaryContactEmail = dto.PrimaryContactEmail, PrimaryContactPhone = dto.PrimaryContactPhone, SecondaryContact = dto.SecondaryContact, SecondaryContactEmail = dto.SecondaryContactEmail, SecondaryContactPhone = dto.SecondaryContactPhone }); _providerVenueService .GetVenueWithTrimmedPostcodeAsync(1, "CV1 2WT") .Returns(new ProviderVenueDetailViewModel { Id = 1, ProviderId = 1, Postcode = dto.VenuePostcode, Name = dto.VenueName, IsEnabledForReferral = dto.VenueIsEnabledForReferral, Qualifications = new List <QualificationDetailViewModel>() }); _qualificationService .GetQualificationAsync("1234567X") .Returns((QualificationDetailViewModel)null); _qualificationService .CreateQualificationEntityAsync(Arg.Is <MissingQualificationViewModel>( p => p.LarId == "1234567X")) .Returns(10); //Qualification id _providerQualificationService .GetProviderQualificationAsync(Arg.Any <int>(), Arg.Any <int>()) .Returns((ProviderQualificationDto)null); _routePathService .GetRouteSummaryByNameAsync("Agriculture, environmental and animal care") .Returns(new RouteSummaryViewModel { Id = 1, Name = "Agriculture, environmental and animal care" }); _routePathService .GetRouteSummaryByNameAsync("Digital") .Returns(new RouteSummaryViewModel { Id = 3, Name = "Digital" }); _qualificationRouteMappingService .GetQualificationRouteMappingAsync(Arg.Any <int>(), Arg.Any <int>()) .Returns((QualificationRouteMappingViewModel)null); var providerVenueQualificationService = new ProviderVenueQualificationService ( _providerService, _providerVenueService, _providerQualificationService, _qualificationService, _routePathService, _qualificationRouteMappingService ); _results = providerVenueQualificationService.UpdateAsync(dtoList).GetAwaiter().GetResult(); }
public When_ProviderVenueQualificationService_Is_Called_To_Unremove_ProviderVenue() { var providerService = Substitute.For <IProviderService>(); _providerVenueService = Substitute.For <IProviderVenueService>(); _providerQualificationService = Substitute.For <IProviderQualificationService>(); _qualificationRouteMappingService = Substitute.For <IQualificationRouteMappingService>(); _qualificationService = Substitute.For <IQualificationService>(); _routePathService = Substitute.For <IRoutePathService>(); var dtoList = new ValidProviderVenueQualificationDtoListBuilder() .AddVenue(isRemoved: false) .Build(); var dto = dtoList.First(); providerService.SearchAsync(10000001) .Returns(new ProviderSearchResultDto { Id = 1, UkPrn = dto.UkPrn, Name = dto.ProviderName }); providerService.GetProviderDetailByIdAsync(1) .Returns(new ProviderDetailViewModel { UkPrn = dto.UkPrn, Name = dto.ProviderName, DisplayName = dto.DisplayName, IsCdfProvider = dto.IsCdfProvider, IsEnabledForReferral = dto.IsEnabledForReferral, PrimaryContact = dto.PrimaryContact, PrimaryContactEmail = dto.PrimaryContactEmail, PrimaryContactPhone = dto.PrimaryContactPhone, SecondaryContact = dto.SecondaryContact, SecondaryContactEmail = dto.SecondaryContactEmail, SecondaryContactPhone = dto.SecondaryContactPhone }); var providerVenueDetailViewModel = new ProviderVenueDetailViewModel { Id = 1, ProviderId = 1, Postcode = dto.VenuePostcode, Name = dto.VenueName, IsEnabledForReferral = dto.VenueIsEnabledForReferral, IsRemoved = true, Qualifications = new List <QualificationDetailViewModel>() }; _providerVenueService .GetVenueWithTrimmedPostcodeAsync(1, "CV1 2WT") .Returns(providerVenueDetailViewModel); _qualificationService.GetQualificationAsync(Arg.Any <string>()).Returns((QualificationDetailViewModel)null); _providerQualificationService.GetProviderQualificationAsync(Arg.Any <int>(), Arg.Any <int>()).Returns((ProviderQualificationDto)null); _routePathService.GetRouteSummaryByNameAsync(Arg.Any <string>()).Returns((RouteSummaryViewModel)null); var providerVenueQualificationService = new ProviderVenueQualificationService ( providerService, _providerVenueService, _providerQualificationService, _qualificationService, _routePathService, _qualificationRouteMappingService ); _results = providerVenueQualificationService.UpdateAsync(dtoList).GetAwaiter().GetResult(); }
public When_ProviderVenueQualificationService_Is_Called_To_Remove_Provider_Qualification() { _providerService = Substitute.For <IProviderService>(); _providerVenueService = Substitute.For <IProviderVenueService>(); _providerQualificationService = Substitute.For <IProviderQualificationService>(); _qualificationRouteMappingService = Substitute.For <IQualificationRouteMappingService>(); _qualificationService = Substitute.For <IQualificationService>(); _routePathService = Substitute.For <IRoutePathService>(); var dtoList = new ValidProviderVenueQualificationDtoListBuilder() .AddVenue() .AddQualificationWithRoutes(false) // Qualification not offerred .Build(); var dto = dtoList.First(); _providerService.SearchAsync(10000001) .Returns(new ProviderSearchResultDto { Id = 1, UkPrn = dto.UkPrn, Name = dto.ProviderName }); _providerService.GetProviderDetailByIdAsync(1) .Returns(new ProviderDetailViewModel { UkPrn = dto.UkPrn, Name = dto.ProviderName, DisplayName = dto.DisplayName, IsCdfProvider = dto.IsCdfProvider, IsEnabledForReferral = dto.IsEnabledForReferral, PrimaryContact = dto.PrimaryContact, PrimaryContactEmail = dto.PrimaryContactEmail, PrimaryContactPhone = dto.PrimaryContactPhone, SecondaryContact = dto.SecondaryContact, SecondaryContactEmail = dto.SecondaryContactEmail, SecondaryContactPhone = dto.SecondaryContactPhone }); _providerVenueService .GetVenueWithTrimmedPostcodeAsync(1, "CV1 2WT") .Returns(new ProviderVenueDetailViewModel { Id = 1, ProviderId = 1, Postcode = dto.VenuePostcode, Name = dto.VenueName, IsEnabledForReferral = dto.VenueIsEnabledForReferral, Qualifications = new List <QualificationDetailViewModel>() }); _qualificationService .GetQualificationAsync("1234567X") .Returns(new QualificationDetailViewModel { Id = 10, LarId = "1234567X", Title = "Full qualification title", ShortTitle = "Short qualification title" }); _providerQualificationService .GetProviderQualificationAsync(Arg.Any <int>(), Arg.Any <int>()) .Returns(new ProviderQualificationDto { ProviderVenueId = 1, QualificationId = 10 }); _routePathService .GetRouteSummaryByNameAsync("Agriculture, environmental and animal care") .Returns(new RouteSummaryViewModel { Id = 1, Name = "Agriculture, environmental and animal care" }); _routePathService .GetRouteSummaryByNameAsync("Digital") .Returns(new RouteSummaryViewModel { Id = 3, Name = "Digital" }); _qualificationRouteMappingService .GetQualificationRouteMappingAsync(1, 10) .Returns(new QualificationRouteMappingViewModel { QualificationId = 10, RouteId = 1, Source = "Test" }); _qualificationRouteMappingService .GetQualificationRouteMappingAsync(3, 10) .Returns(new QualificationRouteMappingViewModel { QualificationId = 10, RouteId = 3, Source = "Test" }); var providerVenueQualificationService = new ProviderVenueQualificationService ( _providerService, _providerVenueService, _providerQualificationService, _qualificationService, _routePathService, _qualificationRouteMappingService ); _results = providerVenueQualificationService.UpdateAsync(dtoList).GetAwaiter().GetResult(); }