public async Task Then_Returns_Legal_Entities(
            GetLegalEntitiesQuery query,
            IEnumerable <AccountLegalEntity> legalEntities,
            [Frozen] Mock <IApiClient> mockApiClient,
            GetLegalEntitiesQueryHandler handler)
        {
            mockApiClient
            .Setup(client => client.GetAll <AccountLegalEntity>(It.IsAny <GetAccountLegalEntitiesRequest>()))
            .ReturnsAsync(legalEntities);

            var result = await handler.Handle(query, CancellationToken.None);

            result.AccountLegalEntities.Count().Should().Be(legalEntities.Count());
        }
        public async Task Then_Gets_Legal_Entities_For_Account(
            GetLegalEntitiesQuery query,
            IEnumerable <AccountLegalEntity> legalEntities,
            [Frozen] Mock <IApiClient> mockApiClient,
            GetLegalEntitiesQueryHandler handler)
        {
            mockApiClient
            .Setup(client => client.GetAll <AccountLegalEntity>(It.IsAny <GetAccountLegalEntitiesRequest>()))
            .ReturnsAsync(legalEntities);

            await handler.Handle(query, CancellationToken.None);

            mockApiClient.Verify(client => client.GetAll <AccountLegalEntity>(It.Is <GetAccountLegalEntitiesRequest>(r => r.AccountId.Equals(query.AccountId))), Times.Once);
        }
        public async Task Then_Hashes_The_Id(
            GetLegalEntitiesQuery query,
            IEnumerable <AccountLegalEntity> legalEntities,
            [Frozen] Mock <IApiClient> mockApiClient,
            [Frozen] Mock <IEncodingService> encodingService,
            GetLegalEntitiesQueryHandler handler)
        {
            mockApiClient
            .Setup(client => client.GetAll <AccountLegalEntity>(It.IsAny <GetAccountLegalEntitiesRequest>()))
            .ReturnsAsync(legalEntities);

            await handler.Handle(query, CancellationToken.None);

            encodingService.Verify(service => service.Encode(legalEntities.FirstOrDefault().AccountLegalEntityId, EncodingType.PublicAccountLegalEntityId), Times.Once);
        }
        public async Task Then_data_is_fetched_via_data_repository()
        {
            //Arrange
            var query    = _fixture.Create <GetLegalEntitiesRequest>();
            var data     = _fixture.CreateMany <LegalEntityDto>().ToList();
            var expected = new GetLegalEntitiesResponse
            {
                LegalEntities = data
            };

            _repositoryMock.Setup(x => x.GetList(dto => dto.AccountId == query.AccountId)).ReturnsAsync(data);

            //Act
            var result = await _sut.Handle(query, CancellationToken.None);

            //Assert
            result.Should().BeEquivalentTo(expected);
        }
        public async Task Then_Uses_correct_Api_Base_Url(
            GetLegalEntitiesQuery query,
            IEnumerable <AccountLegalEntity> legalEntities,
            [Frozen] Mock <IApiClient> mockApiClient,
            [Frozen] Mock <IOptions <ReservationsApiConfiguration> > mockOptions,
            [Frozen] Mock <IEncodingService> encodingService,
            [Frozen] ReservationsApiConfiguration configuration,
            GetLegalEntitiesQueryHandler handler)
        {
            mockOptions.Setup(c => c.Value).Returns(configuration);

            mockApiClient
            .Setup(client => client.GetAll <AccountLegalEntity>(It.IsAny <GetAccountLegalEntitiesRequest>()))
            .ReturnsAsync(legalEntities);

            await handler.Handle(query, CancellationToken.None);

            mockApiClient.Verify(client => client.GetAll <AccountLegalEntity>(It.Is <GetAccountLegalEntitiesRequest>(r => r.BaseUrl.Equals(configuration.Url))), Times.Once);
        }