Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 Assert.AreEqual失败。预期:<;(空)>;。实际:<;System.Web.Mvc.ViewResult>;_Asp.net Mvc 3 - Fatal编程技术网

Asp.net mvc 3 Assert.AreEqual失败。预期:<;(空)>;。实际:<;System.Web.Mvc.ViewResult>;

Asp.net mvc 3 Assert.AreEqual失败。预期:<;(空)>;。实际:<;System.Web.Mvc.ViewResult>;,asp.net-mvc-3,Asp.net Mvc 3,我正在asp.net mvc3上进行单元测试。在默认创建的测试上运行测试方法时: [TestMethod()] public void IndexTest() { ConferenceController target = new ConferenceController(); // TODO: Initialize to an appropriate value ActionResult expected = In

我正在asp.net mvc3上进行单元测试。在默认创建的测试上运行测试方法时:

[TestMethod()]
        public void IndexTest()
        {
            ConferenceController target = new ConferenceController(); // TODO: Initialize to an appropriate value
            ActionResult expected = Index; // TODO: Initialize to an appropriate value
            ActionResult actual;
            actual = target.Index();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        } 
出现此错误
[TestMethod()]

Assert.AreEqual失败。预期:。实际值:

如何传递断言

ActionResult expected = Index; // TODO: Initialize to an appropriate value
如注释所示,您应该将
索引
变量初始化为适当的值。例如:

[TestMethod]
public void Index()
{
    // Arrange
    HomeController controller = new HomeController();

    // Act
    ViewResult result = controller.Index() as ViewResult;

    // Assert
    Assert.AreEqual("Welcome to ASP.NET MVC!", result.ViewBag.Message);
}

只需阅读单元测试方法的摘要,上面给出的解决方案不起作用///////索引测试/////TODO:确保UrlToTest属性指定指向ASP.NET页面的URL(例如,///http://.../Default.aspx). 这是在web服务器上执行单元测试所必需的,//无论您是在测试页面、web服务还是WCF服务。实施上述错误后,现在出现了。。。。。。。????????????