public void ControllerShoulBeForAuthorizedUsersOnly() { //Arrange var controller = new AdminTownsController(null); //Act var attributes = controller.GetType().GetCustomAttributes(true); //Assert attributes.Any(a => a.GetType() == typeof(AuthorizeAttribute)); }
public void ControllerShoulBeForAdminsOnly() { //Arrange var controller = new AdminTownsController(null); //Act var attributes = controller.GetType().GetCustomAttributes(true); //Assert var authorizeAttribute = attributes.FirstOrDefault(a => a.GetType() == typeof(AuthorizeAttribute)); authorizeAttribute.As <AuthorizeAttribute>().Roles.Should().Be(Role.Administrator.ToString()); }
public void ControllerShoulBeInAdminArea() { //Arrange var controller = new AdminTownsController(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)); areaAttribute.As <AreaAttribute>().RouteValue.Should().Be(WebConstants.Area.Admin); }