parent
fdbac041f9
commit
e27742fd0b
|
|
@ -79,10 +79,16 @@ namespace Microsoft.AspNet.Mvc
|
|||
return String.Equals(methodInfo.Name, DefaultMethodName, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the method is a valid action.
|
||||
/// </summary>
|
||||
/// <param name="method">The <see cref="MethodInfo"/>.</param>
|
||||
/// <returns>true if the method is a valid action. Otherwise, false.</returns>
|
||||
protected virtual bool IsValidActionMethod(MethodInfo method)
|
||||
{
|
||||
return
|
||||
method.IsPublic &&
|
||||
!method.IsStatic &&
|
||||
!method.IsAbstract &&
|
||||
!method.IsConstructor &&
|
||||
!method.IsGenericMethod &&
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var actionNames = GetDescriptors(typeof(BaseController).GetTypeInfo()).Select(a => a.Name);
|
||||
|
||||
// Assert
|
||||
Assert.False(actionNames.Contains("Redirect"));
|
||||
Assert.DoesNotContain("Redirect", actionNames);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var actionNames = GetActionNamesFromDerivedController();
|
||||
|
||||
// Assert
|
||||
Assert.False(actionNames.Contains("PrivateMethod"));
|
||||
Assert.DoesNotContain("PrivateMethod", actionNames);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -54,7 +54,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var actionNames = GetActionNamesFromDerivedController();
|
||||
|
||||
// Assert
|
||||
Assert.False(actionNames.Contains("DerivedController"));
|
||||
Assert.DoesNotContain("DerivedController", actionNames);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -74,7 +74,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var actionNames = GetActionNamesFromDerivedController();
|
||||
|
||||
// Assert
|
||||
Assert.False(actionNames.Contains("GenericMethod"));
|
||||
Assert.DoesNotContain("GenericMethod", actionNames);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var actionNames = GetActionNamesFromDerivedController();
|
||||
|
||||
// Assert
|
||||
Assert.False(actionNames.Contains("OverridenNonActionMethod"));
|
||||
Assert.DoesNotContain("OverridenNonActionMethod", actionNames);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -100,6 +100,36 @@ namespace Microsoft.AspNet.Mvc
|
|||
Assert.Empty(methodsFromObjectClass.Intersect(actionNames));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDescriptors_Ignores_StaticMethod_FromUserDefinedController()
|
||||
{
|
||||
// Arrange & Act
|
||||
var actionNames = GetActionNamesFromDerivedController();
|
||||
|
||||
// Assert
|
||||
Assert.DoesNotContain("StaticMethod", actionNames);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDescriptors_Ignores_ProtectedStaticMethod_FromUserDefinedController()
|
||||
{
|
||||
// Arrange & Act
|
||||
var actionNames = GetActionNamesFromDerivedController();
|
||||
|
||||
// Assert
|
||||
Assert.DoesNotContain("ProtectedStaticMethod", actionNames);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetDescriptors_Ignores_PrivateStaticMethod_FromUserDefinedController()
|
||||
{
|
||||
// Arrange & Act
|
||||
var actionNames = GetActionNamesFromDerivedController();
|
||||
|
||||
// Assert
|
||||
Assert.DoesNotContain("PrivateStaticMethod", actionNames);
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetActionNamesFromDerivedController()
|
||||
{
|
||||
return GetDescriptors(typeof(DerivedController).GetTypeInfo()).Select(a => a.Name);
|
||||
|
|
@ -143,6 +173,18 @@ namespace Microsoft.AspNet.Mvc
|
|||
private void PrivateMethod()
|
||||
{
|
||||
}
|
||||
|
||||
public static void StaticMethod()
|
||||
{
|
||||
}
|
||||
|
||||
protected static void ProtectedStaticMethod()
|
||||
{
|
||||
}
|
||||
|
||||
private static void PrivateStaticMethod()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class OperatorOverloadingController : Controller
|
||||
|
|
|
|||
Loading…
Reference in New Issue