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

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


            var newEntity = new sensor_brand();

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

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

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

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


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

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


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