Ejemplo n.º 1
0
        public When_ProviderVenueQualificationService_Is_Called_With_New_Provider()
        {
            _providerService = Substitute.For <IProviderService>();
            var providerVenueService             = Substitute.For <IProviderVenueService>();
            var providerQualificationService     = Substitute.For <IProviderQualificationService>();
            var qualificationRouteMappingService = Substitute.For <IQualificationRouteMappingService>();
            var qualificationService             = Substitute.For <IQualificationService>();
            var routePathService = Substitute.For <IRoutePathService>();

            _providerService.SearchAsync(10000001)
            .Returns((ProviderSearchResultDto)null);

            _providerService.CreateProviderAsync(Arg.Any <CreateProviderDetailViewModel>()).Returns(1);

            var providerVenueQualificationService = new ProviderVenueQualificationService
                                                    (
                _providerService,
                providerVenueService,
                providerQualificationService,
                qualificationService,
                routePathService,
                qualificationRouteMappingService
                                                    );

            var dtoList = new ValidProviderVenueQualificationDtoListBuilder().Build();

            _results = providerVenueQualificationService.UpdateAsync(dtoList).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();
        }
Ejemplo n.º 3
0
        public When_ProviderVenueQualificationService_Is_Called_To_Update_Provider()
        {
            _providerService = Substitute.For <IProviderService>();
            var providerVenueService             = Substitute.For <IProviderVenueService>();
            var providerQualificationService     = Substitute.For <IProviderQualificationService>();
            var qualificationRouteMappingService = Substitute.For <IQualificationRouteMappingService>();
            var qualificationService             = Substitute.For <IQualificationService>();
            var 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",
                DisplayName           = "Old Display Name",
                PrimaryContact        = "Old Primary Contact",
                PrimaryContactEmail   = "*****@*****.**",
                PrimaryContactPhone   = "0771234567",
                SecondaryContact      = "Old Secondary Contact",
                SecondaryContactEmail = "*****@*****.**",
                SecondaryContactPhone = "08812345678"
            });

            var providerVenueQualificationService = new ProviderVenueQualificationService
                                                    (
                _providerService,
                providerVenueService,
                providerQualificationService,
                qualificationService,
                routePathService,
                qualificationRouteMappingService
                                                    );

            var dtoList = new ValidProviderVenueQualificationDtoListBuilder().Build();

            _results = providerVenueQualificationService.UpdateAsync(dtoList).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();
        }