예제 #1
0
        public async Task GetSiteUserCustomActionsTest()
        {
            //TestCommon.Instance.Mocking = false;
            (string customActionName, Guid customActionId) = await TestAssets.CreateTestUserCustomActionAsync(0, addToSiteCollection : true);

            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite, 1))
            {
                ISite site = await context.Site.GetAsync(p => p.UserCustomActions);

                Assert.IsNotNull(site.UserCustomActions);
                Assert.IsTrue(site.UserCustomActions.Length > 0);

                IUserCustomAction foundCustomAction = site.UserCustomActions.AsRequested().FirstOrDefault(uca => uca.Id == customActionId);

                Assert.IsNotNull(foundCustomAction);
                Assert.AreEqual(customActionId, foundCustomAction.Id);
                Assert.AreEqual(UserCustomActionScope.Site, foundCustomAction.Scope);
                foreach (var permissionKind in TestAssets.CustomActionPermissions)
                {
                    Assert.IsTrue(foundCustomAction.Rights.Has(permissionKind));
                }
            }

            await TestAssets.CleanupTestUserCustomActionAsync(2, fromSiteCollection : true);
        }
예제 #2
0
        public async Task GetWebUserCustomActionsTest()
        {
            //TestCommon.Instance.Mocking = false;
            (string customActionName, Guid customActionId) = await TestAssets.CreateTestUserCustomActionAsync(0);

            using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite, 1))
            {
                await context.Web.LoadAsync(p => p.UserCustomActions);

                var web = context.Web;

                Assert.IsNotNull(web.UserCustomActions);
                Assert.IsTrue(web.UserCustomActions.Length > 0);

                IUserCustomAction foundCustomAction = web.UserCustomActions.AsRequested().FirstOrDefault(uca => uca.Id == customActionId);

                Assert.IsNotNull(foundCustomAction);
                Assert.AreEqual(customActionId, foundCustomAction.Id);
                Assert.AreEqual(UserCustomActionScope.Web, foundCustomAction.Scope);
                foreach (var permissionKind in TestAssets.CustomActionPermissions)
                {
                    Assert.IsTrue(foundCustomAction.Rights.Has(permissionKind));
                }
            }

            await TestAssets.CleanupTestUserCustomActionAsync(2);
        }