public void It_Changes_All_The_Fields_On_That_Car()
                {
                    string testCarMake     = "Test new car with all feilds";
                    string testCarModel    = "A4";
                    string testCarEngine   = "4 cylinder Petrol Turbo Intercooled 2.0L";
                    string testCarBodyType = "5 doors 5 seat Wagon";
                    int    testCarWheels   = 4;
                    int    testCarDoors    = 5;
                    int    testCarId       = 0;

                    Vehicle seedCar = new Vehicle();

                    seedCar.Make        = "Non-edited";
                    seedCar.Model       = "Non-edited";
                    seedCar.Engine      = "Non-edited";
                    seedCar.BodyType    = "Non-edited";
                    seedCar.Wheels      = 9;
                    seedCar.Doors       = 10;
                    seedCar.VehicleType = (short)VehicleType.Car;

                    var builder = new DbContextOptionsBuilder <VehicleRecordDBContext>();

                    builder.UseInMemoryDatabase("VehicleRecordDB");

                    using (VehicleRecordDBContext database = new VehicleRecordDBContext(builder.Options))
                    {
                        database.Add(seedCar);
                        database.SaveChanges();
                        testCarId = seedCar.Id;
                    }

                    Car testCar = new Car();

                    testCar.Make     = testCarMake;
                    testCar.Model    = testCarModel;
                    testCar.Engine   = testCarEngine;
                    testCar.BodyType = testCarBodyType;
                    testCar.Wheels   = testCarWheels;
                    testCar.Doors    = testCarDoors;
                    VehicleService.EditVehicle(testCarId, testCar);

                    using (VehicleRecordDBContext database = new VehicleRecordDBContext(builder.Options))
                    {
                        Vehicle resultVehicle = database.Vehicles.Where(v => v.Id == testCarId).FirstOrDefault();
                        Assert.Equal(testCarMake, resultVehicle.Make);
                        Assert.Equal(testCarModel, resultVehicle.Model);
                        Assert.Equal(testCarEngine, resultVehicle.Engine);
                        Assert.Equal(testCarBodyType, resultVehicle.BodyType);
                        Assert.Equal(testCarWheels, resultVehicle.Wheels);
                        Assert.Equal(testCarDoors, resultVehicle.Doors);
                        Assert.Equal((short)VehicleType.Car, resultVehicle.VehicleType);
                    }
                }
                public void It_Makes_No_Change_To_The_Car_And_Throws_An_AllAttributesNullException()
                {
                    string seedCarMake     = "Test new car with all feilds";
                    string seedCarModel    = "A4";
                    string seedCarEngine   = "4 cylinder Petrol Turbo Intercooled 2.0L";
                    string seedCarBodyType = "5 doors 5 seat Wagon";
                    int    seedCarWheels   = 4;
                    int    seedCarDoors    = 5;
                    int    seedCarId       = 0;

                    Vehicle seedCar = new Vehicle();

                    seedCar.Make        = seedCarMake;
                    seedCar.Model       = seedCarModel;
                    seedCar.Engine      = seedCarEngine;
                    seedCar.BodyType    = seedCarBodyType;
                    seedCar.Wheels      = seedCarWheels;
                    seedCar.Doors       = seedCarDoors;
                    seedCar.VehicleType = (short)VehicleType.Car;

                    var builder = new DbContextOptionsBuilder <VehicleRecordDBContext>();

                    builder.UseInMemoryDatabase("VehicleRecordDB");

                    using (VehicleRecordDBContext database = new VehicleRecordDBContext(builder.Options))
                    {
                        database.Add(seedCar);
                        database.SaveChanges();
                        seedCarId = seedCar.Id;
                    }

                    Car testCar = new Car();

                    Assert.Throws <AllAttributesNullException>(() =>
                                                               VehicleService.EditVehicle(seedCarId, testCar));

                    using (VehicleRecordDBContext database = new VehicleRecordDBContext(builder.Options))
                    {
                        Vehicle resultVehicle = database.Vehicles.Where(v => v.Id == seedCarId).FirstOrDefault();
                        Assert.Equal(seedCarMake, resultVehicle.Make);
                        Assert.Equal(seedCarModel, resultVehicle.Model);
                        Assert.Equal(seedCarEngine, resultVehicle.Engine);
                        Assert.Equal(seedCarBodyType, resultVehicle.BodyType);
                        Assert.Equal(seedCarWheels, resultVehicle.Wheels);
                        Assert.Equal(seedCarDoors, resultVehicle.Doors);
                        Assert.Equal((short)VehicleType.Car, resultVehicle.VehicleType);
                    }
                }
            public void It_Returns_That_One_Car()
            {
                var builder = new DbContextOptionsBuilder <VehicleRecordDBContext>();

                builder.UseInMemoryDatabase("VehicleRecordDB");

                using (VehicleRecordDBContext database = new VehicleRecordDBContext(builder.Options))
                {
                    Vehicle testCar = new Vehicle();
                    testCar.Make        = "Test Searching for one car";
                    testCar.VehicleType = (short)VehicleType.Car;
                    database.Add(testCar);
                    database.SaveChanges();
                }

                List <IVehicle> result = VehicleService.GetAllVehiclesOfType(VehicleType.Car);

                Assert.Single(result);
            }
            public void It_Returns_The_Car()
            {
                int    testCarId   = 0;
                string testCarMake = "Testing getting one car that exisits";

                var builder = new DbContextOptionsBuilder <VehicleRecordDBContext>();

                builder.UseInMemoryDatabase("VehicleRecordDB");

                using (VehicleRecordDBContext database = new VehicleRecordDBContext(builder.Options))
                {
                    Vehicle testCar = new Vehicle();
                    testCar.Make        = testCarMake;
                    testCar.VehicleType = (short)VehicleType.Car;
                    database.Add(testCar);
                    database.SaveChanges();
                    testCarId = testCar.Id;
                }

                Car result = (Car)VehicleService.GetVehicle(testCarId);

                Assert.Equal(testCarMake, result.Make);
            }
            public void It_Returns_All_The_Cars_In_The_System()
            {
                int numberOfCarsInSystem = 3;
                var builder = new DbContextOptionsBuilder <VehicleRecordDBContext>();

                builder.UseInMemoryDatabase("VehicleRecordDB");

                using (VehicleRecordDBContext database = new VehicleRecordDBContext(builder.Options))
                {
                    for (int testCarNo = 0; testCarNo < numberOfCarsInSystem; testCarNo++)
                    {
                        Vehicle testCar = new Vehicle();
                        testCar.Make        = "Test Searching for many cars: car " + testCarNo;
                        testCar.VehicleType = (short)VehicleType.Car;
                        database.Add(testCar);
                    }
                    database.SaveChanges();
                }


                List <IVehicle> result = VehicleService.GetAllVehiclesOfType(VehicleType.Car);

                Assert.Equal(numberOfCarsInSystem, result.Count);
            }