public async Task And_All_Fields_Valid_Then_Valid(
            GetProviderCacheReservationCommandQuery query,
            GetProviderCacheReservationCommandQueryValidator validator)
        {
            var result = await validator.ValidateAsync(query);

            result.IsValid().Should().BeTrue();
            result.ValidationDictionary.Count.Should().Be(0);
        }
        public async Task And_No_Cohort_Reference_Then_Invalid(
            GetProviderCacheReservationCommandQuery query,
            GetProviderCacheReservationCommandQueryValidator validator)
        {
            query.CohortRef = null;

            var result = await validator.ValidateAsync(query);

            result.IsValid().Should().BeFalse();
            result.ValidationDictionary.Count.Should().Be(1);

            result.ValidationDictionary
            .Should().ContainKey(nameof(GetProviderCacheReservationCommandQuery.CohortRef))
            .WhichValue.Should()
            .Be($"{nameof(GetProviderCacheReservationCommandQuery.CohortRef)} has not been supplied");
        }
        public async Task And_No_Ukprn_Then_Invalid(
            GetProviderCacheReservationCommandQuery query,
            GetProviderCacheReservationCommandQueryValidator validator)
        {
            query.UkPrn = default(uint);

            var result = await validator.ValidateAsync(query);

            result.IsValid().Should().BeFalse();
            result.ValidationDictionary.Count.Should().Be(1);

            result.ValidationDictionary
            .Should().ContainKey(nameof(GetProviderCacheReservationCommandQuery.UkPrn))
            .WhichValue.Should()
            .Be($"{nameof(GetProviderCacheReservationCommandQuery.UkPrn)} has not been supplied");
        }
        public async Task And_No_Legal_Entity_Public_Hashed_Id_Then_Invalid(
            GetProviderCacheReservationCommandQuery query,
            GetProviderCacheReservationCommandQueryValidator validator)
        {
            query.AccountLegalEntityPublicHashedId = null;

            var result = await validator.ValidateAsync(query);

            result.IsValid().Should().BeFalse();
            result.ValidationDictionary.Count.Should().Be(1);

            result.ValidationDictionary
            .Should().ContainKey(nameof(GetProviderCacheReservationCommandQuery.AccountLegalEntityPublicHashedId))
            .WhichValue.Should()
            .Be($"{nameof(GetProviderCacheReservationCommandQuery.AccountLegalEntityPublicHashedId)} has not been supplied");
        }
        public void Arrange()
        {
            _mediator  = new Mock <IMediator>();
            _validator = new Mock <IValidator <GetProviderCacheReservationCommandQuery> >();
            _query     = new GetProviderCacheReservationCommandQuery
            {
                UkPrn = 12,
                AccountLegalEntityPublicHashedId = "ABC123",
                CohortRef = "1234"
            };

            _handler = new GetProviderCacheReservationCommandQueryHandler(_mediator.Object, _validator.Object);

            _expectedEmployer = new AccountLegalEntity
            {
                AccountId = 1,
                AccountLegalEntityPublicHashedId = _query.AccountLegalEntityPublicHashedId,
                AccountLegalEntityName           = "Test Employer",
                AccountLegalEntityId             = 123,
                AccountName           = "Test Account",
                AccountPublicHashedId = "DEF123"
            };

            _expectedAccountLegalEntity = new AccountLegalEntity
            {
                AccountId = 1,
                AccountLegalEntityPublicHashedId = _query.AccountLegalEntityPublicHashedId,
                AccountLegalEntityName           = "Test Employer",
                AccountLegalEntityId             = 123,
                LegalEntityId    = 456,
                ReservationLimit = 3
            };

            _expectedCohort = new Cohort()
            {
                CohortId             = 123,
                AccountLegalEntityId = _expectedAccountLegalEntity.AccountLegalEntityId,
                LegalEntityName      = _expectedAccountLegalEntity.AccountLegalEntityName,
                ProviderName         = "Test Provider",
                IsFundedByTransfer   = false,
                WithParty            = CohortParty.Provider
            };

            _getTrustedEmployersResponse = new GetTrustedEmployersResponse
            {
                Employers = new [] { _expectedEmployer }
            };

            _getAccountLegalEntityResponse = new GetAccountLegalEntityResult
            {
                LegalEntity = _expectedAccountLegalEntity
            };

            _mediator.Setup(mediator => mediator.Send(
                                It.IsAny <GetTrustedEmployersQuery>(),
                                It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getTrustedEmployersResponse);

            _mediator.Setup(mediator => mediator.Send(
                                It.IsAny <GetAccountLegalEntityQuery>(),
                                It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getAccountLegalEntityResponse);

            _mediator.Setup(m => m.Send(
                                It.IsAny <GetCohortQuery>(),
                                It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetCohortResponse {
                Cohort = _expectedCohort
            });

            _validator.Setup(v => v.ValidateAsync(_query))
            .ReturnsAsync(new ValidationResult {
                ValidationDictionary = new Dictionary <string, string>()
            });
        }