I have the following in a test (my first ever JustMock test, I might add)...
var template = Mock.Create<MessageType>();
Mock.Arrange(() => template.Subject)
.Returns("This template has Zero tokens.");
Mock.Arrange(() => template.Body)
.Returns("This template has {{number}} of {{tokens}}.");
The class being Mocked looks like this ...
public class MessageType : BaseBusinessEntity
{
public string Body { get; set; }
public int DigestsToBeIncludedOn { get; set; }
public Guid MessageReference { get; set; }
public int MessageTypeId { get; set; }
public string Name { get; set; }
public int PredefinedRecipients { get; set; }
public string Subject { get; set; }
}
When I attempt to run the test I get ...
Error Message: Test method Genesis.Service.Implementation.Tests.DigestFixture.ShouldCorrectlyExtractTemplateTokens threw exception: Telerik.JustMock.Core.ElevatedMockingException: Cannot mock 'System.String get_Subject()'. The profiler must be enabled to mock, arrange or execute the specified target. Stacktrace: at Telerik.JustMock.Core.ProfilerInterceptor.ThrowElevatedMockingException(MemberInfo member) at Telerik.JustMock.Core.MocksRepository.CheckMethodInterceptorAvailable(IMatcher instanceMatcher, MethodBase method) at Telerik.JustMock.Core.MocksRepository.AddArrange(IMethodMock methodMock) at Telerik.JustMock.Core.MocksRepository.Arrange[TMethodMock](Expression expr, Func
1 methodMockFactory) at Telerik.JustMock.Mock.<>c__DisplayClass8
1.b__6() at Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal[T](Func1 guardedAction) at Telerik.JustMock.Mock.Arrange[TResult](Expression
1 expression) at Genesis.Service.Implementation.Tests.DigestFixture.ShouldCorrectlyExtractTemplateTokens() in c:\Genesis\Development\Genesis.Service.Implementation.Tests\DigestFixture.cs:line 46
Can anyone point out what I've done wrong?
Be sure you have enabled the profiler from the menu.
While using Visual Studio for writing your tests you will notice the Telerik menu and the JustMock menu-item in it. Once there, you have to check if JustMock is enabled(“Enable JustMock” should be grey, see the example bellow).