Exemplo n.º 1
0
        /// <summary>
        /// Extension method to declare a field/metadata property to load while executing the REST query
        /// </summary>
        /// <typeparam name="TResult">The type of the target entity</typeparam>
        /// <param name="source">The collection of items to load the field/metadata from</param>
        /// <param name="selectors">A selector for a field/metadata</param>
        /// <returns>The resulting collection</returns>
        public static ISupportQuery <TResult> QueryProperties <TResult>(
#pragma warning disable IDE0060 // Remove unused parameter
#pragma warning disable CA1801  // Review unused parameters
            this ISupportQuery <TResult> source, params Expression <Func <TResult, object> >[] selectors)
#pragma warning restore CA1801  // Review unused parameters
#pragma warning restore IDE0060 // Remove unused parameter
        {
            throw new InvalidOperationException(PnPCoreResources.Exception_Unsupported_QueryPropertiesUse);
        }
        public async Task TestQueryProperties()
        {
            //TestCommon.Instance.Mocking = false;
            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite))
            {
                Assert.ThrowsException <InvalidOperationException>(() =>
                {
                    ISupportQuery <Model.SharePoint.IList> bla = null;
                    bla.QueryProperties();
                });

                Assert.ThrowsException <ArgumentNullException>(() =>
                {
                    IQueryable <Model.SharePoint.IList> bla = null;
                    bla.QueryProperties();
                });

                Assert.ThrowsException <ArgumentNullException>(() =>
                {
                    IQueryable <Model.SharePoint.IList> bla = context.Web.Lists;
                    bla.QueryProperties(null);
                });
            }
        }