小编S.B*_*ron的帖子

有可能对这种方法进行单元测试吗?

我有以下方法,我正在尝试编写单元测试:

using StaticClass;           // writen by some one else, have a dll

namespace Test
{
  Class TestClass
   {
      public void DoSomething(string param1)
      {
         List<string> = StaticClass.GetList(param1)

         // sort the list and do other studd here
      }
  }
}
Run Code Online (Sandbox Code Playgroud)

当我不确定如何为DoSomething方法编写测试时,这取决于另一个类中的静态方法.该方法的输出取决于该机器上的数据库,环境和其他一些其他因素.因此,如果两台机器上的数据库不同,则相同的方法会产生不同的结果.我所知道的是GetList返回一些值,该方法可能已经或可能没有被该类的创建者进行单元测试.

我该如何测试这种方法?是否可以这样说,每当调用StaticClass.Getlist方法返回List<String>我在程序中创建的自定义时?我在c#上写测试.

谢谢,

c# unit-testing

1
推荐指数
1
解决办法
368
查看次数

标签 统计

c# ×1

unit-testing ×1