コード例 #1
0
 public ActionResult <Snack> Delete(int id)
 {
     try
     {
         return(Ok(_service.Delete(id)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #2
0
        public void DELETE_ShouldReturnOneSnackLess()
        {
            //Arrange
            int x       = 1;
            var options = new DbContextOptionsBuilder <CinemaDbContext>()
                          .UseInMemoryDatabase(databaseName: "DELETE_ShouldReturnOneSnackLess")
                          .Options;


            var context = new CinemaDbContext(options);

            SeedSnacks(context);

            var service = new SnackService(context);


            //Act
            var result = service.Delete(x);


            //Assert
            Assert.True(result);
        }