Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Person person = new Person
            {
                FirstName   = "Abc",
                LastName    = "Xyz",
                DateOfBirth = new DateTime(1992, 11, 16)
            };

            Console.WriteLine("Age is {0}", person.GetAge());


            //Static Polymorphism
            DieselEngine dieselEngine = new DieselEngine();

            dieselEngine.Start();

            //Dynamic Polymorphism
            Engine engine = new PetrolEngine();

            engine.Start();

            Exhaustable exhaustable = new Car(engine);

            exhaustable.Exhaust();

            exhaustable = new PowerGenerator();
            exhaustable.Exhaust();
        }
Exemplo n.º 2
0
        public void StartPetrolEngine()
        {
            //Arrange
            var petrolEngine        = new PetrolEngine();
            var expectedEngineSound = "vroom";
            var actualEngineSound   = string.Empty;

            //Act
            actualEngineSound = petrolEngine.Start();

            //Assert
            Assert.Same(expectedEngineSound, actualEngineSound);
        }
Exemplo n.º 3
0
 public override string Start()
 {
     return(string.Format("The car {0}", petrolengine.Start()));
 }