public void Remove_ShouldThrowArgumentException_IfCarIsNull() { // Arrange Car car = null; var carsRepository = new CarsRepository(); // Act and Assert var ex = Assert.Throws<ArgumentException>(() => carsRepository.Remove(car)); Assert.IsTrue(ex.Message.Contains("Null car cannot be removed")); }
public void TestCarsRepository_RemoveMethodWhenPassNull_ShouldThrowArgumentException() { var carRepo = new CarsRepository(); Assert.Throws<ArgumentException>(() => carRepo.Remove(null)); }
public void Remove_ShouldremoveCarFromCarsRepository_WhenIsCalled() { // Arrange var car = new Car { Id = 1, Make = "Audi", Model = "A5", Year = 2005 }; var db = new Database(); db.Cars = new List<Car>(); var carsRepository = new CarsRepository(db); // Act carsRepository.Add(car); carsRepository.Remove(car); // Assert Assert.AreEqual(0, db.Cars.Count); }
public void TestCarsRepository_RemoveMethodWhenPassCarr_ShouldRemoveCorrectly() { var carRepo = new CarsRepository(); var mockedCar = new Mock<Car>(); var initialCount = carRepo.TotalCars; carRepo.Add(mockedCar.Object); carRepo.Remove(mockedCar.Object); var finalCount = carRepo.TotalCars; Assert.AreEqual(initialCount, finalCount); }