【发布时间】:2013-06-24 11:17:11
【问题描述】:
我需要帮助,因为我对痣很陌生,我有以下代码:
namespace A.BusinessLayer
{
sealed class AManager
{
void Method1(object obj){
// do something
}
}
public class B
{
void Method1(object obj){
if some thing{
AManager a=new AManager();
a.Method1();
}
}
}
}
现在我正在为上述类创建单元测试,如下所示(想知道这是否可能): 说明:当调用 B.Method1 时,我只是不想检查是否从实现中调用了 A.Method1,这就是我期望这段代码测试的内容。
namespace A.Tests
{
class BTest
{
void Method1Test(){
//I need something like
A.BusinessLayer.Moles.MAManager t=new A.BusinessLayer.Moles.MAManager();
t.Method1=(obj)=>{
Assert.IsTrue(true);
};
B=new B();
B.Method1();
//Assert.IsTrue(true);
}
}
}
我在 A.BusinessLayer 项目的 AssemblyInfo 类中添加了以下属性:
[assembly: InternalsVisibleTo("A.BusinessLayer.Moles")]
[assembly: InternalsVisibleTo("A.BusinessLayer.Tests")]
问题是我看不到 AManger 类的任何 Moles 吗?
任何有助于改进我的方法的帮助都会得到认可。
更新:我在 *moles.xml 文件中看到 AManager 类,但无法通过对象浏览器在 A.BusinessLayer.Moles dll 中看到它
【问题讨论】:
标签: visual-studio-2010 unit-testing mstest moles