public void IsDefinedCallsTypeIsDefined() { // Arrange Mock <Type> mockType = new Mock <Type>(); mockType.Setup(t => t.IsDefined(typeof(ObsoleteAttribute), true)).Returns(true); ReflectedControllerDescriptor cd = new ReflectedControllerDescriptor(mockType.Object); // Act bool isDefined = cd.IsDefined(typeof(ObsoleteAttribute), true); // Assert Assert.True(isDefined); }
protected override void ExecuteCore() { Type controllerType = this.ControllerContext.Controller.GetType(); ControllerDescriptor controllerDescriptor = new ReflectedControllerDescriptor(controllerType); if (controllerDescriptor.IsDefined(typeof(SpecialSetUpAttribute), true)) { //Do special setup } else { //Do normal setup } base.ExecuteCore(); }
protected override void ExecuteCore() { Type controllerType = this.ControllerContext.Controller.GetType(); ControllerDescriptor controllerDescriptor = new ReflectedControllerDescriptor(controllerType); // Edit start string actionName = Convert.ToString(this.ControllerContext.RouteData.Values["action"]); string controller = Convert.ToString(this.ControllerContext.RouteData.Values["controller"]); // Edit end if (controllerDescriptor.IsDefined(typeof(SpecialSetUpAttribute), true)) { //Do special setup } else { //Do normal setup } base.ExecuteCore(); }