Пример #1
0
        public void read_should_throw_exception_when_ambiguous_api_versions_are_requested()
        {
            // arrange
            var request = new HttpRequestMessage();
            var reader  = new HeaderApiVersionReader("api-version");

            request.Headers.TryAddWithoutValidation("api-version", new[] { "1.0", "2.0" });

            // act
            Action read = () => reader.Read(request);

            // assert
            read.ShouldThrow <AmbiguousApiVersionException>().And.ApiVersions.Should().BeEquivalentTo("1.0", "2.0");
        }
Пример #2
0
        public void read_should_retrieve_version_from_header(string headerName, string requestedVersion)
        {
            // arrange
            var request = new HttpRequestMessage();
            var reader  = new HeaderApiVersionReader("api-version", "x-ms-version");

            request.Headers.TryAddWithoutValidation(headerName, requestedVersion);

            // act
            var version = reader.Read(request);

            // assert
            version.Should().Be(requestedVersion);
        }
Пример #3
0
        public void read_should_not_throw_exception_when_duplicate_api_versions_are_requested()
        {
            // arrange
            var request = new HttpRequestMessage();
            var reader  = new HeaderApiVersionReader("api-version", "x-ms-version");

            request.Headers.TryAddWithoutValidation("api-version", "1.0");
            request.Headers.TryAddWithoutValidation("x-ms-version", "1.0");

            // act
            var version = reader.Read(request);

            // assert
            version.Should().Be("1.0");
        }