Unit testing 不能嘲笑。。。。必须启用探查器以模拟、排列或执行指定的目标
我在一个测试中有以下内容(我可能会添加我的第一个JustMock测试) 当我尝试运行测试时,我得到 错误消息:测试方法 Genesis.Service.Implementation.Tests.DigestFixture.ShouldCorrectExtractTemplateTokens 引发异常:Telerik.JustMock.Core.LevelatedMockingException: 无法模拟“System.String get_Subject()”。分析器必须是 允许模拟、安排或执行指定的目标。堆栈跟踪: 在 Telerik.JustMock.Core.ProfilerInterceptor.ThrowellEvatedMockingException(MemberInfo 成员)在 Telerik.JustMock.Core.MocksRepository.CheckMethodInterceptor可用(IMatcher instanceMatcher,MethodBase方法)位于 Telerik.JustMock.Core.MocksRepository.AddArrange(IMethodMock 方法模拟)在 Telerik.JustMock.Core.MocksRepository.Arrange[TMethodMock](表达式 expr,FuncUnit testing 不能嘲笑。。。。必须启用探查器以模拟、排列或执行指定的目标,unit-testing,telerik,justmock,Unit Testing,Telerik,Justmock,我在一个测试中有以下内容(我可能会添加我的第一个JustMock测试) 当我尝试运行测试时,我得到 错误消息:测试方法 Genesis.Service.Implementation.Tests.DigestFixture.ShouldCorrectExtractTemplateTokens 引发异常:Telerik.JustMock.Core.LevelatedMockingException: 无法模拟“System.String get_Subject()”。分析器必须是 允许模拟、安排或执
1 methodMockFactory)位于
Telerik.JustMock.Mock.c_uudisplayClass8
1.b_u6()位于
Telerik.JustMock.Core.ProfilerInterceptor.guardinal[T](函数1
guardedAction)在Telerik.JustMock.Mock.Arrange[TResult](表达式
1
表达式)在
Genesis.Service.Implementation.Tests.DigestFixture.ShouldCorrectlyExtractTemplateTokens()
在里面
c:\Genesis\Development\Genesis.Service.Implementation.Tests\DigestFixture.cs:line
46
有人能指出我做错了什么吗?确保已从菜单中启用探查器 在使用VisualStudio编写测试时,您会注意到其中的Telerik菜单和JustMock菜单项。在那里之后,您必须检查JustMock是否已启用(“Enable 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; }
}