public void InitializeFromSettings_WithValidSettings_MatchesCorrectly() { var settings = new[] { new RuleSetting { Name = "text.evaluation", Value = "passed" }, new RuleSetting { Name = string.Empty, Value = string.Empty }, new RuleSetting { Name = null, Value = string.Empty }, new RuleSetting { Name = "text.evaluation", Value = string.Empty } }; var rule = new BodyContentRule(); rule.InitializeFromSettings(settings); Assert.IsTrue(rule.IsInitialized); var request = CreateTextRequest("passed"); Assert.IsTrue(rule.IsMatch(request)); }
public void IsMatch_NullContext_ReturnsFalse() { var rule = new BodyContentRule( new string[] { "passed" }); Assert.IsFalse(rule.IsMatch(null)); }
public void IsMatch_RegexTextWithNonMatchingString_ReturnsFalse() { var rule = new BodyContentRule( new string[] { "regex:AA.*ssed.*D" }); var request = CreateTextRequest("failed"); Assert.IsFalse(rule.IsMatch(request)); }
public void IsMatch_ContainsTextWithMatchingString_ReturnsTrue() { var rule = new BodyContentRule( new string[] { "passed", "AAA" }); var request = CreateTextRequest("passed"); Assert.IsTrue(rule.IsMatch(request)); }
public void IsMatch_ContainsTextInversedWithNonMatchingText_ReturnsFalse() { var rule = new BodyContentRule( new string[] { "not:passed" }); var request = CreateTextRequest("passed"); Assert.IsFalse(rule.IsMatch(request)); }
public void IsMatch_BinaryContentWithTextString_ReturnsFalse() { var request = CreateBinaryRequest(); var rule = new BodyContentRule( new string[] { "passed" }); Assert.IsFalse(rule.IsMatch(request)); }
public void IsMatch_WithoutBody_ReturnsFalse() { var request = Substitute.For <IStumpsHttpRequest>(); request.BodyLength.Returns(0); var rule = new BodyContentRule( new string[] { "passed" }); Assert.IsFalse(rule.IsMatch(null)); }
public void IsMatch_ContainsTextWithNonMatchingString_ReturnsFalse() { var ruleCaseMatches = new BodyContentRule( new string[] { "failed", "AAA" }); var ruleCaseDoesNotMatch = new BodyContentRule( new string[] { "PASSED", "AAA" }); var request = CreateTextRequest("passed"); Assert.IsFalse(ruleCaseMatches.IsMatch(request)); // correct text, wrong case Assert.IsFalse(ruleCaseDoesNotMatch.IsMatch(request)); }
public void IsMatch_ContainsTextInversedWithMatchingText_ReturnsTrue() { var rule = new BodyContentRule( new string[] { "not:failed" }); var request = CreateTextRequest("passed"); Assert.IsTrue(rule.IsMatch(request)); }
public void IsMatch_WithoutBody_ReturnsFalse() { var request = Substitute.For<IStumpsHttpRequest>(); request.BodyLength.Returns(0); var rule = new BodyContentRule( new string[] { "passed" }); Assert.IsFalse(rule.IsMatch(null)); }