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 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 ShouldNotValidateIfNotPossibleToGetCourceByFrameworkCode()
        {
            var message = new ApprenticeshipProviderDetailQuery {
                FrameworkId = "1", LocationId = 5, UkPrn = 42
            };

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

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

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

            _mockIGetFrameworks.Verify(x => x.GetFrameworkById(It.IsAny <string>()), Times.Once);
            response.StatusCode.Should().Be(ApprenticeshipProviderDetailResponse.ResponseCodes.ApprenticeshipProviderNotFound);
        }