I am doing some testing of a DAL and so am testing classes which effectively take in a load of data and then passing it out again.
At present I am doing this in roughly the style shown below.
[TestMethod]
public void Copying_Test()
{
VWE_STB_BOOKMARK entity = new VWE_STB_BOOKMARK();
entity.STB_ID = int.MaxValue;
Nullable<int> temp_STB_ID = entity.STB_ID;
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
VWE_STB_BOOKMARK newBookmark = new VWE_STB_BOOKMARK();
recorder.ExpectAndReturn(newBookmark.STB_ID, temp_STB_ID);
}
try
{
VWE_STB_BOOKMARK target = new VWE_STB_BOOKMARK();
Nullable<int> result = target.STB_ID;
Assert.AreEqual(temp_STB_ID,result);
MockManager.Verify();
}
finally
{
MockManager.ClearAll();
}
}
I was wandering if there is a may to use the properties of an entity as the results from calls in natural typemocks. This would be something like the code shown below.
[TestMethod]
public void Copying_Test2()
{
VWE_STB_BOOKMARK entity = new VWE_STB_BOOKMARK();
entity.STB_ID = int.MaxValue;
Nullable<int> temp_STB_ID = entity.STB_ID;
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
VWE_STB_BOOKMARK newBookmark = new VWE_STB_BOOKMARK();
recorder.ExpectAndReturn(newBookmark.STB_ID, [u]entity.STB_ID[/u]);
}
try
{
VWE_STB_BOOKMARK target = new VWE_STB_BOOKMARK();
Nullable<int> result = target.STB_ID;
Assert.AreEqual(temp_STB_ID,result);
MockManager.Verify();
}
finally
{
MockManager.ClearAll();
}
}
This wont work at present. Presumably as TypeMock is mocking the call to entity.STB_ID within the recording section.
Thanks,