我需要为下一个函数编写一个单元测试,我看到我可以使用[ExpectedException]
这是要测试的功能.
public static T FailIfEnumIsNotDefined<T>(this T enumValue, string message = null)
where T:struct
{
var enumType = typeof (T);
if (!enumType.IsEnum)
{
throw new ArgumentOutOfRangeException(string.Format("Type {0} is not an Enum, therefore it cannot be checked if it is Defined not have defined.", enumType.FullName));
}
else if (!Enum.IsDefined(enumType, enumValue))
{
throw new ArgumentOutOfRangeException(string.Format("{1} Value {0} is not does not have defined value in Enum of type {0}. It should not be...", enumType.FullName, message ?? ""));
}
return enumValue;
}
Run Code Online (Sandbox Code Playgroud)
这里将使用代码来测试应该抛出的异常 …
我想在应用程序投入生产之前截断它的所有数据我正在查看文档并且没有找到任何关于使用 liquibase 截断表的信息。所以我想知道是否有人解决了类似的问题