コード例 #1
0
        public void TestMatchesWithIncorrectContentTypeIsFalse()
        {
            var matcher = new ContentTypeMatcher("application/json");
            var message = new HttpRequestMessage();

            message.Content = new ByteArrayContent(Encoding.UTF8.GetBytes("true"));
            message.Content.Headers.ContentType = new MediaTypeHeaderValue("text/plain");

            Assert.False(matcher.Matches(message));
        }
コード例 #2
0
        public void ContentTypeMatcher_GetPatterns()
        {
            // Assign
            var matcher = new ContentTypeMatcher("x");

            // Act
            var patterns = matcher.GetPatterns();

            // Assert
            Check.That(patterns).ContainsExactly("x");
        }
コード例 #3
0
        public void ContentTypeMatcher_GetName()
        {
            // Assign
            var matcher = new ContentTypeMatcher("x");

            // Act
            string name = matcher.Name;

            // Assert
            Check.That(name).Equals("ContentTypeMatcher");
        }
コード例 #4
0
        public void TestMatchesWithIncorrectCharSetIsFalse()
        {
            var matcher = new ContentTypeMatcher("text/plain; charset=utf-8");
            var message = new HttpRequestMessage();

            message.Content = new ByteArrayContent(Encoding.UTF32.GetBytes("true"));
            message.Content.Headers.ContentType = new MediaTypeHeaderValue("text/plain")
            {
                CharSet = "utf-32"
            };

            Assert.False(matcher.Matches(message));
        }
コード例 #5
0
        public void TestMatchesWithPartialCorrectContentTypeIsTrue()
        {
            var matcher = new ContentTypeMatcher("text/plain");
            var message = new HttpRequestMessage();

            message.Content = new ByteArrayContent(Encoding.UTF8.GetBytes("true"));
            message.Content.Headers.ContentType = new MediaTypeHeaderValue("text/plain")
            {
                CharSet = "utf-8"
            };

            Assert.True(matcher.Matches(message));
        }
コード例 #6
0
        public void ContentTypeMatcher_IsMatchWithIgnoreCaseTrue_Positive(string contentType)
        {
            var matcher = new ContentTypeMatcher("application/json", true);

            Check.That(matcher.IsMatch(contentType)).IsEqualTo(1.0d);
        }