測試的代碼都寫對了.但測試時報這個錯.
Test method DALTest.SystemManageDaoTest.InsertReasonInfoTest threw exception:  System.NullReferenceException: 未将对象引用设置到对象的实例。.
我檢查了,VS的單元測試沒有生成DALTest.SystemManageDaoTest.InsertReasonInfoTest 這個東西是要我自己寫的是嗎?我試了去new它,報錯說它是個類型,被我當屬性來使用了.
請問這怎么解決呢?

解决方案 »

  1.   

    DALTest.SystemManageDaoTest.InsertReasonInfoTest 类型的一个对象
      

  2.   

    請問如果實例化.... = =DALTest.SystemManageDaoTest.InsertReasonInfoTest = new SystemManageDaoTest();不行...
      

  3.   

    啊= =測試的代碼如下
            public void InsertReasonInfoTest()
            {
                
                SystemManageDao target = new SystemManageDao();            DataSet dsReasonInfo = new DataSet("dsReasonInfo"); // TODO: Initialize to an appropriate value
                DataTable dt = new DataTable();
                dt.Columns.Add("FlowTypeID", typeof(int));
                dt.Columns.Add("Reason_CH", typeof(string));
                dt.Columns.Add("Reason_EN", typeof(string));            DataRow dr = dt.NewRow();
                dr["FlowTypeID"] = 2;
                dr["Reason_CH"] = "2";
                dr["Reason_EN"] = "2";
                dt.Rows.Add(dr);
                dsReasonInfo.Tables.Add(dt);            bool expected = true;
                bool actual;            actual = target.InsertReasonInfo(dsReasonInfo);            Assert.AreEqual(expected, actual, "ESupply.DAL.SystemManageDao.InsertReasonInfo did not return the expected value.");
                //Assert.Inconclusive("Verify the correctness of this test method.");
            }