Ejemplo n.º 1
0
        public void Setup()
        {
            _entryNotification = Substitute.For <IEntryNotifcation>();
            _userValidation    = Substitute.For <IUserValidation>();
            _doors             = Substitute.For <IDoors>();

            _uut = new DoorControl(_doors, _entryNotification, _userValidation);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // Create factory directly - simulating user input or some program condition
            Console.WriteLine("Creating factory directly - simulating user input or some program condition.");
            Console.WriteLine();
            string carType = "bmw";
            ICarAbstractFactory carFactoryDirect = null;

            if (carType == "bmw")
            {
                carFactoryDirect = new BMWFactory();
            }
            else if (carType == "audi")
            {
                carFactoryDirect = new AudiFactory();
            }
            ICar    carDirect    = carFactoryDirect.GetSUV();
            IEngine engineDirect = carDirect.GetEngine();
            IDoors  doorsDirect  = carDirect.GetDoors();

            Console.WriteLine("SUV");
            Console.WriteLine(engineDirect.GetEngineType());
            Console.WriteLine(doorsDirect.GetDoorsType());
            Console.WriteLine(carDirect.GetModel());

            // Create factory from App Settings
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Creating factory from App Settings.");
            Console.WriteLine();
            ICarAbstractFactory carFactoryAppSet = FactoryLoader.LoadFromAppSettings();
            ICar    audiAppSet   = carFactoryDirect.GetHatchBack();
            IEngine engineAppSet = audiAppSet.GetEngine();
            IDoors  doorsAppSet  = audiAppSet.GetDoors();

            Console.WriteLine("Audi - Hatchback");
            Console.WriteLine(engineAppSet.GetEngineType());
            Console.WriteLine(doorsAppSet.GetDoorsType());

            // Creating factory from custom section in config file
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Creating factory from custom section in config file.");
            Console.WriteLine();
            ICarAbstractFactory carFactoryCustomSet = FactoryLoader.LoadFromCustomSettings();
            ICar    bmwCustSet    = carFactoryDirect.GetSedan();
            IEngine engineCustSet = bmwCustSet.GetEngine();
            IDoors  doorsCustSet  = bmwCustSet.GetDoors();

            Console.WriteLine("BMW - Sedan");
            Console.WriteLine(engineCustSet.GetEngineType());
            Console.WriteLine(doorsCustSet.GetDoorsType());
            Console.WriteLine(bmwCustSet.GetModel());

            Console.Read();
        }
Ejemplo n.º 3
0
 public void setDoors(IDoors doors)
 {
     this._doors = doors;
 }
Ejemplo n.º 4
0
 public SUV(IBrakeBehaviour brake, IPower power, IDoors doors) : base(brake, power)
 {
     _doors = doors;
 }
Ejemplo n.º 5
0
 public Hatchback(IBrakeBehaviour brake, IPower power, IDoors doors) : base(brake, power)
 {
     _doors = doors;
 }
Ejemplo n.º 6
0
 public Game(IDoors doors, IResponseThingy io)
 {
     _doors = doors;
     _io    = io;
 }
Ejemplo n.º 7
0
 public DoorControl(IDoors door, IEntryNotifcation entry, IUserValidation userValidation)
 {
     _doors            = door;
     _entryNotifcation = entry;
     _userValidation   = userValidation;
 }
Ejemplo n.º 8
0
 public Audi(IEngine engine, IDoors doors)
 {
     _engine = engine;
     _doors  = doors;
 }