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)); }
public void ContentTypeMatcher_GetPatterns() { // Assign var matcher = new ContentTypeMatcher("x"); // Act var patterns = matcher.GetPatterns(); // Assert Check.That(patterns).ContainsExactly("x"); }
public void ContentTypeMatcher_GetName() { // Assign var matcher = new ContentTypeMatcher("x"); // Act string name = matcher.Name; // Assert Check.That(name).Equals("ContentTypeMatcher"); }
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)); }
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)); }
public void ContentTypeMatcher_IsMatchWithIgnoreCaseTrue_Positive(string contentType) { var matcher = new ContentTypeMatcher("application/json", true); Check.That(matcher.IsMatch(contentType)).IsEqualTo(1.0d); }