나는 똑같은 것을 찾고 있었다. 내가 ShouldBeNull
을 구현하기 위해 다음과 같은 확장 메서드를 추가 결국 짝수 짧은 ShouldNotMap
:
RouteTestingExtensions.cs
에서 :
/// <summary>
/// Verifies that no corresponding route is defined.
/// </summary>
/// <param name="relativeUrl"></param>
public static void ShouldNotMap(this string relativeUrl)
{
RouteData routeData = relativeUrl.Route();
routeData.ShouldBeNull(string.Format("URL '{0}' shouldn't map.", relativeUrl));
}
/// <summary>
/// Verifies that the <see cref="RouteData">routeData</see> is null.
/// </summary>
public static void ShouldNotMap(this RouteData routeData)
{
routeData.ShouldBeNull("URL should not map.");
}
GeneralTestExtensions.cs
에서 :
///<summary>
/// Asserts that the object should be null.
///</summary>
///<param name="actual"></param>
///<param name="message"></param>
///<exception cref="AssertFailedException"></exception>
public static void ShouldBeNull(this object actual, string message)
{
if (actual != null)
{
throw new AssertFailedException(message);
}
}
나는 ShouldBeNull를 찾지 못했습니다() 메소드 . 대신 "~/do/not/map/this"를 수행해야했습니다. Route(). ShouldEqual (null, ""); – JNappi