Please tell me how to get the value by not changing the controller action.
Controller
[HttpPost]
public JsonResult A_Action_In_Controller(Guid ID)
{
var operationConfirmation = _repository.DoSomethingInDB(emailID);
return Json(new { operationConfirmation }, JsonRequestBehavior.AllowGet);
}
Test Method
[TestMethod]
public void DoSomethingInDB_SendOperationConfirmationToTheUI()
{...
var expected = "Successfully Completed";
var target = controller.A_Action_In_Controller(obj1.Id);
Assert.AreEqual(expected, target.Data);
}
Error
Assert.AreEqual failed. Expected:<Successfully Completed (System.String)>. Actual:<{ operationConfirmation = Successfully
Completed } (<>f__AnonymousType2`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]])>.
Please tell me how to write something like
Assert.AreEqual(expected, target.Data.operationConfirmation);
instead of what I am having now, i dont want to change my controller code
Assert.AreEqual(expected, target.Data);