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)); }
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); }
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()); }