我是 PEX 和 Moles 的新手,只是想知道如何用下面的痣进行单元测试。
我只需要一个 UniDynArray 来测试。但是创建 UniDynArray 依赖于 UniSession,而 UniSession 依赖于 UniObjects.OpenConnection。当我运行此代码时,我从第三方 dll 收到错误,说会话未打开
请帮忙
[TestMethod, HostType("Moles")]
public void Constructor2WithMoles()
{
using (MolesContext.Create())
{
//Should I make the Third party session like this ???
MUniSession msession = new MUniSession();
//Here What Actually Happens in the code is uniObject opensession return session
// UniSession session = UniObjects.OpenSession(a,b,c,d); How should i do this
//???? MUniObjects.OpenSessionStringStringStringString = (a, b, c, d) => msession;
MUniDynArray mdata = new MUniDynArray();
mdata.InsertInt32Int32String = (column, index, strValue) =>
{
column = 1;
index = 1;
strValue = "Personal Auto";
};
mdata.InsertInt32Int32String = (column, index, strValue) =>
{
column = 2;
index = 1;
strValue = "1.1";
};
mdata.InsertInt32Int32String = (column, index, strValue) =>
{
column = 3;
index = 1;
strValue = "05/05/2005";
};
mdata.InsertInt32Int32String = (column, index, strValue) =>
{
column = 4;
index = 1;
strValue = "Some Description";
};
mdata.InsertInt32Int32String = (column, index, strValue) =>
{
column = 5;
index = 1;
strValue = "20";
};
mdata.InsertInt32Int32String = (column, index, strValue) =>
{
column = 6;
index = 1;
strValue = "1";
};
History target = new History(mdata, 1);
Assert.AreEqual<string>("Some Description", target.Description);
}
// TODO: CREATE Mole asserts
}