コード例 #1
0
        public async Task Put()
        {
            //Arrange
            var get = await controller.Get(1);

            var okgetResult = Assert.IsType <OkObjectResult>(get);
            var entity      = Assert.IsType <event_status>(okgetResult.Value);


            var newEntity = new event_status();

            newEntity.status = "active";
            //should test the equals Equatable for all these too
            var huh = entity.Equals(newEntity);

            entity.status = "editStat";
            //Act
            var response = await controller.Put(1, entity);

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(response);
            var result   = Assert.IsType <event_status>(okResult.Value);

            Assert.Equal(entity.status, result.status);
        }
コード例 #2
0
 public async Task <IActionResult> Put(int id, [FromBody] event_status entity)
 {
     try
     {
         if (id < 0 || !isValid(entity))
         {
             return(new BadRequestResult());
         }
         return(Ok(await agent.Update <event_status>(id, entity)));
     }
     catch (Exception ex)
     {
         return(await HandleExceptionAsync(ex));
     }
 }
コード例 #3
0
 public async Task <IActionResult> Post([FromBody] event_status entity)
 {
     try
     {
         if (!isValid(entity))
         {
             return(new BadRequestResult());
         }
         //sm(agent.Messages);
         return(Ok(await agent.Add <event_status>(entity)));
     }
     catch (Exception ex)
     {
         //sm(agent.Messages);
         return(await HandleExceptionAsync(ex));
     }
 }
コード例 #4
0
        public async Task Post()
        {
            //Arrange
            var entity = new event_status()
            {
                status = "TestPost"
            };


            //Act
            var response = await controller.Post(entity);

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(response);
            var result   = Assert.IsType <event_status>(okResult.Value);


            Assert.Equal("TestPost", result.status);
        }