Ejemplo n.º 1
0
        public void Test_that_CarDealership_class_implements_type_inheritance()
        {
            var carDealership = new CarDealership <ICar>();

            Assert.That(carDealership, Is.Not.TypeOf <Dealership <IVehicle> >());
            Assert.That(carDealership, Is.Not.TypeOf <Dealership <Vehicle> >());
            Assert.That(carDealership, Is.Not.TypeOf <Dealership <ICar> >());
            Assert.That(carDealership, Is.Not.TypeOf <Dealership <Car> >());
            Assert.That(carDealership, Is.Not.TypeOf <Dealership <IBike> >());
            Assert.That(carDealership, Is.Not.TypeOf <CarDealership <Car> >());

            Assert.That(carDealership, Is.TypeOf <CarDealership <ICar> >());

            var carDealership2 = new CarDealership <Car>();

            Assert.That(carDealership2, Is.Not.TypeOf <CarDealership <ICar> >());
            Assert.That(carDealership2, Is.TypeOf <CarDealership <Car> >());

            var dealership = carDealership2 as CarDealership <Car>;

            Assert.That(dealership != null);

            var dealership1 = carDealership2 as Dealership <Car>;

            Assert.That(dealership1 != null);
        }
Ejemplo n.º 2
0
 //Basic operations//
 /// <summary>
 /// Add a new dealership to the database
 /// </summary>
 /// <param name="carDealership">The dealership thta needs to be added to the database</param>
 public void Add(CarDealership carDealership)
 {
     using (carDealershipContext)
     {
         carDealershipContext.CarDealerships.Add(carDealership);
         carDealershipContext.SaveChanges();
     }
 }
        /// <summary>
        /// Update the input text boxes with information for a selected car dealership
        /// </summary>
        /// <param name="Id">The ID of a selected car dealership</param>
        private void UpdateTextBoxes(int Id)
        {
            CarDealershipBusiness carDealershipBusiness = new CarDealershipBusiness();
            CarDealership         carDealership         = carDealershipBusiness.GetCarDealershipById(Id);

            txtName.Text = carDealership.Name;
            txtTown.Text = carDealership.TownId.ToString();
        }
Ejemplo n.º 4
0
        public void Test_that_CarDealership_instance_implements_IDealership_methods()
        {
            var carDealership = new CarDealership <ICar>();

            var listOfCarsAvailable = carDealership.GetListOfVehicles();

            Assert.That(listOfCarsAvailable, Is.Not.Null);
            Assert.That(listOfCarsAvailable, Is.Empty);
        }
        /// <summary>
        /// Pull edited information from the input text boxes to an instance of a car dealership
        /// </summary>
        /// <returns>Returns a car dealership with edited information</returns>
        private CarDealership GetEditedCarDealership()
        {
            CarDealership carDealership = new CarDealership();

            carDealership.Id   = editId;
            carDealership.Name = txtName.Text;
            int.TryParse(txtTown.Text, out int townId);
            carDealership.TownId = townId;

            return(carDealership);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            CarDealership         carDealership         = GetEditedCarDealership();
            CarDealershipBusiness carDealershipBusiness = new CarDealershipBusiness();

            carDealershipBusiness.Update(carDealership);
            PopulateDataGridViewDefault();
            ResetSelect();
            ToggleSaveUpdate();
            ClearTextBoxes();
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Change the information about one of the dealerships
 /// </summary>
 /// <param name="carDealership">A dealership with the new information and the same id as the old one</param>
 public void Update(CarDealership carDealership)
 {
     using (carDealershipContext)
     {
         var item = carDealershipContext.CarDealerships.Find(carDealership.Id);
         if (item != null)
         {
             carDealershipContext.Entry(item).CurrentValues.SetValues(carDealership);
             carDealershipContext.SaveChanges();
         }
     }
 }
        /// <summary>
        /// Populate the data grid with information for a single car dealership
        /// </summary>
        /// <param name="dealership">A single car dealership used to populate the data grid</param>
        private void DataPopulatorSingle(CarDealership dealership)
        {
            CarDealershipBusiness carDealershipBusiness = new CarDealershipBusiness();

            string[] row =
            {
                dealership.Id.ToString(),
                dealership.Name,
                carDealershipBusiness.GetTownName(dealership.TownId)
            };
            dataGridView.Rows.Add(row);
        }
Ejemplo n.º 9
0
        public static void Main(string[] args)
        {
            Factory nissanFactory = new NissanFactory();

            CarDealership carDealership = new CarDealership(nissanFactory);
            carDealership.OrderVehicles();

            Factory fordFactory = new FordFactory();
            carDealership = new CarDealership(fordFactory);
            carDealership.OrderVehicles();

            Console.ReadKey();
        }
Ejemplo n.º 10
0
        public static void Main(string[] args)
        {
            Factory nissanFactory = new NissanFactory();

            CarDealership carDealership = new CarDealership(nissanFactory);

            carDealership.OrderVehicles();

            Factory fordFactory = new FordFactory();

            carDealership = new CarDealership(fordFactory);
            carDealership.OrderVehicles();

            Console.ReadKey();
        }
        //cbGet and cbSort//

        //Buttons + attached logic//
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var name = txtName.Text;

            int.TryParse(txtTown.Text, out int town);

            CarDealership carDealership = new CarDealership();

            carDealership.Name   = name;
            carDealership.TownId = town;

            CarDealershipBusiness carDealershipBusiness = new CarDealershipBusiness();

            carDealershipBusiness.Add(carDealership);
            PopulateDataGridViewDefault();
            ClearTextBoxes();
        }
