私は PEX と Moles が初めてで、以下のような Moles を使用して UnitTest を行う方法を知りたいと思っています。
テストするには UniDynArray が必要です。ただし、UniDynArray の作成は UniSession に依存し、UniSession は UniObjects.OpenConnection に依存します。このコードを実行すると、ThirdParty 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
}