Example #1
0
        public void CarFactoryTests()
        {
            AbstractVehicleFactory factory = new CarFactory();

            IBody      vehicleBody      = factory.CreateBody();
            IChassis   vehicleChassis   = factory.CreateChassis();
            IGlassware vehicleGlassware = factory.CreateGlassware();

            Assert.AreEqual(expected: "Body shell parts for a car", actual: vehicleBody.BodyParts);
            Assert.AreEqual(expected: "Chassis parts for a car", actual: vehicleChassis.ChassisParts);
            Assert.AreEqual(expected: "Window glassware for a car", actual: vehicleGlassware.GlasswareParts);
        }
        public void CarFactoryTest()
        {
            //given
            AbstractVehicleFactory factory = new CarFactory();

            //when
            IBody      vehicleBody      = factory.CreateBody();
            IChassis   vehicleChasis    = factory.CreateChassis();
            IGlassware vehicleGlassware = factory.CreateGlassware();

            //then
            Assert.AreEqual(vehicleBody.GetType(), typeof(CarBody));
            Assert.AreEqual(vehicleChasis.GetType(), typeof(CarChassis));
            Assert.AreEqual(vehicleGlassware.GetType(), typeof(CarGlassware));
        }
Example #3
0
 public Client(CarFactory carFactory)
 {
     _car    = carFactory.CreateCar();
     _engine = carFactory.CreateEngine();
     _body   = carFactory.CreateBody();
 }
Example #4
0
 public Client(CarFactory carFactory)
 {
     Car    = carFactory.CreateCar();
     Engine = carFactory.CreateEngine();
     Body   = carFactory.CreateBody();
 }