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

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


            var newEntity = new network_type();

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

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

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

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


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

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


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