public async Task <ActionResult> CanUserWriteComment() { var result = await _userPermissionProvider.CheckUserPermission( User?.Identity?.GetUserId(), nameof(Permissions.CanWriteComment)); return(Json(result)); }
public async Task Check_permission_should_return_resutlt() { var user = new User(); var role = new IdentityRole(); var userRole = new IdentityUserRole() { User = user, Role = role }; user.Roles.Add(userRole); _userRepository.Setup(x => x.Get(It.IsAny <string>())) .Returns(user); _permissionFacade.Setup(x => x.CheckPermission(It.IsAny <string>(), It.IsAny <IList <string> >(), true)) .Returns(Task.FromResult(true)); var result = await _provider.CheckUserPermission("test", "test"); Assert.That(result, Is.EqualTo(true)); }