Ich versuche Asp.net.NET MVC Admin Bereich Route zu vereinen Test mit Telerik nur mock lite.Aber ich kann nicht testen.Asp.NET MVC Arearegistration Route Einheit Test mit Telerik Just Mock Lite
Hier ist-Code Mein Versuch:
[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");
}
Wenn var context = Mock.Create<HttpContext>();
nur verspotten diesen Fehler
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.
So erzählt Wie kann ich Bereich Registrierung Route Unit-Test mit telerik nur Mock lite tun? Wie kann ich dieses Problem lösen?
Vielen Dank.
Ich verwende diese also.But seine nicht gerade Strecke Test, die auch test.Do registerarea Sie irgendwelche Codebeispiel dafür? – kodcu