If you are inside the view you could directly use the helper:
<%= Url.Action( "Details", "test", new {test.ID } ) %>
If you are inside a controller action you could use the Url property:
public ActionResult Index()
{
string fullUrl = Url.Action( "Details", "test", new {test.ID } );
return View();
}
If this is in a helper method you already have the url:
public static void SomeHelper(this UrlHelper url)
{
string fullUrl = url.Action( "Details", "test", new {test.ID } );
}
If it is none of the above you are probably doing something wrong and you might need to move this code.
If you are new to ASP.NET MVC I would recommend you reading some tutorials.