public void GetRuleSettings_WhenCalled_ReturnsList() { var rule = new HeaderRule("a", "b"); var list = new List <RuleSetting>(rule.GetRuleSettings()); Assert.AreEqual(2, list.Count); }
public void InitializeFromSettings_WithNullSettings_ThrowsException() { var rule = new HeaderRule(); Assert.That( () => rule.InitializeFromSettings(null), Throws.Exception.TypeOf <ArgumentNullException>().With.Property("ParamName").EqualTo("settings")); }
public void InitializeFromSettings_WithNullSettings_ThrowsException() { var rule = new HeaderRule(); Assert.That( () => rule.InitializeFromSettings(null), Throws.Exception.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("settings")); }
public void IsMatch_WithRegexNameAndExactValue_ReturnsExpected( string headerName, string headerValue, bool expectedResult) { var rule = new HeaderRule("regex:he.*me", "headervalue"); var request = CreateWithHeaders(headerName, headerValue); Assert.AreEqual(expectedResult, rule.IsMatch(request)); }
public void IsMatch_WithExactNameAndRegexValueInversed_ReturnsExpected( string headerName, string headerValue, bool expectedResult) { var rule = new HeaderRule("headername", "not:regex:he.*ue"); var request = CreateWithHeaders(headerName, headerValue); Assert.AreEqual(expectedResult, rule.IsMatch(request)); }
public void IsMatch_HeadersAreNull_ReturnsFalse() { var rule = new HeaderRule(string.Empty, string.Empty); var request = Substitute.For <IStumpsHttpRequest>(); IHttpHeaders dict = null; request.Headers.Returns(dict); Assert.IsFalse(rule.IsMatch(request)); }
public void IsMatch_HeadersAreNull_ReturnsFalse() { var rule = new HeaderRule(string.Empty, string.Empty); var request = Substitute.For<IStumpsHttpRequest>(); IHttpHeaders dict = null; request.Headers.Returns(dict); Assert.IsFalse(rule.IsMatch(request)); }
public void InitializeFromSettings_WithValidSettings_InitializesCorrectly(string headerName, string headerValue, string expectedName, string expectedValue) { var settings = new[] { new RuleSetting { Name = "header.name", Value = headerName }, new RuleSetting { Name = "header.value", Value = headerValue } }; var rule = new HeaderRule(); rule.InitializeFromSettings(settings); Assert.IsTrue(rule.IsInitialized); Assert.AreEqual(expectedName, rule.HeaderNameTextMatch); Assert.AreEqual(expectedValue, rule.HeaderValueTextMatch); }
public void IsMatch_RequestIsNull_ReturnsFalse() { var rule = new HeaderRule(string.Empty, string.Empty); Assert.IsFalse(rule.IsMatch(null)); }
public void Constructor_Default_NotInitialized() { var rule = new HeaderRule(); Assert.IsFalse(rule.IsInitialized); }
public void GetRuleSettings_WhenCalled_ReturnsList() { var rule = new HeaderRule("a", "b"); var list = new List<RuleSetting>(rule.GetRuleSettings()); Assert.AreEqual(2, list.Count); }
public void IsMatch_WithRegexNameInversedAndExactValue_ReturnsExpected( string headerName, string headerValue, bool expectedResult) { var rule = new HeaderRule("not:regex:he.*me", "headervalue"); var request = CreateWithHeaders(headerName, headerValue); Assert.AreEqual(expectedResult, rule.IsMatch(request)); }
public void IsMatch_WithExactNameAndRegexValue_ReturnsExpected( string headerName, string headerValue, bool expectedResult) { var rule = new HeaderRule("headername", "regex:he.*ue"); var request = CreateWithHeaders(headerName, headerValue); Assert.AreEqual(expectedResult, rule.IsMatch(request)); }