【发布时间】:2020-09-06 13:23:14
【问题描述】:
下面是场景。
我有一个包含 2 个静态方法的公共类。
public class Helper{
public static string (string args1, Datetime dt)
{
string computedValue = GetSomeValue(args1);
return dt.ToString(computedValue);
}
public static GetSomeValue(string args2){
//Perform Computation and return a string
}
}
现在我想对GetSomeValue 方法进行单元测试。我不确定我们是否可以模拟静态方法,或者我们是否应该对该方法进行单元测试。
请帮忙。
【问题讨论】:
-
我们不知道您想测试哪些方法,只有您自己知道。无论如何,这里已经询问了模拟静态成员:stackoverflow.com/questions/2416362/…
标签: c# .net unit-testing moq