chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
We use WCSF with CSLA.NET and Typemock 4.3

We have a Class which contains collection object. Based on Collection count some button activation / deactivation happens on presenter and in turn on view.

public ClassA
{
int id
List<string> Names
}

When we test presenter, we mock ClassA. Since ClassA is mocked so does all child objects on ClassA.

In recordering block we say

recorder.ExpectAndReturn(mockClassA.Names.Count, 0)

When we do this we get following:
System.NullReferenceException: Object reference not set to an instance of an object..

get_Count()

We thought what we are doing in recording block is correct, but it doesn't seem like. We don't know how to fix and run the test.

Help is appreciated.
asked by love_luv (1.7k points)

3 Answers

0 votes
Unfortunately you cannot mock classes from MsCorLib and List is such a type.

In the new AAA API introduced in Isolator 5.0 you can return collection from a call and fake the desired behavior.
answered by dhelper (11.9k points)
0 votes
We don't have 5.0, but we have 4.3. Is there anyway we can test something like this in 4.3 ver

thanks,
answered by love_luv (1.7k points)
0 votes
Hi,

Unfortunately, you can't do that with 4.x API. As a rule, the new features are added to 5.x versions.

I recommend upgrading to the current version. It's not that you'll be able to fake collections, you'll also get all the bug fixes that we added since then. We've had about 6 releases since 4.3, each with features and bug fixes.

Thanks,
answered by gilz (14.5k points)
...