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
Most of my work with .NET involves writing custom ASP.NET controls. I use NUnitAsp to unit test the controls. I have a requirement for any mock object framework that I have not been able to find in other products, I'll try to explain it below and maybe someone from the team can comment.

My unit tests run in the NUnit process, they effectively use the NUnitAsp code to make calls to a test aspx pages that contain one of my asp.net custom controls. The test aspx page is designed to allow me to drive all of the features of the asp.net custom control. The big thing I am missing in my scenario is the ability to use a mock object framework within my unit test code (setting up expectations, verifying calls etc.) as my unit test code is in one process and my asp.net custom controls are running in the asp.net process.

As an example, lets say I have a custom control called AccountDataDropDown. The AccountDataDropDown control uses an instance of the IDataAccessLayer interface to retrieve a list of accounts from the database and then populates a standard Html select tag.

I'd like to be able to mock the instance of the IDataAccessLayer interface, setup the expectations in the unit test code and then have the AccountDataDropDown control use the mocked instance.

In the past I've manually achieved this by creating a primitive hand coded mock object that stores all of its state data (by state data I mean the expectations that have been recorded) in a file, the unit test code and the asp.net code create instances of a IDataAccessLayer class which uses the file to "share" the state data between processes.

Is there any feature of TypeMock that would help me out.

Thanks
asked by ripster (600 points)

1 Answer

0 votes
Hi,
Currently there is no out-of-the-box way in which to set expectations on a remote machine.

One way to do this is to have the expectations setup in predefined methods on the server, and allow the tests to initiate those methods.

In any case you will have to run the IIS with mock enabled. As this is a service you will have to set the variables defined in mocking_on.bat at a system level, restart IIS and then undefine those variables.

:idea: I will add this request to our feature list.
answered by scott (32k points)
...