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 GetRuleSettings_WhenCalled_ReturnsList() { var rule = new BodyContentRule(new string[] { "Hello" }); var list = new List <RuleSetting>(rule.GetRuleSettings()); Assert.AreEqual(1, list.Count); }
public void InitializeFromSettings_WithNullSettings_ThrowsException() { var rule = new BodyContentRule(); Assert.That( () => rule.InitializeFromSettings(null), Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("settings")); }
public void InitializeFromSettings_WithNullSettings_ThrowsException() { var rule = new BodyContentRule(); Assert.That( () => rule.InitializeFromSettings(null), Throws.Exception.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("settings")); }
public void InitializeFromSettings_WhenInitialized_ThrowsException() { var rule = new BodyContentRule(new string[] { "ABCD" }); var settings = new[] { new RuleSetting { Name = "text.evaluation", Value = "passed" } }; Assert.That( () => rule.InitializeFromSettings(settings), Throws.Exception.TypeOf<InvalidOperationException>()); }
public void IsMatch_NullContext_ReturnsFalse() { var rule = new BodyContentRule( new string[] { "passed" }); Assert.IsFalse(rule.IsMatch(null)); }
public void InitializeFromSettings_WhenInitialized_ThrowsException() { var rule = new BodyContentRule(new string[] { "ABCD" }); var settings = new[] { new RuleSetting { Name = "text.evaluation", Value = "passed" } }; Assert.That( () => rule.InitializeFromSettings(settings), Throws.Exception.TypeOf <InvalidOperationException>()); }
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 Constructor_ListOfStrings_Initialized() { var rule = new BodyContentRule(new string[] { "Test1", "Test2" }); Assert.True(rule.IsInitialized); }
public void GetRuleSettings_WhenCalled_ReturnsList() { var rule = new BodyContentRule(new string[] { "Hello" }); var list = new List<RuleSetting>(rule.GetRuleSettings()); Assert.AreEqual(1, list.Count); }
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 Constructor_Default_NotInitialized() { var rule = new BodyContentRule(); Assert.IsFalse(rule.IsInitialized); }
public void IsMatch_ContainsTextInversedWithMatchingText_ReturnsTrue() { var rule = new BodyContentRule( new string[] { "not:failed" }); var request = CreateTextRequest("passed"); Assert.IsTrue(rule.IsMatch(request)); }