Exemplo n.º 1
0
        public void test_THAT_mixed_boolean_expression_IS_translated_successfully()
        {
            var xml =
                "<Query>" +
                "   <Where>" +
                "       <Or>" +
                "           <And>" +
                "               <Eq>" +
                "                   <FieldRef Name=\"foo1\" />" +
                "                   <Value Type=\"Boolean\">1</Value>" +
                "               </Eq>" +
                "               <Eq>" +
                "                   <FieldRef Name=\"foo2\" />" +
                "                   <Value Type=\"Boolean\">0</Value>" +
                "               </Eq>" +
                "           </And>" +
                "           <Eq>" +
                "               <FieldRef Name=\"foo3\" />" +
                "               <Value Type=\"Boolean\">1</Value>" +
                "           </Eq>" +
                "       </Or>" +
                "   </Where>" +
                "</Query>";

            var expr = Camlex.QueryFromString(xml).ToExpression();

            Assert.That(expr.ToString(), Is.EqualTo("Query().Where(x => ((Convert(x.get_Item(\"foo1\")) AndAlso Not(Convert(x.get_Item(\"foo2\")))) OrElse Convert(x.get_Item(\"foo3\"))))"));
        }
Exemplo n.º 2
0
        public void test_THAT_1_order_by_IS_translated_sucessfully()
        {
            string xml =
                "<Query>" +
                "  <OrderBy>" +
                "    <FieldRef Name=\"Modified\" Ascending=\"False\" />" +
                "  </OrderBy>" +
                "</Query>";

            var expr = Camlex.QueryFromString(xml).ToExpression();

            Assert.That(expr.ToString(), Is.EqualTo("Query().OrderBy(x => (x.get_Item(\"Modified\") As Desc))"));
        }
Exemplo n.º 3
0
        public void test_THAT_multiple_groupby_expression_IS_translated_sucessfully()
        {
            var xml =
                "<Query>" +
                "  <GroupBy Collapse=\"True\" GroupLimit=\"10\">" +
                "    <FieldRef Name=\"field1\" />" +
                "    <FieldRef Name=\"field2\" />" +
                "  </GroupBy>" +
                "</Query>";

            var expr = Camlex.QueryFromString(xml).ToExpression();

            Assert.That(expr.ToString(), Is.EqualTo("Query().GroupBy(x => new [] {x.get_Item(\"field1\"), x.get_Item(\"field2\")}, True, 10)"));
        }
Exemplo n.º 4
0
        public void test_THAT_projected_fields_ARE_translated_sucessfully()
        {
            string xml =
                "<Query>" +
                "<ProjectedFields>" +
                "<Field Name=\"test1\" Type=\"Lookup\" List=\"foo1\" ShowField=\"bar1\" />" +
                "<Field Name=\"test2\" Type=\"Lookup\" List=\"foo2\" ShowField=\"bar2\" />" +
                "</ProjectedFields>" +
                "</Query>";

            var expr = Camlex.QueryFromString(xml).ToExpression();

            Assert.That(expr.ToString(), Is.EqualTo("Query().ProjectedFields().Field(x => x.get_Item(\"test1\").List(\"foo1\").ShowField(\"bar1\")).Field(x => x.get_Item(\"test2\").List(\"foo2\").ShowField(\"bar2\"))"));
        }
Exemplo n.º 5
0
        public void test_THAT_expression_with_not_includes_with_lookup_id_IS_translated_successfully()
        {
            string xml =
                "<Query>" +
                "   <Where>" +
                "       <NotIncludes>" +
                "           <FieldRef Name=\"Foo\" LookupId=\"True\" />" +
                "           <Value Type=\"Integer\">1</Value>" +
                "       </NotIncludes>" +
                "   </Where>" +
                "</Query>";

            var expr = Camlex.QueryFromString(xml).ToExpression();

            Assert.That(expr.ToString(), Is.EqualTo("Query().Where(x => Not(Convert(Convert(x.get_Item(\"Foo\"))).Includes(Convert(1), True)))"));
        }
Exemplo n.º 6
0
        public void test_THAT_expression_with_number_IS_translated_successfully()
        {
            var xml =
                "<Query>" +
                "  <Where>" +
                "    <Eq>" +
                "      <FieldRef Name=\"foo\" />" +
                "      <Value Type=\"Number\">1.23</Value>" +
                "    </Eq>" +
                "  </Where>" +
                "</Query>";

            var expr = Camlex.QueryFromString(xml).ToExpression();

            Assert.That(expr.ToString(), Is.EqualTo("Query().Where(x => (Convert(x.get_Item(\"foo\")) == 1.23))"));
        }
Exemplo n.º 7
0
        public void test_THAT_expression_with_lookup_multi_value_IS_translated_successfully()
        {
            var xml =
                "<Query>" +
                "  <Where>" +
                "    <Eq>" +
                "      <FieldRef Name=\"Title\" />" +
                "      <Value Type=\"LookupMulti\">5</Value>" +
                "    </Eq>" +
                "  </Where>" +
                "</Query>";

            var expr = Camlex.QueryFromString(xml).ToExpression();

            Assert.That(expr.ToString(), Is.EqualTo("Query().Where(x => (x.get_Item(\"Title\") == Convert(Convert(\"5\"))))"));
        }
Exemplo n.º 8
0
        public void test_THAT_datetime_with_includetimevalue_and_storagetz_IS_translated_sucessfully()
        {
            string xml =
                "<Query>" +
                "  <Where>" +
                "    <Gt>" +
                "        <FieldRef Name=\"Created\" />" +
                "        <Value Type=\"DateTime\" IncludeTimeValue=\"True\" StorageTZ=\"True\">2021-05-18T17:31:18Z</Value>" +
                "    </Gt>" +
                "  </Where>" +
                "</Query>";

            var expr = Camlex.QueryFromString(xml).ToExpression();

            Assert.That(expr.ToString(), Is.EqualTo("Query().Where(x => (Convert(x.get_Item(\"Created\")) > 5/18/2021 5:31:18 PM.IncludeTimeValue(True)))"));
        }
Exemplo n.º 9
0
        public void test_THAT_inner_join_IS_translated_sucessfully()
        {
            string xml =
                "<Query>" +
                "<Joins>" +
                "<Join Type=\"INNER\" ListAlias=\"Customers\">" +
                "<Eq>" +
                "<FieldRef Name=\"CustomerName\" RefType=\"Id\" />" +
                "<FieldRef List=\"Customers\" Name=\"Id\" />" +
                "</Eq>" +
                "</Join>" +
                "</Joins>" +
                "</Query>";

            var expr = Camlex.QueryFromString(xml).ToExpression();

            Assert.That(expr.ToString(), Is.EqualTo("Query().Joins().Inner(x => x.get_Item(\"CustomerName\").ForeignList(\"Customers\"))"));
        }
Exemplo n.º 10
0
        public void test_THAT_in_expression_IS_translated_successfully()
        {
            var xml =
                "<Query>" +
                "  <Where>" +
                "    <In>" +
                "      <FieldRef Name=\"test\" />" +
                "      <Values>" +
                "        <Value Type=\"Text\">test1</Value>" +
                "        <Value Type=\"Text\">test2</Value>" +
                "      </Values>" +
                "    </In>" +
                "  </Where>" +
                "</Query>";

            var expr = Camlex.QueryFromString(xml).ToExpression();

            Assert.That(expr.ToString(), Is.EqualTo("Query().Where(x => new [] {\"test1\", \"test2\"}.Contains(Convert(x.get_Item(\"test\"))))"));
        }