Esempio n. 1
0
        public async Task UserHasPermissionOnEntity_ReturnsFalse(UserPermissions up)
        {
            var pm = new Mock <IPermissionManager>();

            pm.Setup(p => p.GetUserPermissions(It.IsAny <string>())).ReturnsAsync(up);

            var res = await PermissionManagerExtensions.UserHasPermissionOnEntity(pm.Object, uId, ek, pk, eId);

            res.ShouldBeFalse();
        }
Esempio n. 2
0
        public async Task UserHasPermissionOnEntity_ReturnsTrue()
        {
            var up = new UserPermissions
            {
                UserId            = uId,
                EntityPermissions = new[]
                {
                    new EntityPermission
                    {
                        EntityId       = eId,
                        EntityKey      = ek,
                        PermissionKeys = new [] { pk }
                    }
                }
            };
            var pm = new Mock <IPermissionManager>();

            pm.Setup(p => p.GetUserPermissions(It.IsAny <string>())).ReturnsAsync(up);

            var res = await PermissionManagerExtensions.UserHasPermissionOnEntity(pm.Object, uId, ek, pk, eId);

            res.ShouldBeTrue();
        }