public void TestCacheReadDelegatingHandler_ThrowsException_OnFileMissing()
        {
            File.Exists(Path.Combine(ResponseFilesPath, "services.odata.org", "missing-testcache-file")).Should().BeFalse();
            var    handler = new TestCacheReadDelegatingHandler(ResponseFilesPath);
            var    request = new HttpRequestMessage(HttpMethod.Get, "https://services.odata.org/missing-testcache-file");
            Action act     = () => handler.SendAsyncInternal(request).GetAwaiter().GetResult();

            act.Should().Throw <InvalidOperationException>().WithMessage("No test cache response file could be found at the path: *");
        }
        public async Task TestCacheReadDelegatingHandler_CanReadFile(string mediaType, string directoryPath, string fileName, string requestUri)
        {
            var handler = new TestCacheReadDelegatingHandler(ResponseFilesPath);
            var request = new HttpRequestMessage(HttpMethod.Get, requestUri);

            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(mediaType));
            var response = await handler.SendAsyncInternal(request);

            response.StatusCode.Should().Be(HttpStatusCode.OK);
            var content = await response.Content.ReadAsStringAsync();

            content.Should().NotBeNullOrEmpty();
        }
        public async Task TestCacheReadDelegatingHandler_MediaType_ReflectsFileExtension()
        {
            File.Exists(Path.Combine(ResponseFilesPath, "services.odata.org", "metadata.xml")).Should().BeTrue();
            var handler = new TestCacheReadDelegatingHandler(ResponseFilesPath);
            var request = new HttpRequestMessage(HttpMethod.Get, "https://services.odata.org/$metadata");

            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml"));
            var response = await handler.SendAsyncInternal(request);

            response.StatusCode.Should().Be(HttpStatusCode.OK);
            response.Content.Headers.ContentType.ToString().Should().StartWith("text/xml");
            var content = await response.Content.ReadAsStringAsync();

            content.Should().NotBeNullOrEmpty();
        }