コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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]);
        }
コード例 #4
0
ファイル: APITest.cs プロジェクト: camit/RMS-SAMPLE
        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);
        }