public void OnAuthentication(AuthenticationContext filterContext) { try { filterContext.Result = GetCodeResult(filterContext); } catch (Exception ex) { ErrorSignaler.SignalFromCurrentContext(ex); throw new BlogException(ex.Message, ex.InnerException); } }
public void ShouldReturnUnauthorizedWhenNotAuthenticated() { _requestBase.SetupGet(r => r.IsAuthenticated).Returns(false); var attribute = new BlogAuthorizationAttribute(); attribute.OnAuthentication(_authenticationContext.Object); Assert.IsInstanceOf(typeof(HttpUnauthorizedResult), _authenticationContext.Object.Result); }