Ejemplo n.º 1
0
        public void EditVehicle_shuold_edit_vehicle()
        {
            // arrange
            Vehicle OldTestVehicle = new Vehicle {
                Id = 1, Color = "Red", RegNr = "ABH234", OwnerId = 1, TypeId = 1
            };
            Vehicle TestVehicle = new Vehicle {
                Id = 1, Color = "Red", RegNr = "ABH234", OwnerId = 1, TypeId = 1
            };
            Vehicle TestVehicleEdit = new Vehicle {
                Id = 1, Color = "Green", RegNr = "ABH234", OwnerId = 1, TypeId = 1
            };

            var context = new TestGarageContext();
            var repo    = new GRepo(context);

            repo.AddVehicle(TestVehicle);

            // Act
            repo.EditVehicle(TestVehicleEdit);

            var result = repo.GetVehicle(1) as Vehicle;

            // Assert

            // Vehicle was changed
            Assert.AreNotEqual(OldTestVehicle.Color, TestVehicle.Color);

            // Vehicle color was changed to green
            Assert.AreEqual(TestVehicle.Color, "Green");

            // TestVehicle is the same as the result
            Assert.AreEqual(result, TestVehicle);
        }
Ejemplo n.º 2
0
        public void RemoveVehicle_shuold_remove_vehicle()
        {
            // arrange
            Vehicle TestVehicle = new Vehicle {
                Id = 1, Color = "Red", RegNr = "ABH234", OwnerId = 1, TypeId = 1
            };

            var context = new TestGarageContext();
            var repo    = new GRepo(context);

            repo.AddVehicle(TestVehicle);

            // Act
            int OldCount = repo.GetVehicles().Count();

            repo.RemoveVehicle(TestVehicle);

            var result = repo.GetVehicles() as IEnumerable <Vehicle>;

            // Assert

            // Repository was changed
            Assert.AreNotEqual(OldCount, result.Count());

            // Count decresed by only 1
            Assert.AreEqual((OldCount - 1), result.Count());

            // TestVehicle doesn't exist in the result
            Assert.IsFalse(result.Contains(TestVehicle));
        }
Ejemplo n.º 3
0
        public void AddVehicle_shuold_add_vehicle()
        {
            // arrange
            Vehicle TestVehicle = new Vehicle {
                Id = 1, Color = "Red", RegNr = "ABH234", OwnerId = 1, TypeId = 1
            };

            var context = new TestGarageContext();
            var repo    = new GRepo(context);

            // Act
            int oldCount = repo.GetVehicles().Count();

            repo.AddVehicle(TestVehicle);
            var result = repo.GetVehicle(1) as Vehicle;

            // Assert

            //Count has changed
            Assert.AreNotEqual(oldCount, repo.GetVehicles().Count());

            //Count increased by only 1
            Assert.AreEqual((oldCount + 1), repo.GetVehicles().Count());

            //Vehicle added is the same as the vehicle returned from the repository
            Assert.AreEqual(TestVehicle, result);
        }