Ejemplo n.º 12
0
        public void Test_that_ICarDealership_class_implements_interface_inheritance()
        {
            ICarDealership <ICar> carDealership = new CarDealership <ICar>();

            Assert.That(carDealership, Is.Not.TypeOf <IDealership <IVehicle> >());
            Assert.That(carDealership, Is.Not.TypeOf <IDealership <IBike> >());
            Assert.That(carDealership, Is.Not.TypeOf <IDealership <ICar> >());
            Assert.That(carDealership, Is.Not.TypeOf <ICarDealership <ICar> >());

            Assert.That(carDealership, Is.TypeOf <CarDealership <ICar> >());

            var carDealershipInstance1 = carDealership as ICarDealership <ICar>;

            Assert.That(carDealershipInstance1 != null);

            var dealership3 = carDealership as IDealership <ICar>;

            Assert.That(dealership3 != null);

            ICarDealership <Car> carDealership2 = new CarDealership <Car>();

            Assert.That(carDealership2, Is.Not.TypeOf <ICarDealership <ICar> >());
            Assert.That(carDealership2, Is.Not.TypeOf <ICarDealership <Car> >());

            var dealership = carDealership2 as ICarDealership <Car>;

            Assert.That(dealership != null);

            var dealership1 = carDealership2 as CarDealership <Car>;

            Assert.That(dealership1 != null);

            var dealership2 = carDealership2 as IDealership <Car>;

            Assert.That(dealership2 != null);
        }
Ejemplo n.º 13
0
        public void isCar_StringEqualCarThing_True()
        {
            CarDealership testCarDealership = new CarDealership();

            Assert.AreEqual(true, testCarDealership.isCar("4 wheels"));
        }
Ejemplo n.º 14
0
        public void isCar_StringNotEqualCarThings_False()
        {
            CarDealership testCarDealership = new CarDealership();

            Assert.AreEqual(false, testCarDealership.isCar("horse"));
        }
Ejemplo n.º 15
0
        private static void Seed(CarsDbContext context)
        {
            var makes = new[]
            {
                new Make {
                    Name = "Ford"
                },
                new Make {
                    Name = "Mercedes"
                },
                new Make {
                    Name = "Audi"
                },
                new Make {
                    Name = "BMW"
                },
                new Make {
                    Name = "АЗЛК"
                },
                new Make {
                    Name = "Лада"
                },
                new Make {
                    Name = "Трабант"
                },
            };


            var engines = new[]
            {
                new Engine
                {
                    Capacity   = 3.0,
                    Cyllinders = 8,
                    FuelType   = FuelType.Diesel,
                    HorsePower = 318
                },

                new Engine
                {
                    Capacity   = 1.2,
                    Cyllinders = 3,
                    FuelType   = FuelType.Gas,
                    HorsePower = 60
                },

                new Engine
                {
                    Capacity   = 1.6,
                    Cyllinders = 4,
                    FuelType   = FuelType.Petrol,
                    HorsePower = 95
                }
            };

            context.Engines.AddRange(engines);

            var cars = new[]
            {
                new Car
                {
                    Engine         = engines[2],
                    Make           = makes[6],
                    Doors          = 4,
                    Model          = "Кашон P50",
                    ProductionYear = new DateTime(1958, 1, 1),
                    Trasnmition    = Trasnmition.Manual
                },
                new Car
                {
                    Engine         = engines[1],
                    Make           = makes[4],
                    Doors          = 3,
                    Model          = "Москвич-423",
                    ProductionYear = new DateTime(1954, 1, 1),
                    Trasnmition    = Trasnmition.Automtaic
                },
                new Car
                {
                    Engine         = engines[0],
                    Make           = makes[0],
                    Doors          = 4,
                    Model          = "Escort",
                    ProductionYear = new DateTime(1955, 1, 1),
                    Trasnmition    = Trasnmition.Automtaic
                }
            };

            context.Cars.AddRange(cars);

            var dealerships = new[]
            {
                new Dealership
                {
                    Name = "SoftUni-Auto"
                },
                new Dealership
                {
                    Name = "Fast and Furious Auto"
                },
            };

            context.Dealerships.AddRange(dealerships);

            var carDealerships = new CarDealership[]
            {
                new CarDealership
                {
                    Car        = cars[0],
                    Dealership = dealerships[0]
                },

                new CarDealership
                {
                    Car        = cars[1],
                    Dealership = dealerships[1]
                },
                new CarDealership
                {
                    Car        = cars[0],
                    Dealership = dealerships[1]
                }
            };

            context.CarDealerships.AddRange(carDealerships);

            var licencePlates = new[]
            {
                new LicencePlate
                {
                    Number = "СВ1234АБ"
                },
                new LicencePlate
                {
                    Number = "СВ4567БC"
                },
                new LicencePlate
                {
                    Number = "ВР9999AA"
                }
            };

            context.LicencePlates.AddRange(licencePlates);

            context.SaveChanges();
        }
Ejemplo n.º 16
0
 public void Setup()
 {
     carDealership = new CarDealership();
 }