Пример #1
0
        public void GetValueForSearchQueryRule_SearchQueryRuleIsNull_ThrowsException()
        {
            // Arrange
            SearchQueryRule <TestIndexableEntity> searchQueryRule = null;
            var parameterNameValuePairs = new NameValueCollection();
            var sut = new NameValuePairSearchQueryValueProvider(() => parameterNameValuePairs);

            // Act
            Action act = () => sut.GetValueForSearchQueryRule(searchQueryRule);

            // Assert
            act.ShouldThrow <ArgumentNullException>();
        }
Пример #2
0
        public void GetValueForSearchQueryRule_DynamicValueProvidingParameterNotSetForSearchQueryRule_ReturnsDefaultValue(string defaultValue)
        {
            // Arrange
            var propertySelector        = ExpressionUtils.GetPropertySelector <TestIndexableEntity, object>(TestIndexableEntityPropertyName);
            var searchQueryRule         = new SearchQueryRule <TestIndexableEntity>(propertySelector, ComparisonOperator.Equal, defaultValue: defaultValue);
            var parameterNameValuePairs = new NameValueCollection();
            var sut = new NameValuePairSearchQueryValueProvider(() => parameterNameValuePairs);

            // Act
            var actual = sut.GetValueForSearchQueryRule(searchQueryRule);

            // Assert
            actual.ShouldBeEquivalentTo(defaultValue);
        }
Пример #3
0
        public void GetValueForSearchQueryRule_SingleDynamicValueProvidedByQueryStringParameter_ReturnsSingleValue()
        {
            // Arrange
            var propertySelector        = ExpressionUtils.GetPropertySelector <TestIndexableEntity, object>(TestIndexableEntityPropertyName);
            var searchQueryRule         = new SearchQueryRule <TestIndexableEntity>(propertySelector, ComparisonOperator.Equal, ParameterName);
            var parameterValue          = "someValue";
            var parameterNameValuePairs = new NameValueCollection {
                { ParameterName, parameterValue }
            };
            var sut = new NameValuePairSearchQueryValueProvider(() => parameterNameValuePairs);

            // Act
            var actual = sut.GetValueForSearchQueryRule(searchQueryRule);

            // Assert
            actual.ShouldBeEquivalentTo(parameterValue);
        }