我收到一個錯誤,試圖單元測試我的MVC.Net應用程序中的JsonResult。我需要幫助單元測試MVC.Net站點JsonResults
我看到我在我的測試中使用動態檢索數據,但是當我執行Assert.AreEqual時,出現錯誤。
我在做什麼錯?我怎樣才能解決這個問題?
我已經包含了我在單元測試中使用,以及爲我得到(見以下圖片)的錯誤代碼:
代碼中使用單元測試
[TestMethod]
public void getStatusesInfoTESTTest()
{
const int statusID = 12;
MasterDataController controller = new MasterDataController();
var result = controller.getStatusInfoTEST(statusID) as JsonResult;
dynamic data = result.Data;
Assert.AreEqual("TESTING 123", data.MasterDataDescription);
}
ERROR我得到:
錯誤消息:
型「Microsoft.CSharp.RuntimeBinder.RuntimeBinderException」的異常出現在System.Core.dll但在用戶代碼中沒有處理
圖像數據等我回來的 IMAGE OF RETURNED DATA
感謝您的幫助, mrotor
顯示待測方法。 'getStatusInfoTEST'是數據的具體類型還是匿名類型? – Nkosi