示例#1
0
        static void Main(string[] args)
        {
            Duck mallarDuck = new MallarDuck();

            mallarDuck.SetFlyBehavior(new FlyNoWay());

            mallarDuck.Display();
            mallarDuck.PerformFly();
            mallarDuck.SetFlyBehavior(new FlyWithWings());
            mallarDuck.PerformFly();
            Console.ReadLine();
        }
        public void MallarDuck_Should_Quack_Swim_Fly_Display()
        {
            Duck mallarDuck = new MallarDuck();

            Assert.Equal("quack", mallarDuck.PerformQuack());
            Assert.Equal("swim", mallarDuck.Swim());
            Assert.Equal("fly", mallarDuck.PerformFly());
            Assert.Equal("looks like a mallard", mallarDuck.Display());
        }
示例#3
0
        private static void Main(string[] args)
        {
            Duck mallard = new MallarDuck();

            mallard.SetFlyBehavior(new  FlyNoWay());
            mallard.SetQuackBehavior(new Quack());
            var result = mallard.PerformQuack();
            var msj    = mallard.PerformFly();

            Console.WriteLine(result);
            Console.WriteLine(msj);

            mallard.SetFlyBehavior(new FlyWithWings());
            mallard.SetQuackBehavior(new MuteQuack());

            var result1 = mallard.PerformQuack();
            var msj1    = mallard.PerformFly();

            Console.WriteLine("----------------------------------------------------");
            Console.WriteLine(result1);
            Console.WriteLine(msj1);
            Console.ReadLine();
        }
示例#4
0
        public void MallarDuck_ShuldQuackAndFlyAndDisplay()
        {
            //Arrange
            Duck mallar = new MallarDuck();

            //Act
            var fly     = mallar.PerformFly();
            var quack   = mallar.PerformQuack();
            var display = mallar.Display();

            //Assert
            fly.Should().Be("I'm flying!!");
            quack.Should().Be("Quack");
            display.Should().Be("I'm a real Mallard duck");
        }