Tim,
Thank you so much for your reply, I'm new to the world of testing and
I really appreciate your help..
In the real implementation of the method foo1 that I want to stub, the
code accesses a configuration file. I want to stub it in my test so
that it doesn't need to access a configuration file. I followed your
example and made foo1 virtual but on the line:
var mockedFoo = MockRepository.GeneratePartialMock<fooClass>();
and before stubbing the method I get an exception saying that the
method foo1 is trying to read a null object (which is the
configuration file.) I don't get this exception if I generate dynamic
or static mock of the class but I want to generate a partial mock. Any
idea? why is it seeing the production code?
Note: the method foo1 is called in the constructor of the fooClass(),
could that be it?
I have another question:
I'm assigned the task of creating unit tests for a System, I've been
learning about unit testing and I kind of understand the idea of
making the System testable to be able to do manual stubbing and
mocking. I'm still learning to use the Isolation framework Rhino
Mocks, My question is do I need to make the system testable the same
way I think about manual stubbing to be able to take advantage of
Rhino Mocks? in other words in terms of making the system testable
does it make a difference whether I'll be using manual stubbing &
mocking or using an isolation framework?
Thanks,
Samah
On Aug 18, 8:43 pm, Tim Barcz <
timba...@gmail.com> wrote:
> Samah,
>
> The code you want is below (I encourage you to paste into your code and run
> (note the use of xUnit)...a few notes however
>
> - I've used AAA syntax, which is our preferred method (over
> record/replay)
> - Since we're "stubbing" foo1 (that is intercepting calls made to it), it
> needs to be virtual. Method foo2 does not have this requirement.
> - I'm using xUnit as the testing framework - this should translate very
> easily to MSTest (as it appears you are using)
> - The correct output of this program should be "I'm in foo2" - even