Exemplo n.º 1
0
        public ActionResult RemovePost(int id)
        {
            try
            {
                DbLocation location = GetLocationIfExistsAndUserHasAccess(id);
                if (location == null)
                {
                    return(RedirectToAction("Index"));
                }

                LocationsRepository locationsRepository = _unitOfWork.LocationsRepository;
                locationsRepository.Remove(location);

                TempData["AlertType"]    = "success";
                TempData["AlertMessage"] = "De locatie is verwijderd!";
            }
            catch
            {
                TempData["AlertType"]    = "danger";
                TempData["AlertMessage"] = "Er is iets fout gelopen tijdens het verwijderen van de locatie!";

                return(View());
            }

            return(RedirectToAction("Index", "Locations"));
        }
        public void Verify_Remove_Should_RemoveTheEntityFromTheContext()
        {
            // Arrange
            Mock <IDbSet <Location> > mockSetLocations;
            var mockContext = LocationsMockingSetup.DoMockingSetupForContext(true, out mockSetLocations);
            var repository  = new LocationsRepository(mockContext.Object);
            var locations   = repository.Get(1);

            // Act
            repository.Remove(locations);
            // Assert
            mockSetLocations.Verify(x => x.Remove((Location)locations), Times.Once);
        }
 public void Verify_Remove_Should_RemoveTheEntityFromTheContext()
 {
     // Arrange
     Mock<IDbSet<Location>> mockSetLocations;
     var mockContext = LocationsMockingSetup.DoMockingSetupForContext(true, out mockSetLocations);
     var repository = new LocationsRepository(mockContext.Object);
     var locations = repository.Get(1);
     // Act
     repository.Remove(locations);
     // Assert
     mockSetLocations.Verify(x => x.Remove((Location)locations), Times.Once);
 }