Ejemplo n.º 1
0
        public void ControllerShouldBeForAuthorizedUsersOnly()
        {
            //Arrange
            var controller = new AdminStationsController(null, null);

            //Act
            var attributes = controller.GetType().GetCustomAttributes(true);

            //Assert
            attributes.Any(a => a.GetType() == typeof(AuthorizeAttribute));
        }
Ejemplo n.º 2
0
        public void ControllerShouldBeInAdminArea()
        {
            //Arrange
            var controller = new AdminStationsController(null, null);

            //Act
            var attributes = controller.GetType().GetCustomAttributes(true);

            //Assert
            attributes.Any(a => a.GetType() == typeof(AreaAttribute));
            var areaAttribute = attributes.FirstOrDefault(a => a.GetType() == typeof(AreaAttribute)).As <AreaAttribute>();

            areaAttribute.RouteValue.Should().Be(WebConstants.Area.Admin);
        }
Ejemplo n.º 3
0
        public void ControllerShouldBeForAdministratorsOnly()
        {
            //Arrange
            var controller = new AdminStationsController(null, null);

            //Act
            var attributes = controller.GetType().GetCustomAttributes(true);

            //Assert
            attributes.Any(a => a.GetType() == typeof(AuthorizeAttribute));
            var authorizeAttribute = attributes.FirstOrDefault(a => a.GetType() == typeof(AuthorizeAttribute)).As <AuthorizeAttribute>();

            authorizeAttribute.Roles.Should().Be(Role.Administrator.ToString());
        }