Exemple #1
0
        public async Task Then_The_Endpoint_Is_Called_And_Cached_If_Not_In_Cache(
            string accountType,
            GetAvailableApiProductsResponse apiResponse,
            [Frozen] Mock <IApimDeveloperApiClient <ApimDeveloperApiConfiguration> > apimDeveloperApiClient,
            [Frozen] Mock <ICacheStorageService> cacheStorageService,
            ApimApiService apimApiService)
        {
            //Arrange
            var expectedGet = new GetAvailableApiProductsRequest(accountType);

            cacheStorageService
            .Setup(x => x.RetrieveFromCache <GetAvailableApiProductsResponse>(
                       $"{accountType}-{nameof(GetAvailableApiProductsResponse)}"))
            .ReturnsAsync((GetAvailableApiProductsResponse)null);
            apimDeveloperApiClient
            .Setup(x => x.Get <GetAvailableApiProductsResponse>(
                       It.Is <GetAvailableApiProductsRequest>(c => c.GetUrl.Equals(expectedGet.GetUrl))))
            .ReturnsAsync(apiResponse);

            //Act
            var actual = await apimApiService.GetAvailableProducts(accountType);

            //Assert
            actual.Should().BeEquivalentTo(apiResponse);
            cacheStorageService.Verify(x => x.SaveToCache($"{accountType}-{nameof(GetAvailableApiProductsResponse)}", apiResponse, 1));
        }
Exemple #2
0
        public void Then_The_Url_Is_Correctly_Constructed(string accountType)
        {
            var actual = new GetAvailableApiProductsRequest(accountType);

            actual.GetUrl.Should().Be($"api/products?group={accountType}");
        }