예제 #1
0
        public void ExpressionToCamlMapper_Test_DateTime()
        {
            string expected = "<Where><And><Eq><FieldRef Name=\"Title\" /><Value Type=\"Text\">Test</Value></Eq><Leq><FieldRef Name=\"Created\" /><Value Type=\"DateTime\">2019-01-15T00:00:00</Value></Leq></And></Where>";
            string actual   = ExpressionToCamlMapper <MockSPEntity> .MapExpressionToCaml <MockSPEntity>(me => me.Title == "Test" && me.CreatedDate <= new DateTime(2019, 01, 15));

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void ExpressionToCamlMapper_Test_LookupId()
        {
            string expected = "<Where><Eq><FieldRef Name=\"TestLookup\" LookupId=\"TRUE\" /><Value Type=\"Lookup\">1</Value></Eq></Where>";
            string actual   = ExpressionToCamlMapper <MockSPEntity> .MapExpressionToCaml <MockSPEntity>(me => me.TestLookup.Id == 1);

            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        public void ExpressionToCamlMapper_Test_SimpleWhere()
        {
            string expected = "<Where><Eq><FieldRef Name=\"Title\" /><Value Type=\"Text\">Test</Value></Eq></Where>";
            string actual   = ExpressionToCamlMapper <MockSPEntity> .MapExpressionToCaml <MockSPEntity>(me => me.Title == "Test");

            Assert.AreEqual(expected, actual);
        }
예제 #4
0
        public void ExpressionToCamlMapper_Test_SimpleWhere_Date()
        {
            DateTime date     = new DateTime(2019, 06, 01, 12, 00, 00);
            string   expected = "<Where><Eq><FieldRef Name=\"Created\" /><Value Type=\"DateTime\">2019-06-01T12:00:00</Value></Eq></Where>";
            string   actual   = ExpressionToCamlMapper <MockSPEntity> .MapExpressionToCaml <MockSPEntity>(me => me.CreatedDate == date);

            Assert.AreEqual(expected, actual);
        }
예제 #5
0
        public void SPRepository_Test_ComposeCaml_DefaultOrderBy()
        {
            using (ClientContext context = new ClientContext(ConfigurationManager.AppSettings["SiteUrl"]))
            {
                SecureString password = Common.ToSecureString(ConfigurationManager.AppSettings["UserPassword"]);
                context.Credentials = new SharePointOnlineCredentials(ConfigurationManager.AppSettings["UserLogin"], password);
                SPClientRepository <MockSPEntity> repo = new SPClientRepository <MockSPEntity>(context);

                string expectedQuery = "<View><Query><Where><Eq><FieldRef Name=\"Title\" /><Value Type=\"Text\">Test</Value></Eq></Where></Query><RowLimit>10</RowLimit><ViewFields><FieldRef Name=\"ID\" /><FieldRef Name=\"Title\" /><FieldRef Name=\"Created\" /><FieldRef Name=\"TestLookup\" /></ViewFields><OrderBy><FieldRef Name=\"ID\" Ascending=\"FALSE\"/></OrderBy></View>";
                string whereSection  = ExpressionToCamlMapper <MockSPEntity> .MapExpressionToCaml <MockSPEntity>(me => me.Title == "Test");

                string actualQuery = repo.ComposeQuery(whereSection, 10);

                Assert.AreEqual(expectedQuery, actualQuery);
            }
        }