Пример #1
0
        public async Task TestQueryItems_Graph()
        {
            //TestCommon.Instance.Mocking = false;

            try
            {
                (string listName, int id, string itemTitle) = await TestAssets.CreateTestListItemAsync(0);

                using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite, 1))
                {
                    context.GraphFirst = true;

                    var query = (from i in context.Web.Lists.GetByTitle(listName).Items
                                 where i.Title == itemTitle
                                 select i)
                                .QueryProperties(l => l.Id, l => l.Title);

                    var queryResult = query.ToList();

                    // Ensure that we have 1 item in the result and that its title is the expected one
                    Assert.IsNotNull(queryResult);
                    Assert.AreEqual(1, queryResult.Count);
                    Assert.AreEqual(itemTitle, queryResult[0].Title);
                }
            }
            finally
            {
                await TestAssets.CleanupTestDedicatedListAsync(2);
            }
        }
Пример #2
0
        public async Task TestQueryGetByIdLINQ_Graph()
        {
            //TestCommon.Instance.Mocking = false;

            try
            {
                (string listName, int id, string itemTitle) = await TestAssets.CreateTestListItemAsync();

                using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite, 1))
                {
                    context.GraphFirst = true;

                    var library   = context.Web.Lists.GetByTitle(listName);
                    var firstItem = library.Items.GetById(1);

                    Assert.IsNotNull(firstItem);
                    Assert.AreEqual(id, firstItem.Id);
                    Assert.AreEqual(firstItem.Title, itemTitle);
                }
            }
            finally
            {
                await TestAssets.CleanupTestDedicatedListAsync(2);
            }
        }