私はAsp.NET MVC Adminエリアのルートをテストしようとしています。ここで Asp.NET MVC TelerikジャストモックLiteとのArearegistrationルートユニットテスト
は、私はコードをしようとしている: [TestMethod]
public void AdminRouteUrlIsRoutedToHomeAndIndex()
{
//spts.saglik.gov.tr/admin
//create route collection
var routes = new RouteCollection();
var areaRegistration = new AdminAreaRegistration();
Assert.AreEqual("Admin",areaRegistration.AreaName);
// Get an AreaRegistrationContext for my class. Give it an empty RouteCollection
var areaRegistrationContext = new AreaRegistrationContext(areaRegistration.AreaName, routes);
areaRegistration.RegisterArea(areaRegistrationContext);
// Mock up an HttpContext object with my test path (using Moq)
var context = Mock.Create<HttpContext>();
context.Arrange(c=>c.Request.AppRelativeCurrentExecutionFilePath).Returns("~/Admin");
// Get the RouteData based on the HttpContext
var routeData = routes.GetRouteData(context.Request.RequestContext.HttpContext);
//assert has route
Assert.IsNotNull(routeData,"route config");
}
var context = Mock.Create<HttpContext>();
だけのモックだから私はtelerikちょうどモックLiteでエリア登録ルートのユニットテストを行うことができますどのようにこのエラー
Telerik.JustMock.Core.ElevatedMockingException: Cannot mock 'System.Web.HttpContext'. JustMock Lite can only mock interface members, virtual/abstract members in non-sealed classes, delegates and all members on classes derived from MarshalByRefObject on instances created with Mock.Create or Mock.CreateLike. For any other scenario you need to use the full version of JustMock.
を告げますか?どうすればこの問題を解決できますか?
ありがとうございます。
私はそのまたtest.Doがregisterareaあなたがいずれかを持っている、これはそのだけではなく、ルートテストをalso.But使用していますこれのコード例? – kodcu