Beispiel #1
0
        public void Add_NewCard_NewCarAdded()
        {
            var newCar = new Car {Make = "Saab", RegistrationNumber = "DN10000"};
            var repository = new CarRepository();
            repository.Add(newCar);

            AssertValuesForCarIsPersisted(newCar);
        }
Beispiel #2
0
        public void GetBy_IdNotInDatabase_ReturnValueIsNull()
        {
            var carRepository = new CarRepository();
            var id = Guid.NewGuid();

            var nullCar = carRepository.GetBy(id);

            Assert.IsNull(nullCar);
        }
Beispiel #3
0
        public void GetBy_IdFromCarInDb_CarReturned()
        {
            var newCar = new Car { Make = "Saab", RegistrationNumber = "DN10000" };
            var carRepository = new CarRepository();
            carRepository.Add(newCar);

            var savedCar = carRepository.GetBy(newCar.Id);

            Assert.AreEqual(newCar.Id, savedCar.Id);
        }
Beispiel #4
0
        public void GetAll_TwoSaabsAndOneBMWInDb_OnlySaabsReturned()
        {
            var saab1 = new Car { Make = "Saab", RegistrationNumber = "DN10000"};
            var saab2 = new Car { Make = "Saab", RegistrationNumber = "DN10001"};
            var bmw1 = new Car { Make = "BMW", RegistrationNumber = "DN10002"};

            var carRepository = new CarRepository();
            carRepository.Add(saab1);
            carRepository.Add(saab2);
            carRepository.Add(bmw1);

            var saabs = carRepository.GetAll("Saab");

            Assert.AreEqual(2, saabs.Count());
        }
Beispiel #5
0
        public void Update_RegistrationNumberChanged_ChangePersistsInDataBase()
        {
            var newCar = new Car { Make = "Saab", RegistrationNumber = "DN10000" };
            var carRepository = new CarRepository();
            carRepository.Add(newCar);

            newCar.RegistrationNumber = "LJ10000";

            carRepository.Update(newCar);

            AssertValuesForCarIsPersisted(newCar);
        }
Beispiel #6
0
        public void Remove_CarExistsInDb_CarRemoved()
        {
            var newCar = new Car { Make = "Saab", RegistrationNumber = "DN10000" };
            var carRepository = new CarRepository();
            carRepository.Add(newCar);

            carRepository.Remove(newCar);

            AssertCarIsNotInDb(newCar);
        }