public void CreateNewTraining() { var maxTrainingIDBeforeAdd = data.Max(t => t.TId); //Init the WebAPI service var controller = new TrainingController(mockContext.Object); //Check the equality between the returned data and the expected data var result = controller.PostTrainingInfo(new TrainingInfo { TId = maxTrainingIDBeforeAdd + 1, TrainingName = "Training " + (maxTrainingIDBeforeAdd + 1), StartDate = new DateTime().AddDays(9), EndDate = new DateTime().AddDays(12) }) as OkNegotiatedContentResult <TrainingInfo>; Assert.IsNotNull(result); Assert.AreEqual(maxTrainingIDBeforeAdd + 1, result.Content.TId); }