1

私はAsp.NET MVC管理エリアルートをテレリックとテストしようとしていますが、テストはできません。

これが私の試しているコードです:

        [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.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.

では、mock lite だけの telerik でエリア登録ルートの単体テストを行うにはどうすればよいでしょうか? この問題を解決するにはどうすればよいですか?

どうもありがとう。

4

1 に答える 1