public void TestAddActivity() { PerformanceController ñontroller = ConfigureController(); ActivityModel m = new ActivityModel { name = "TTT", description = "description of TTT", workCost = 20 }; IActionResult result = ñontroller.AddActivity(m); Assert.IsTrue(result is OkObjectResult); OkObjectResult okResult = result as OkObjectResult; Assert.IsTrue(okResult.Value is Activity); Activity activity = okResult.Value as Activity; Assert.IsTrue(activity.Id == 0 && activity.Name == "TTT" && activity.Description == m.description && activity.WorkCost == m.workCost && activity.ParentId == 1); m = new ActivityModel { id = 0, name = "TTT2", description = "description of TTT", workCost = 30 }; // Modification result = ñontroller.AddActivity(m); Assert.IsTrue(result is OkObjectResult); okResult = result as OkObjectResult; Assert.IsTrue(okResult.Value is Activity); activity = okResult.Value as Activity; Assert.IsTrue(activity.Id == 0 && activity.Name == m.name && activity.Description == m.description && activity.WorkCost == m.workCost && activity.ParentId == 1); m = new ActivityModel { id = 1, name = "TTT2", description = "description of TTT", workCost = 20, options = 1 }; // Modification result = ñontroller.AddActivity(m); Assert.IsTrue(result is BadRequestObjectResult); }