public async Task Put()
        {
            //Arrange
            var get = await controller.Get(1);

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


            var newEntity = new hwm_qualities();

            newEntity.hwm_quality = "excellent: +/- 0.05 ft";
            //should test the equals Equatable for all these too
            var huh = entity.Equals(newEntity);

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

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

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


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

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


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