私は同じことを探していました。私は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