I have this code in my SUT:
FarmLoggingService tempService = FarmLoggingService.Local;
if (null != tempService)
{
tempService.Update();
}
else
{
tempService = new FarmLoggingService();
tempService.Update();
if (tempService.Status != SPObjectStatus.Online)
tempService.Provision();
}
I'm trying to figure out how to mock the call to the FarmLoggingService constructor: tempService = new FarmLoggingService.
I've tried variations all similar to
Mock.Arrange( () => new FarmLoggingService() ).Returns(mockSvc);
where mockSvc was created like this:
var mockSvc = Mock.Create<FarmLoggingService>(Constructor.Mocked);
But nothing seems to be working. Ultimately, I need to be able to check that Update and Provision were each called once. I have it working to return null from FarmLoggingService.Local to force me into the else block, mock the return value from the Status property so it always calls Provision, but I can't get the constructor bit working right.
Any ideas?
Thanks,
Dave
FarmLoggingService tempService = FarmLoggingService.Local;
if (null != tempService)
{
tempService.Update();
}
else
{
tempService = new FarmLoggingService();
tempService.Update();
if (tempService.Status != SPObjectStatus.Online)
tempService.Provision();
}
I'm trying to figure out how to mock the call to the FarmLoggingService constructor: tempService = new FarmLoggingService.
I've tried variations all similar to
Mock.Arrange( () => new FarmLoggingService() ).Returns(mockSvc);
where mockSvc was created like this:
var mockSvc = Mock.Create<FarmLoggingService>(Constructor.Mocked);
But nothing seems to be working. Ultimately, I need to be able to check that Update and Provision were each called once. I have it working to return null from FarmLoggingService.Local to force me into the else block, mock the return value from the Status property so it always calls Provision, but I can't get the constructor bit working right.
Any ideas?
Thanks,
Dave