public void FieldsParameter002()
        {
            // Arrange
            var    expected = JObject.Parse(@"
            {
              ""fields"": [
                ""_id_"",
                ""_score_""
              ]
            }");
            string actual;
            var    jObject           = new JObject();
            var    expressionCache   = new ExpressionCache <TestDocument>();
            var    expressionBuilder = (IExpressionBuilder <TestDocument>) new ExpressionBuilder <TestDocument>(expressionCache);
            var    parameter         = new FieldsParameter <TestDocument>(expressionBuilder);

            parameter.Configure(q => q.Id, q => q.Score);

            // Act
            parameter.Execute(jObject);
            actual = jObject.ToString();

            // Assert
            Assert.Equal(expected.ToString(), actual);
        }
        public void FieldsParameter005()
        {
            // Arrange
            var expressionCache   = new ExpressionCache <TestDocument>();
            var expressionBuilder = (IExpressionBuilder <TestDocument>) new ExpressionBuilder <TestDocument>(expressionCache);
            var parameter         = new FieldsParameter <TestDocument>(expressionBuilder);

            // Act / Assert
            Assert.Throws <ArgumentException>(() => parameter.Configure(new Expression <Func <TestDocument, object> >[] { }));
        }
        public void FieldsParameter004()
        {
            // Arrange
            var expressionCache   = new ExpressionCache <TestDocument>();
            var expressionBuilder = (IExpressionBuilder <TestDocument>) new ExpressionBuilder <TestDocument>(expressionCache);
            var parameter         = new FieldsParameter <TestDocument>(expressionBuilder);

            // Act / Assert
            Assert.Throws <ArgumentNullException>(() => parameter.Configure(null));
        }
        public void FieldsParameter003()
        {
            // Arrange
            bool   actual;
            string dummy;
            var    expressionCache   = new ExpressionCache <TestDocumentWithAttribute>();
            var    expressionBuilder = (IExpressionBuilder <TestDocumentWithAttribute>) new ExpressionBuilder <TestDocumentWithAttribute>(expressionCache);
            var    parameter         = new FieldsParameter <TestDocumentWithAttribute>(expressionBuilder);

            parameter.Configure(q => q.Stored, q => q.NotStored);

            // Act
            parameter.Validate(out actual, out dummy);

            // Assert
            Assert.False(actual);
        }
        public void FieldsParameter006()
        {
            // Arrange
            bool   isValid;
            string errorMessage;
            var    expressionCache   = new ExpressionCache <TestDocumentWithAttribute>();
            var    expressionBuilder = (IExpressionBuilder <TestDocumentWithAttribute>) new ExpressionBuilder <TestDocumentWithAttribute>(expressionCache);
            var    parameter         = new FieldsParameter <TestDocumentWithAttribute>(expressionBuilder);

            parameter.Configure(q => q.Stored);

            // Act
            parameter.Validate(out isValid, out errorMessage);

            // Assert
            Assert.True(isValid);
        }
        public void FieldsParameter007()
        {
            // Arrange
            bool   isValid;
            string errorMessage;
            var    expressionCache   = new ExpressionCache <TestDocumentWithAttribute>();
            var    expressionBuilder = (IExpressionBuilder <TestDocumentWithAttribute>) new ExpressionBuilder <TestDocumentWithAttribute>(expressionCache);
            var    parameter         = new FieldsParameter <TestDocumentWithAttribute>(expressionBuilder);

            parameter.Configure(q => q.NotStored);

            // Act
            parameter.Validate(out isValid, out errorMessage);

            // Assert
            Assert.False(isValid);
            Assert.Equal(Resource.FieldMustBeStoredTrueToBeUsedInFieldsException, errorMessage);
        }