Inheritance: System.Attribute, IAuthorizeHubConnection, IAuthorizeHubMethodInvocation
Ejemplo n.º 1
0
        public void AuthorizeHubAttribute_Constructor_AuthorizationProviderIsNull_ThrowsArgumentNullException()
        {
            //------------Setup for test--------------------------

            //------------Execute Test---------------------------
            var attribute = new AuthorizeHubAttribute(null);

            //------------Assert Results-------------------------
        }
Ejemplo n.º 2
0
        public void AuthorizeHubAttribute_Constructor_Default_ProviderIsAuthorizationProviderInstance()
        {
            //------------Setup for test--------------------------

            //------------Execute Test---------------------------
            var attribute = new AuthorizeHubAttribute();

            //------------Assert Results-------------------------
            Assert.AreSame(ServerAuthorizationService.Instance, attribute.Service);
        }
Ejemplo n.º 3
0
        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-------------------------
        }
Ejemplo n.º 4
0
        static void Verify_AuthorizeHubMethodInvocation(bool isAuthenticated, bool isAuthorized, string methodName = null)
        {
            //------------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.AuthorizeHubMethodInvocation(CreateHubIncomingInvokerContext(isAuthenticated, methodName), false);

            //------------Assert Results-------------------------
            Assert.AreEqual(isAuthenticated && isAuthorized, response);
        }
Ejemplo n.º 5
0
        public void AuthorizeHubAttribute_AuthorizeHubMethodInvocation_HubIncomingInvokerContextIsNull_ThrowsArgumentNullException()
        {
            //------------Setup for test--------------------------
            var authorizationProvider = new Mock<IAuthorizationService>();
            var attribute = new AuthorizeHubAttribute(authorizationProvider.Object);

            //------------Execute Test---------------------------
            attribute.AuthorizeHubMethodInvocation(null, false);

            //------------Assert Results-------------------------
        }
Ejemplo n.º 6
0
        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);
        }