public void TestProjectController_GetProject_ShouldReturnProjectModelAsJsonResult(string httpMethod) { Project _project = this.db.Context.Projects.Where(p => p.ProjectId == projectId).FirstOrDefault(); //Arrange SetUpProjectControllerForTesting(httpMethod); projectController.CurrentUser = user; JsonResult result = projectController.GetProject(Convert.ToString(projectId)) as JsonResult; Assert.That(this.response.HasError, Is.EqualTo(false)); int index = result.Data.ToString().IndexOf("Data"); index += 6; var tempValue = result.Data.ToString().Substring(index, result.Data.ToString().Length - index); tempValue = tempValue.Remove(tempValue.Length - 1); string json = tempValue; var jo = Newtonsoft.Json.Linq.JObject.Parse(json); var data = jo["Model"]; ProjectModel _model = new ProjectModel { ProjectId = Convert.ToInt64(data["ProjectId"]), Name = data["Name"].ToString(), ProjectStatusTypeId = (byte)(data["ProjectStatusTypeId"]) }; Assert.That(_model, Is.Not.Null); Assert.That(_model.ProjectId, Is.EqualTo(projectId)); Assert.That(_model.Name, Is.EqualTo(_project.Name)); Assert.That(_model.ProjectStatusTypeId, Is.EqualTo((byte)_project.ProjectStatusTypeId)); }