Hi,
I'm testing a class PersonManager, which instantiates an object of
type CityManager with 'using'.
I want to mock all the CityManager methods and constructors. I.e. I
want to skip the constructor in 'using', the Save and Move methods
(which are public virtual).
While I can mock the other personmanager methods (e.g.
GetPersonByName), I found no way to mock the CityManager.
I tried also dependency injection and passed a CityManager object in
the PersonManager constructor, but this did not work either, probably
because the Using instantiates a new CityManager object.
Is there any way to do it?
Thanks in advance.
Public class PersonManager
{
public string GetFirstName(string lastName)
{
using (CityManager cityMgr = new CityManager("London"))
{
cityMgr.Move("UK");
cityMgr.Save();
}
GetPersonByName(…);
}
}
[TestMethod]
:
PersonManager personMgr = mocks.Stub<PersonManager>(BAcontext);
SetupResult.For(personMgr.GetPersonByLastName("Miller")).Return(fakePersons[0]);
name = personMgr.GetFirstName("Miller");
Assert.AreEqual(mCity, "Joseph");
--
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en.