示例#1
0
        public void Given_uriString_when_matching_should_match(string uriString, bool hasWildcard, string requestUri, bool isMatch)
        {
            var request = new HttpRequestMessage
            {
                RequestUri = new Uri(requestUri, UriKind.Absolute)
            };

            _sut = new RequestUriMatcher(uriString, hasWildcard);

            // Act & assert
            _sut.IsMatch(new MockHttpRequestContext(request)).Should().Be(isMatch);
        }
示例#2
0
        public void When_formatting_should_return_human_readable_representation()
        {
            const string expectedText = "RequestUri: '*/controller/*'";

            _sut = new RequestUriMatcher("*/controller/*");

            // Act
            string displayText = _sut.ToString();

            // Assert
            displayText.Should().Be(expectedText);
        }
示例#3
0
        public void Given_null_context_when_matching_it_should_throw()
        {
            _sut = new RequestUriMatcher("*/controller/*");
            MockHttpRequestContext requestContext = null;

            // Act
            // ReSharper disable once ExpressionIsAlwaysNull
            Action act = () => _sut.IsMatch(requestContext);

            // Assert
            act.Should()
            .Throw <ArgumentNullException>()
            .WithParamName(nameof(requestContext));
        }