我与下面链接的问题基本上有相同的问题,但我似乎无法让它工作.我得到"无法将索引[]应用于System.Data.DataRow类型的表达式".据我所知,我已正确实施了解决方案.
[TestClass]
public class UnitTest1
{
private TestContext testContextInstance;
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
private ServiceReference1.ProductCatalogClient client = new ServiceReference1.ProductCatalogClient("BasicHttpBinding_IProductCatalog");
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\CountList.csv", "CountList#csv", DataAccessMethod.Sequential), DeploymentItem("..\\ServiceTest\\CountList.csv"), TestMethod]
public void AreCountsCorrect()
{
int id = TestContext.DataRow["Id"] as int;
int count = client.GetProductCount(id);
Assert.IsTrue(count == TestContext.DataRow["Count"] as int);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用MVC2 Preview 1开发一个非常简单的应用程序.
我有一个名为ContentController的控制器.我的问题是/ Content/Index工作正常,但/ Content /返回404.我在Studio Development Server上运行应用程序.
使用RouteDebugger测试但/ Content /返回404,并且不显示任何调试信息.
我没有更改路由代码:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
Run Code Online (Sandbox Code Playgroud)
这是我的控制器:
public class ContentController : Controller
{
IRepository _repo = new SimpleRepository("db", SimpleRepositoryOptions.RunMigrations);
public ActionResult Index()
{
var content = _repo.GetPaged<Content>(0, 20);
return View(content);
}
Run Code Online (Sandbox Code Playgroud)