I have spent better part of today trying to dive back into mocking. I have some rather simple code that I need to test that has proven to be a lot harder to test then I would have thought.
Much of that is because of a series of Helper methods that get called, all working w/in the HttpContext object.
I have managed to get nearly complete except for when I try to "mock" MapPath. Here is what I have so far:
this._mockHttpContext.ExpectGetAlways("Current", this._httpContext);
this._mockHttpContext.ExpectGetAlways("Request", this._httpRequest);
this._mockHttpRequest.ExpectGetAlways("ApplicationPath", "/pixelmedia.cmt.web/");
string dirRoot = PixelMEDIA.CMT.Core.Helpers.ConfigHelper.GetAppSetting("DIR_ROOT");
this._mockHttpRequest.ExpectGetAlways("MapPath", dirRoot);
It fails on the last line with the following error:
TestCase 'PixelMEDIA.CMT.Tests.Unit.Core.Controls.Server.XsltServerControlTestFixture.TestXsltOverride'
failed: TypeMock.TypeMockException :
*** No method get_MapPath in type System.Web.HttpRequest
at TypeMock.Mock.a(String A_0, Object A_1, Boolean A_2, Boolean A_3, Int32 A_4, Type[] A_5)
at TypeMock.Mock.a(String A_0, Object A_1, Boolean A_2, Boolean A_3, Type[] A_4)
at TypeMock.Mock.AlwaysReturn(String method, Object ret, Type[] genericTypes)
at TypeMock.Mock.ExpectGetAlways(String property, Object value)
C:clientWorkPixelMEDIACMTsrcTestsUnitCoreControlsServerXsltServerControlTestFixture.cs(42,0): at PixelMEDIA.CMT.Tests.Unit.Core.Controls.Server.XsltServerControlTestFixture.TestXsltOverride()
I'm at a loss now on how to proceed. Any suggestions are greatly appreciated.
Thanks.