public void ShouldNotValidateIfNotPossibleToGetStandard()
        {
            var message = new ApprenticeshipProviderDetailQuery {
                StandardCode = "1", LocationId = 5, UkPrn = 42
            };

            var stubApprenticeship = new ApprenticeshipDetails
            {
                Product  = new ApprenticeshipProduct(),
                Location = new Location {
                    LocationId = 5
                },
                Provider = new Provider {
                    UkPrn = 42
                }
            };

            _mockSearchService.Setup(x => x.GetCourseByStandardCode(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(stubApprenticeship);
            _mockIGetStandards.Setup(x => x.GetStandardById("1")).Returns(null as Standard);

            var response = _handler.Handle(message, _cancellationToken).Result;

            _mockIGetStandards.Verify(x => x.GetStandardById(It.IsAny <string>()), Times.Once);
            response.StatusCode.Should().Be(ApprenticeshipProviderDetailResponse.ResponseCodes.ApprenticeshipProviderNotFound);
        }
        public void ShouldNotValidateIfProviderOrLocationIdIsMissing(int ukprn, int locationId)
        {
            var message = new ApprenticeshipProviderDetailQuery {
                StandardCode = "1", LocationId = locationId, UkPrn = ukprn
            };

            var stubApprenticeship = new ApprenticeshipDetails
            {
                Product  = new ApprenticeshipProduct(),
                Location = new Location {
                    LocationId = 55
                },
                Provider = new Provider {
                    UkPrn = 42
                }
            };

            var stubStandardProduct = new Standard {
                Title = "Standard1", Level = 4,
            };

            _mockSearchService.Setup(x => x.GetCourseByStandardCode(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(stubApprenticeship);
            _mockIGetStandards.Setup(x => x.GetStandardById("1")).Returns(stubStandardProduct);

            var response = _handler.Handle(message, _cancellationToken).Result;

            response.StatusCode.Should().Be(ApprenticeshipProviderDetailResponse.ResponseCodes.InvalidInput);
        }
        public void ShouldReturnAStandardFromAHigherEducationInstitute()
        {
            var message = new ApprenticeshipProviderDetailQuery {
                StandardCode = "1", LocationId = 55, UkPrn = 42
            };

            var stubApprenticeship = new ApprenticeshipDetails
            {
                Product  = new ApprenticeshipProduct(),
                Location = new Location {
                    LocationId = 55
                },
                Provider = new Provider {
                    UkPrn = 42, IsHigherEducationInstitute = true
                }
            };
            var stubStandardProduct = new Standard {
                Title = "Standard1", Level = 4,
            };

            _mockSearchService.Setup(x => x.GetCourseByStandardCode(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(stubApprenticeship);
            _mockIGetStandards.Setup(x => x.GetStandardById("1")).Returns(stubStandardProduct);

            var response = _handler.Handle(message, _cancellationToken).Result;

            response.ApprenticeshipDetails.Should().Be(stubApprenticeship);
            response.ApprenticeshipLevel.ShouldBeEquivalentTo("4");
            response.ApprenticeshipName.ShouldAllBeEquivalentTo("Standard1");
            response.ApprenticeshipType.ShouldBeEquivalentTo(ApprenticeshipTrainingType.Standard);
            response.ApprenticeshipDetails.Provider.IsHigherEducationInstitute.Should().BeTrue();
        }
        public void ShouldReturnAFramework()
        {
            var message = new ApprenticeshipProviderDetailQuery {
                FrameworkId = "1", LocationId = 55, UkPrn = 42
            };

            var stubApprenticeship = new ApprenticeshipDetails
            {
                Product  = new ApprenticeshipProduct(),
                Location = new Location {
                    LocationId = 55
                },
                Provider = new Provider {
                    UkPrn = 42
                }
            };
            var stubStandardProduct = new Framework {
                Title = "Framework1", Level = 4,
            };

            _mockSearchService.Setup(x => x.GetCourseByFrameworkId(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(stubApprenticeship);
            _mockIGetFrameworks.Setup(x => x.GetFrameworkById("1")).Returns(stubStandardProduct);

            var response = _handler.Handle(message, _cancellationToken).Result;

            response.ApprenticeshipDetails.Should().Be(stubApprenticeship);
            response.ApprenticeshipLevel.ShouldBeEquivalentTo("4");
            response.ApprenticeshipName.ShouldAllBeEquivalentTo("Framework1");
            response.ApprenticeshipType.ShouldBeEquivalentTo(ApprenticeshipTrainingType.Framework);
        }
        public void Setup()
        {
            _mockSearchService  = new Mock <IApprenticeshipProviderRepository>();
            _mockIGetStandards  = new Mock <IGetStandards>();
            _mockIGetFrameworks = new Mock <IGetFrameworks>();
            _mockLogger         = new Mock <ILog>();

            var providerFrameworkSearchResults = new ApprenticeshipDetails();

            _mockSearchService.Setup(x => x.GetCourseByStandardCode(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(providerFrameworkSearchResults);

            _handler = new ApprenticeshipProviderDetailHandler(
                new ApprenticeshipProviderDetailQueryValidator(new Validation()),
                _mockSearchService.Object,
                _mockIGetStandards.Object,
                _mockIGetFrameworks.Object,
                _mockLogger.Object);
        }
Пример #6
0
        public DetailProviderResponse CreateDetailProviderResponse(ApprenticeshipDetails model, IApprenticeshipProduct apprenticeshipProduct, ApprenticeshipTrainingType apprenticeshipProductType)
        {
            if (model == null || apprenticeshipProduct == null)
            {
                return(new DetailProviderResponse
                {
                    StatusCode = DetailProviderResponse.ResponseCodes.ApprenticeshipProviderNotFound
                });
            }

            var response = new DetailProviderResponse
            {
                StatusCode            = DetailProviderResponse.ResponseCodes.Success,
                ApprenticeshipDetails = model,
                ApprenticeshipType    = apprenticeshipProductType,
                ApprenticeshipName    = apprenticeshipProduct.Title,
                ApprenticeshipLevel   = apprenticeshipProduct.Level.ToString()
            };

            return(response);
        }
Пример #7
0
        public void ShouldMapAllValauesCorrectly()
        {
            var mappingService = new MappingService(null);

            var providerResult = new ApprenticeshipDetails
            {
                Product = new ApprenticeshipProduct
                {
                    Apprenticeship = new ApprenticeshipBasic
                    {
                        ApprenticeshipInfoUrl       = "apprenticeship test url",
                        ApprenticeshipMarketingInfo = "test marketing info"
                    },
                    DeliveryModes = new List <string>()
                    {
                        "On site", "Day trip"
                    },
                    EmployerSatisfaction    = 8.3,
                    LearnerSatisfaction     = 2.1,
                    ProviderMarketingInfo   = "provider marketing info",
                    AchievementRate         = 1.1,
                    OverallCohort           = "27",
                    NationalAchievementRate = 2.2
                },
                Location = new Location
                {
                    LocationId   = 23,
                    LocationName = "Location 1",
                    Address      = new Address
                    {
                        Address1 = "12, test bay",
                        Address2 = "Market place",
                        Town     = "Sea Town",
                        County   = "Greensville",
                        Postcode = "AB12 3ED",
                        Lat      = 123,
                        Long     = 243
                    }
                },
                Provider = new Provider
                {
                    UkPrn = 947598734,
                    Name  = "test provider",
                    ContactInformation = new ContactInformation
                    {
                        Email        = "*****@*****.**",
                        Phone        = "01234 567891",
                        Website      = "www.test.co.uk",
                        ContactUsUrl = "www.contactus.co.uk"
                    }
                }
            };

            var viewModel = mappingService.Map <ApprenticeshipDetails, ApprenticeshipDetailsViewModel>(providerResult);

            viewModel.Address.Should().BeSameAs(providerResult.Location.Address);
            viewModel.Apprenticeship.Should().BeSameAs(providerResult.Product.Apprenticeship);
            viewModel.ContactInformation.Should().BeSameAs(providerResult.Provider.ContactInformation);
            viewModel.DeliveryModes.Should().BeEquivalentTo(providerResult.Product.DeliveryModes);

            viewModel.Location.LocationId.Should().Be(providerResult.Location.LocationId);
            viewModel.Location.LocationName.Should().BeSameAs(providerResult.Location.LocationName);
            viewModel.Location.Address.Should().BeSameAs(providerResult.Location.Address);
            viewModel.Location.Address.Should().BeSameAs(providerResult.Location.Address);

            viewModel.Name.Should().BeSameAs(providerResult.Provider.Name);
            viewModel.Ukprn.Should().Be(providerResult.Provider.UkPrn.ToString());

            viewModel.EmployerSatisfactionMessage.Should().Be("8.3%");
            viewModel.LearnerSatisfactionMessage.Should().Be("2.1%");

            viewModel.LocationAddressLine.Should().BeEquivalentTo("Location 1, 12, test bay, Market place, Sea Town, Greensville, AB12 3ED");
        }