Exemple #1
0
        public void DeleteRoadShouldNotHardDeleteRoad()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "DeleteRoad_Road_Db")
                          .Options;

            var dbContext = new ApplicationDbContext(options);

            var roadsService = new RoadsService(dbContext, null, null, null, null, null);

            var road = new Road()
            {
                RoadName = "Road"
            };



            dbContext.Roads.Add(road);
            dbContext.SaveChanges();

            dbContext.Roads.Remove(road);
            dbContext.SaveChanges();

            var result = roadsService.DeleteRoad(road.Id);

            Assert.False(result);
        }
Exemple #2
0
 public void DeleteRoad(Road road)
 {
     try
     {
         Logger.LogNewMessage($"Deleting road with id {road.Id}", LogType.INFO);
         RoadsService.DeleteRoad(road.Id);
     }
     catch (Exception ex)
     {
         Logger.LogNewMessage($"Error getting road with id {road.Id}. Message  {ex.Message}", LogType.ERROR);
     }
 }
Exemple #3
0
 public async Task <ActionResult <Road> > DeleteRoad(int id)
 {
     return(await _roadsService.DeleteRoad(id));
 }