> Of course. But when called via the test, it runs the actual
> TaskLoggingHelper, and not my mocked out version.
> a
> On Dec 3, 2:57 pm, "Daniel Cazzulino" <dan...@cazzulino.com> wrote:
> > Does your RestoreDatabase use the Logger property?
> > On Tue, Dec 2, 2008 at 2:53 AM, Anthony Stevens
> > <anthonyrstev...@gmail.com>wrote:
> > > Hi - hope someone can help.
> > > I'm creating a custom MSBuild task and want to test the Execute()
> > > method after first mocking out the built-in Log property. Since Log
> > > isn't virtual, I embedded it in a protected internal virtual property:
> > > protected internal virtual Logger { get { return this.Log; } }
> > > Here's my test:
> > > [TestMethod]
> > > public void Execute_1()
> > > {
> > > Mock<Microsoft.Build.Utilities.TaskLoggingHelper> log =
> > > new Mock<Microsoft.Build.Utilities.TaskLoggingHelper>(It.IsAny<ITask>
> > > ());
> > > Mock<RestoreDatabase> mock = new Mock<RestoreDatabase>();
> > > mock.ExpectGet(x => x.Logger).Returns(log.Object);
> > > mock.CallBase = true;
> > > mock.Object.Execute();
> > > }
> > > Execute() calls this.Logger.LogMessage(MessageImportance.Low, "some
> > > message");
> > > I get an exception from the actual TaskLoggingHelper class, indicating
> > > that my mocked log object is not fully mocked out. When the mocked
> > > log object gets a LogMessage() method call I don't want to pass it
> > > through to the actual TaskLoggingHelper class.
> > > Can anyone advise?
> > > Thanks,
> > > a