Example #1
0
        public void Add_RepoContains1Car_CarAddedToRepo()
        {
            var testObject = new CarTestableObject();

            testObject.InMemoryCarRepository.Save(testObject.CarBMW);

            Assert.AreEqual(testObject.CarBMW, testObject.InMemoryCarRepository.FindById(testObject.CarBMW.Id));
        }
Example #2
0
        public void GetAll_Add2CarsToRepo_RepoAllReturn2Cars()
        {
            var testObject = new CarTestableObject();

            testObject.InMemoryCarRepository.Save(testObject.CarBMW);
            testObject.InMemoryCarRepository.Save(testObject.CarMG);

            Assert.AreEqual(2, testObject.InMemoryCarRepository.All().Count());
            Assert.AreEqual(testObject.CarBMW, testObject.InMemoryCarRepository.FindById(testObject.CarBMW.Id));
            Assert.AreEqual(testObject.CarMG, testObject.InMemoryCarRepository.FindById(testObject.CarMG.Id));
        }
Example #3
0
        public void Delete_RepoNotContainsAddedCar_TargetCarRemoved()
        {
            var testObject = new CarTestableObject();

            testObject.InMemoryCarRepository.Save(testObject.CarBMW);
            testObject.InMemoryCarRepository.Save(testObject.CarMG);

            testObject.InMemoryCarRepository.Delete(testObject.CarBMW.CarId);

            Assert.IsNull(testObject.InMemoryCarRepository.FindById(testObject.CarBMW.Id));
            Assert.AreEqual(1, testObject.InMemoryCarRepository.All().Count());
        }
Example #4
0
        public void Find_RepoContainsAddedCar_AddedCarReturned()
        {
            var testObject = new CarTestableObject();

            testObject.InMemoryCarRepository.Save(testObject.CarBMW);
            testObject.InMemoryCarRepository.Save(testObject.CarMG);

            var targetElement = testObject.InMemoryCarRepository.FindById(testObject.CarBMW.Id);
            var emptyElement  = testObject.InMemoryCarRepository.FindById(Guid.Empty);

            Assert.NotNull(targetElement);
            Assert.IsNull(emptyElement);
        }
Example #5
0
        public void Update_RepoContainsUpdateCar_UpdatedCarReturned()
        {
            var testObject = new CarTestableObject();

            testObject.InMemoryCarRepository.Save(testObject.CarBMW);
            testObject.InMemoryCarRepository.Save(testObject.CarMG);

            var targetElement = testObject.InMemoryCarRepository.FindById(testObject.CarBMW.Id);
            var NameOfNewCar  = "LADA";

            targetElement.Name = NameOfNewCar;
            testObject.InMemoryCarRepository.Save(targetElement);

            Assert.AreEqual(NameOfNewCar, testObject.InMemoryCarRepository.FindById(testObject.CarBMW.Id).Name);
        }