void Verify_IsAuthorized(WindowsGroupPermission configPermissions, TestAuthorizationRequest authorizationRequest) { //------------Setup for test-------------------------- var allowedPermissions = AuthorizationHelpers.ToPermissions(authorizationRequest.AuthorizationContext); var expected = authorizationRequest.UserIsInRole && (configPermissions.Permissions & allowedPermissions) != 0; var securityService = new Mock <ISecurityService>(); securityService.SetupGet(p => p.Permissions).Returns(new[] { configPermissions }); var authorizationService = new TestServerAuthorizationService(securityService.Object); //------------Execute Test--------------------------- var authorized = authorizationService.IsAuthorized(authorizationRequest); //------------Assert Results------------------------- Assert.AreEqual(expected, authorized, string.Format("\nUserIsInRole: {0}\nAllowed: {1}\nConfig: {2}\nIsServer: {3}\nURL: {4}", authorizationRequest.UserIsInRole, allowedPermissions, configPermissions.Permissions, configPermissions.IsServer, authorizationRequest.Url)); }