public async Task Then_The_Api_Is_Called_And_Data_Returned(
            GetApiProductSubscriptionsQuery query,
            GetAvailableApiProductsResponse serviceResponse,
            GetApiProductSubscriptionsResponse apiSubscriptionsResponse,
            [Frozen] Mock <IApimApiService> apimApiService,
            [Frozen] Mock <IApimDeveloperApiClient <ApimDeveloperApiConfiguration> > apiClient,
            GetApiProductSubscriptionsQueryHandler handler)
        {
            apimApiService.Setup(x =>
                                 x.GetAvailableProducts(query.AccountType)).ReturnsAsync(serviceResponse);
            apiClient.Setup(x =>
                            x.Get <GetApiProductSubscriptionsResponse>(
                                It.Is <GetApiProductSubscriptionsRequest>(c => c.GetUrl.EndsWith($"/{query.AccountIdentifier}"))))
            .ReturnsAsync(apiSubscriptionsResponse);

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

            actual.Products.Should().BeEquivalentTo(serviceResponse.Products);
            actual.Subscriptions.Should().BeEquivalentTo(apiSubscriptionsResponse.Subscriptions);
        }
コード例 #2
0
        public async Task Then_The_Product_And_Subscription_Is_Returned_For_The_Account(
            GetApiProductSubscriptionQuery subscriptionQuery,
            GetAvailableApiProductsResponse serviceResponse,
            GetApiProductSubscriptionsResponse apiSubscriptionsResponse,
            [Frozen] Mock <IApimApiService> apimApiService,
            [Frozen] Mock <IApimDeveloperApiClient <ApimDeveloperApiConfiguration> > client,
            GetApiProductSubscriptionQueryHandler handler)
        {
            serviceResponse.Products.First().Id = subscriptionQuery.ProductId;
            apiSubscriptionsResponse.Subscriptions.First().Name = subscriptionQuery.ProductId;
            apimApiService.Setup(x =>
                                 x.GetAvailableProducts(subscriptionQuery.AccountType)).ReturnsAsync(serviceResponse);
            client.Setup(x =>
                         x.Get <GetApiProductSubscriptionsResponse>(
                             It.Is <GetApiProductSubscriptionsRequest>(c => c.GetUrl.EndsWith($"/{subscriptionQuery.AccountIdentifier}"))))
            .ReturnsAsync(apiSubscriptionsResponse);

            var actual = await handler.Handle(subscriptionQuery, CancellationToken.None);

            actual.Product.Should().BeEquivalentTo(serviceResponse.Products.First());
            actual.Subscription.Should().BeEquivalentTo(apiSubscriptionsResponse.Subscriptions.First());
        }