public void MD5DoesNotExistTest() { #region ////Arrange //var bigFileUploadController = new Mock<BigFileUploadController>(); //bigFileUploadController.Setup(a=>a.IsMD5Exist()) ////Act //ActionResult result = bigFileUploadController.IsMD5Exist("ef13915dda1f0dd3e2c5576ca2c7dce2", "fileName", "FileID") as ActionResult; ////Assert #endregion //Arrange BigFileUploadController bigFileUploadController = new BigFileUploadController(); //Act //ActionResult result = bigFileUploadController.IsMD5Exist("this md5 is not exist", "fileName", "FileID") as ActionResult; var result = bigFileUploadController.IsMD5Exist("this md5 is not exist", "fileName", "FileID") as JsonResult; string data = result.Data.ToString(); //Assert 失败: System.Web.Mvc.HttpNotFoundResult 成功: System.Web.Mvc.JsonResult Console.WriteLine(data); Assert.AreEqual(data, "this file is not exist"); }
public void IsMD5ExistTest() { #region ////Arrange //var bigFileUploadController = new Mock<BigFileUploadController>(); //bigFileUploadController.Setup(a=>a.IsMD5Exist()) ////Act //ActionResult result = bigFileUploadController.IsMD5Exist("ef13915dda1f0dd3e2c5576ca2c7dce2", "fileName", "FileID") as ActionResult; ////Assert #endregion //Arrange BigFileUploadController bigFileUploadController = new BigFileUploadController(); //Act try { var result = bigFileUploadController.IsMD5Exist("ef13915dda1f0dd3e2c5576ca2c7dce2", "fileName", "FileID") as JsonResult; //Assert 失败: System.Web.Mvc.HttpNotFoundResult 成功: System.Web.Mvc.JsonResult string data = result.Data.ToString(); Console.WriteLine(data); Assert.AreEqual(data, "this file is exist"); } catch (Exception e) { Console.WriteLine(e.Message); Assert.Inconclusive(); } }