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

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


            var newEntity = new housing_type();

            newEntity.type_name = "1 - pre-deployed Bracket";
            //should test the equals Equatable for all these too
            var huh = entity.Equals(newEntity);

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

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

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


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

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


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