public async void Posted_Training_are_retrievable_on_get() { //Arrange var sampleTraining1 = new Training() { Id = 3, StartDate = new DateTime(2019, 09, 20), EndDate = new DateTime(2019, 09, 21), TrainingName = "SSRS Training" }; //Act var taskResult = await myController.PostTraining(sampleTraining1); var getResult = await myController.GetTraining(sampleTraining1.Id); //Assert Assert.Equal(getResult.Value.TrainingName, sampleTraining1.TrainingName); }
public void PostTrainingInvalidData() { var controller = new TrainingsController(new TestTrainingAppContext()); var data = GetDemoTraining(); data.Id = 0; IHttpActionResult result = controller.PostTraining(data); Assert.IsInstanceOfType(result, typeof(BadRequestResult)); }
public void PostTrainingData() { var controller = new TrainingsController(new TestTrainingAppContext()); var data = GetDemoTraining(); IHttpActionResult result = controller.PostTraining(data); var okresult = result as OkNegotiatedContentResult <List <string> >; Assert.IsNotNull(result); Assert.AreEqual("result:Success", okresult.Content[0]); }
public async Task TestPostTrainingItemValidAsync() { // Arrange var dbContext = DbContextMocker.GetTrainingDbContext(nameof(TestPostTrainingItemValidAsync)); var controller = new TrainingsController(null, dbContext); var request = new Training { Training_Name = "TestPostTrainingItem", Training_Startdate = DateTime.Now, Training_Endate = DateTime.Now.AddDays(24) }; // Act var response = await controller.PostTraining(request) as ObjectResult; var value = response.Value as ISingleResponse <Training>; dbContext.Dispose(); // Assert Assert.False(value.IsError); }