public void QueryStringWithFields_GuardClauses()
        {
            var source = new FakeQueryProvider().CreateQuery <Sample>();

            Assert.Throws <ArgumentNullException>(() => ElasticQueryExtensions.QueryString <Sample>(null, "", new[] { "one", "two" }));
            Assert.Throws <ArgumentNullException>(() => source.QueryString(null, new[] { "one", "two" }));
            Assert.Throws <ArgumentOutOfRangeException>(() => source.QueryString("hi", null));
            Assert.Throws <ArgumentOutOfRangeException>(() => source.QueryString("hi", new string[] { }));
        }
        public void QueryString_GuardClauses()
        {
            var source = new FakeQueryProvider().CreateQuery <Sample>();

            Assert.Throws <ArgumentNullException>(() => ElasticQueryExtensions.QueryString <Sample>(null, ""));
            Assert.Throws <ArgumentNullException>(() => source.QueryString(null));
        }
Exemplo n.º 3
0
        public void QueryStringIsAddedToExpressionTree()
        {
            const string expectedQueryString = "abcdef";
            var          source  = new FakeQueryProvider().CreateQuery <Sample>();
            var          applied = source.QueryString(expectedQueryString);

            Assert.IsAssignableFrom <MethodCallExpression>(applied.Expression);
            var callExpression = (MethodCallExpression)applied.Expression;

            Assert.Equal(2, callExpression.Arguments.Count);
            Assert.IsType <ConstantExpression>(callExpression.Arguments[1]);
            Assert.Equal(((ConstantExpression)callExpression.Arguments[1]).Value, expectedQueryString);
        }
        public void QueryStringWithFieldsIsAddedToExpressionTree()
        {
            const string expectedQueryString = "abcdef";
            var          expectedFields      = new[] { "three", "four" };

            var source  = new FakeQueryProvider().CreateQuery <Sample>();
            var applied = source.QueryString(expectedQueryString, expectedFields);

            Assert.IsAssignableFrom <MethodCallExpression>(applied.Expression);
            var callExpression = (MethodCallExpression)applied.Expression;

            Assert.Equal(3, callExpression.Arguments.Count);
            var queryStringConstantExpression = Assert.IsType <ConstantExpression>(callExpression.Arguments[1]);

            Assert.Equal(queryStringConstantExpression.Value, expectedQueryString);
            var fieldsConstantExpression = Assert.IsType <ConstantExpression>(callExpression.Arguments[2]);

            Assert.Equal(fieldsConstantExpression.Value, expectedFields);
        }
Exemplo n.º 5
0
        public void QueryStringThrowsArgumentNullWhenArgumentIsNull()
        {
            var source = new FakeQueryProvider().CreateQuery <Sample>();

            Assert.Throws <ArgumentNullException>(() => source.QueryString(null));
        }