我在测试中有以下内容(我可能会添加我的第一次 JustMock 测试)......
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}}.");
被嘲笑的班级看起来像这样......
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; }
}
当我尝试运行测试时,我得到...
错误消息:测试方法 Genesis.Service.Implementation.Tests.DigestFixture.ShouldCorrectlyExtractTemplateTokens 抛出异常:Telerik.JustMock.Core.ElevatedMockingException:无法模拟“System.String get_Subject()”。必须启用探查器来模拟、安排或执行指定的目标。Stacktrace:在 Telerik.JustMock.Core.MocksRepository.AddArrange(IMethodMock methodMock) 在 Telerik.JustMock.Core.MocksRepository.CheckMethodInterceptorAvailable(IMatcher instanceMatcher, MethodBase method) 在 Telerik.JustMock.Core.ProfilerInterceptor.ThrowElevatedMockingException(MemberInfo member)。 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 表达式)在 Genesis.Service.Implementation.Tests.DigestFixture.ShouldCorrectlyExtractTemplateTokens() 在 c:\Genesis\Development\Genesis.Service.Implementation.Tests\DigestFixture.cs:line 46
谁能指出我做错了什么?