public void Add_ShouldThrowArgumentException_IfCarIsNull() { // Arrange Car car = null; var db = new Database(); db.Cars = new List<Car>(); var count = db.Cars.Count; var carsRepository = new CarsRepository(db); // Act and Assert Assert.Throws<ArgumentException>(() => carsRepository.Add(car), "Null car cannot be added"); }
public void Add_ShouldAddCarToCarRepository() { // Arrange var car = new Car { Id = 1, Make = "Audi", Model = "A5", Year = 2005 }; var db = new Database(); db.Cars = new List<Car>(); var count = db.Cars.Count; var carsRepository = new CarsRepository(db); // Act carsRepository.Add(car); // Assert Assert.AreEqual(1, db.Cars.Count); }
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); }