public async Task GetItemTypedAsync_ResponseIsCached(CacheTypeEnum cacheType)
        {
            const string codename    = "codename";
            var          url         = $"items/{codename}";
            var          item        = CreateItemResponse(CreateItem(codename, "original"));
            var          updatedItem = CreateItemResponse(CreateItem(codename, "updated"));

            var scenarioBuilder = new ScenarioBuilder(cacheType);

            var scenario      = scenarioBuilder.WithResponse(url, item).Build();
            var firstResponse = await scenario.CachingClient.GetItemAsync <TestItem>(codename);

            scenario = scenarioBuilder.WithResponse(url, updatedItem).Build();
            var secondResponse = await scenario.CachingClient.GetItemAsync <TestItem>(codename);

            firstResponse.Should().NotBeNull();
            firstResponse.Should().BeEquivalentTo(secondResponse);
            scenario.GetRequestCount(url).Should().Be(1);
        }
        public async Task GetItemTypedAsync_InvalidatedByItemKey(CacheTypeEnum cacheType)
        {
            const string codename    = "codename";
            var          url         = $"items/{codename}";
            var          item        = CreateItemResponse(CreateItem(codename, "original"));
            var          updatedItem = CreateItemResponse(CreateItem(codename, "updated"));

            var scenarioBuilder = new ScenarioBuilder(cacheType);

            var scenario      = scenarioBuilder.WithResponse(url, item).Build();
            var firstResponse = await scenario.CachingClient.GetItemAsync <TestItem>(codename);

            scenario = scenarioBuilder.WithResponse(url, updatedItem).Build();
            scenario.InvalidateDependency(CacheHelpers.GetItemKey <TestItem>(codename, Enumerable.Empty <IQueryParameter>()));
            var secondResponse = await scenario.CachingClient.GetItemAsync <TestItem>(codename);

            firstResponse.Should().NotBeNull();
            secondResponse.Should().NotBeNull();
            firstResponse.Should().NotBeEquivalentTo(secondResponse);
            scenario.GetRequestCount(url).Should().Be(2);
        }
        public async Task GetItemJsonAsync_InvalidatedByItemDependency()
        {
            const string codename    = "codename";
            var          url         = $"items/{codename}";
            var          item        = CreateItemResponse(CreateItem(codename, "original"));
            var          updatedItem = CreateItemResponse(CreateItem(codename, "updated"));

            var scenarioBuilder = new ScenarioBuilder();

            var scenario      = scenarioBuilder.WithResponse(url, item).Build();
            var firstResponse = await scenario.CachingClient.GetItemJsonAsync(codename);

            scenario = scenarioBuilder.WithResponse(url, updatedItem).Build();
            scenario.InvalidateDependency(CacheHelpers.GetItemDependencyKey(codename));
            var secondResponse = await scenario.CachingClient.GetItemJsonAsync(codename);

            firstResponse.Should().NotBeNull();
            secondResponse.Should().NotBeNull();
            firstResponse.Should().NotEqual(secondResponse);
            scenario.GetRequestCount(url).Should().Be(2);
        }