public void QuerystringPersonalisationGroupCriteria_MatchesVisitor_WithEmptyDefinition_ThrowsException()
        {
            // Arrange
            var mockQuerystringProvider = MockQuerystringProvider();
            var criteria = new QuerystringPersonalisationGroupCriteria(mockQuerystringProvider.Object);

            // Act
            Assert.Throws <ArgumentNullException>(() => criteria.MatchesVisitor(null));
        }
        public void QuerystringPersonalisationGroupCriteria_MatchesVisitor_WithEmptyDefinition_ThrowsException()
        {
            // Arrange
            var mockQuerystringProvider = MockQuerystringProvider();
            var criteria = new QuerystringPersonalisationGroupCriteria(mockQuerystringProvider.Object);

            // Act
            criteria.MatchesVisitor((string)null);
        }
        public void QuerystringPersonalisationGroupCriteria_MatchesVisitor_WithInvalidDefinition_ThrowsException()
        {
            // Arrange
            var mockQuerystringProvider = MockQuerystringProvider();
            var criteria   = new QuerystringPersonalisationGroupCriteria(mockQuerystringProvider.Object);
            var definition = "invalid";

            // Act
            criteria.MatchesVisitor(definition);
        }
        public void QuerystringPersonalisationGroupCriteria_MatchesVisitor_WithDefinitionForQuerystringContainingValue_WithNonMatchingQuerystring_ReturnsFalse()
        {
            // Arrange
            var mockQuerystringProvider = MockQuerystringProvider();
            var criteria   = new QuerystringPersonalisationGroupCriteria(mockQuerystringProvider.Object);
            var definition = string.Format(DefinitionFormat, "key", "ContainsValue", "xxx");

            // Act
            var result = criteria.MatchesVisitor(definition);

            // Assert
            Assert.IsFalse(result);
        }
        public void QuerystringPersonalisationGroupCriteria_MatchesVisitor_WithDefinitionDoesNotMatchRegex_WithNonMatchingQuerystring_ReturnsTrue()
        {
            // Arrange
            var mockQuerystringProvider = MockQuerystringProvider();
            var criteria   = new QuerystringPersonalisationGroupCriteria(mockQuerystringProvider.Object);
            var definition = string.Format(DefinitionFormat, "regexTest", "DoesNotMatchRegex", "[A-Z]");

            // Act
            var result = criteria.MatchesVisitor(definition);

            // Assert
            Assert.IsTrue(result);
        }
        public void QuerystringPersonalisationGroupCriteria_MatchesVisitor_WithDefinitionForLessThanStringValue_WithMatchingQuerystring_ReturnsTrue()
        {
            // Arrange
            var mockQuerystringProvider = MockQuerystringProvider();
            var criteria   = new QuerystringPersonalisationGroupCriteria(mockQuerystringProvider.Object);
            var definition = string.Format(DefinitionFormat, "stringCompareTest", "LessThanValue", "ccc");

            // Act
            var result = criteria.MatchesVisitor(definition);

            // Assert
            Assert.IsTrue(result);
        }
        public void QuerystringPersonalisationGroupCriteria_MatchesVisitor_WithDefinitionForGreaterThanNumericValue_WithNonMatchingQuerystring_ReturnsFalse()
        {
            // Arrange
            var mockQuerystringProvider = MockQuerystringProvider();
            var criteria   = new QuerystringPersonalisationGroupCriteria(mockQuerystringProvider.Object);
            var definition = string.Format(DefinitionFormat, "numericCompareTest", "GreaterThanValue", "7");

            // Act
            var result = criteria.MatchesVisitor(definition);

            // Assert
            Assert.IsFalse(result);
        }