public void AuthorizeHubAttribute_AuthorizeHubConnection_RequestIsNull_ThrowsArgumentNullException() { //------------Setup for test-------------------------- var authorizationProvider = new Mock<IAuthorizationService>(); var attribute = new AuthorizeHubAttribute(authorizationProvider.Object); //------------Execute Test--------------------------- attribute.AuthorizeHubConnection(new HubDescriptor(), null); //------------Assert Results------------------------- }
static void Verify_AuthorizeHubConnection(bool isAuthenticated, bool isAuthorized) { //------------Setup for test-------------------------- var authorizationProvider = new Mock<IAuthorizationService>(); authorizationProvider.Setup(p => p.IsAuthorized(It.IsAny<IAuthorizationRequest>())).Returns(isAuthorized); var attribute = new AuthorizeHubAttribute(authorizationProvider.Object); //------------Execute Test--------------------------- var response = attribute.AuthorizeHubConnection(new HubDescriptor(), CreateRequest(isAuthenticated: isAuthenticated).Object); //------------Assert Results------------------------- Assert.AreEqual(isAuthenticated && isAuthorized, response); }