|
From: Xiaoqiao Li <xia...@ya...> - 2004-05-23 04:27:08
|
Hi,
How does Mock.Expect verify ArrayList parameters? ArrayList.Equals is inherited from Object and compares reference, not content. But my unit test needs to compare the content, similar to the behavoir in Java - first compare the list size, and then call equals on each element.
IMock mock = new DynamicMock(typeof(IFoo);
IFoo foo = (IFoo) mock.MockInstance;
ArrayList expectedList = new ArrayList();
expectedList.Add(1);
expectedList.Add(2);
mock.Expect("Bar", expectedList );
FooUser user = new FooUser(foo);
user.DoSomething();
// foo.Bar(actualList) is called in user.DoSomething()
mock.Verify();
I'd like to have the above test pass. The actualList is generated inside user.DoSomething(), so I cannot set expectedList = actualList.
The ArrayList parameter is not uncommon. I think there must be a way in nmock. Can someone shed light on this? Thanks.
Xiaoqiao
---------------------------------
Do you Yahoo!?
Yahoo! Domains - Claim yours for only $14.70/year |