protected override void Given()
        {
            base.Given();

            MockAuthorizationService
            .Setup(
                m => m.AuthorizeAsync(
                    It.IsAny <ClaimsPrincipal>(),
                    It.IsAny <object>(),
                    PolicyNames.CanSubmitReport))
            .Returns(
                Task.FromResult(AuthorizationResult.Failed()));
            MockAuthorizationService
            .Setup(
                m => m.AuthorizeAsync(
                    It.IsAny <ClaimsPrincipal>(),
                    It.IsAny <object>(),
                    PolicyNames.CanEditReport))
            .Returns(
                Task.FromResult(AuthorizationResult.Failed()));
        }
예제 #2
0
 protected void SetupAuthorization(bool isAuthorized)
 {
     MockAuthorizationService
     .Setup(x => x.AuthorizeAsync(It.IsAny <ClaimsPrincipal>(), null, It.IsAny <IEnumerable <IAuthorizationRequirement> >()))
     .ReturnsAsync(isAuthorized ? AuthorizationResult.Success() : AuthorizationResult.Failed());
 }