Exemplo n.º 1
0
        public void read_should_not_throw_exception_when_duplicate_api_versions_are_requested()
        {
            // arrange
            var request = new HttpRequestMessage(Get, "http://localhost/test?api-version=1.0&api-version=1.0");
            var reader  = new QueryStringApiVersionReader();

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

            // assert
            version.Should().Be("1.0");
        }
Exemplo n.º 2
0
        public void read_should_throw_exception_when_ambiguous_api_versions_are_requested()
        {
            // arrange
            var request = new HttpRequestMessage(Get, "http://localhost/test?api-version=1.0&api-version=2.0");
            var reader  = new QueryStringApiVersionReader();

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

            // assert
            read.ShouldThrow <AmbiguousApiVersionException>().And.ApiVersions.Should().BeEquivalentTo("1.0", "2.0");
        }
Exemplo n.º 3
0
        public void read_should_return_null_when_query_parameter_is_empty()
        {
            // arrange
            var request = new HttpRequestMessage(Get, "http://localhost/test?api-version=");
            var reader  = new QueryStringApiVersionReader();

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

            // assert
            version.Should().BeNull();
        }
        public void read_should_not_throw_exception_when_duplicate_api_versions_are_requested(string requestUri)
        {
            // arrange
            var request = new HttpRequestMessage(Get, requestUri);
            var reader  = new QueryStringApiVersionReader("api-version", "version");

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

            // assert
            version.Should().Be("1.0");
        }
        public void read_should_throw_exception_when_ambiguous_api_versions_are_requested(string requestUri)
        {
            // arrange
            var request = new HttpRequestMessage(Get, requestUri);
            var reader  = new QueryStringApiVersionReader("api-version", "version");

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

            // assert
            read.Should().Throw <AmbiguousApiVersionException>().And.ApiVersions.Should().BeEquivalentTo("1.0", "2.0");
        }
Exemplo n.º 6
0
        public void read_should_retrieve_version_from_query_string()
        {
            // arrange
            var requestedVersion = "2.1";
            var request          = new HttpRequestMessage(Get, $"http://localhost/test?api-version={requestedVersion}");
            var reader           = new QueryStringApiVersionReader();

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

            // assert
            version.Should().Be(requestedVersion);
        }