예제 #1
0
        public void SwitchStates()
        {
            var dragon = new Dragon();

            dragon.Fly();

            Assert.AreEqual(1000, dragon.State.Speed);
            Assert.IsTrue(dragon.State.Flying);
            Assert.IsFalse(dragon.State.Walking);

            dragon.Walk();

            Assert.AreEqual(10, dragon.State.Speed);
            Assert.IsFalse(dragon.State.Flying);
            Assert.IsTrue(dragon.State.Walking);
        }
예제 #2
0
        public void WindUpgradeIncreasesWindDamage()
        {
            IDragon dragon = new Dragon();

            Assert.AreEqual(1, dragon.FireDamage);
            Assert.AreEqual(1, dragon.WaterDamage);
            Assert.AreEqual(1, dragon.EarthDamage);
            Assert.AreEqual(1, dragon.WindDamage);

            dragon = new DragonWindUpgrade(dragon);

            Assert.AreEqual(1, dragon.FireDamage);
            Assert.AreEqual(1, dragon.WaterDamage);
            Assert.AreEqual(1, dragon.EarthDamage);
            Assert.AreEqual(11, dragon.WindDamage);
        }
예제 #3
0
        public void DealDamageDifferentTypes()
        {
            var dragon = new Dragon {
                HitPoints = 1000
            };
            var human = new Human {
                HitPoints = 1
            };

            var projectile = new GigaBlastProjectile();

            dragon.Accept(projectile);
            human.Accept(projectile);

            Assert.AreEqual(999, dragon.HitPoints);
            Assert.AreEqual(-1000, human.HitPoints);
        }
예제 #4
0
        public void DragonFlyPeopleLookUp()
        {
            Dragon dragon = new Dragon();

            Person p1 = new Person();
            Person p2 = new Person();
            Person p3 = new Person();

            dragon.Subscribe(p1);
            dragon.Subscribe(p2);

            dragon.Flying = true;

            Assert.AreEqual(Person.LookingDirectionTypes.Up, p1.LookingDirection);
            Assert.AreEqual(Person.LookingDirectionTypes.Up, p2.LookingDirection);
            Assert.AreEqual(Person.LookingDirectionTypes.Foward, p3.LookingDirection);
        }
예제 #5
0
        public void ClonedObjectsAreNotSame()
        {
            Dragon d1 = new Dragon {
                Attack = 9000
            };
            Dragon d2 = d1;
            Dragon d3 = null;

            d3 = (Dragon)d1.Clone();

            Assert.AreSame(d1, d2);
            Assert.AreNotSame(d1, d3);
            Assert.AreEqual(d1.Attack, d3.Attack);

            d3.Attack = 555;

            Assert.AreNotEqual(d1.Attack, d3.Attack);
        }
예제 #6
0
        public void CompositeAttackDealsCompositeDamage()
        {
            var d1 = new Dragon();
            var d2 = new Dragon();
            var d3 = new Dragon();
            var d4 = new Dragon();
            var d5 = new Dragon();

            var composite = new DragonComposite();

            composite.Add(d1);
            composite.Add(d2);
            composite.Add(d3);
            composite.Add(d4);

            Assert.AreEqual(340, composite.Attack());
            Assert.AreEqual(100, d5.Attack());
        }
예제 #7
0
        public void DragonsMoveAreRecorded()
        {
            var dragon         = new Dragon();
            var dragonRecorder = new Recorder(dragon);

            dragonRecorder.Record();

            Assert.AreEqual(0, dragon.PositionX);
            Assert.AreEqual(0, dragon.PositionY);

            dragon.PositionX = 100;
            dragon.PositionY = 50;
            dragonRecorder.Record();

            Assert.AreEqual(100, dragon.PositionX);
            Assert.AreEqual(50, dragon.PositionY);

            dragon.PositionX = 500;
            dragon.PositionY = 500;
            dragonRecorder.Record();

            Assert.AreEqual(500, dragon.PositionX);
            Assert.AreEqual(500, dragon.PositionY);

            dragonRecorder.Rewind();

            Assert.AreEqual(100, dragon.PositionX);
            Assert.AreEqual(50, dragon.PositionY);

            dragonRecorder.Rewind();

            Assert.AreEqual(0, dragon.PositionX);
            Assert.AreEqual(0, dragon.PositionY);

            dragonRecorder.Foward();

            Assert.AreEqual(100, dragon.PositionX);
            Assert.AreEqual(50, dragon.PositionY);

            dragonRecorder.Foward();

            Assert.AreEqual(500, dragon.PositionX);
            Assert.AreEqual(500, dragon.PositionY);
        }
예제 #8
0
        public void UpgradeStacks()
        {
            IDragon dragon = new Dragon();

            Assert.AreEqual(1, dragon.FireDamage);
            Assert.AreEqual(1, dragon.WaterDamage);
            Assert.AreEqual(1, dragon.EarthDamage);
            Assert.AreEqual(1, dragon.WindDamage);

            dragon = new DragonFireUpgrade(dragon);
            dragon = new DragonFireUpgrade(dragon);
            dragon = new DragonWaterUpgrade(dragon);
            dragon = new DragonEarthUpgrade(dragon);
            dragon = new DragonWindUpgrade(dragon);

            Assert.AreEqual(21, dragon.FireDamage);
            Assert.AreEqual(11, dragon.WaterDamage);
            Assert.AreEqual(11, dragon.EarthDamage);
            Assert.AreEqual(11, dragon.WindDamage);
        }
예제 #9
0
        public void DragonsRage()
        {
            var dragonsHoardNorth  = new DragonMediator();
            var dragonsHoardSoulth = new DragonMediator();

            var d1 = new Dragon(dragonsHoardNorth);
            var d2 = new Dragon(dragonsHoardNorth);
            var d3 = new Dragon(dragonsHoardSoulth);
            var d4 = new Dragon(dragonsHoardSoulth);

            d1.DragonsCall();

            Assert.AreEqual(100, d1.Rage);
            Assert.AreEqual(100, d2.Rage);

            d2.DragonsCall();

            Assert.AreEqual(200, d1.Rage);
            Assert.AreEqual(200, d2.Rage);

            Assert.AreEqual(0, d3.Rage);
            Assert.AreEqual(0, d4.Rage);
        }
예제 #10
0
        public void DragonMoveWalk()
        {
            var dragon = new Dragon();

            Assert.AreEqual("Walking", dragon.Move(new WalkMoveBridge()));
        }
예제 #11
0
        public void DragonMoveFly()
        {
            var dragon = new Dragon();

            Assert.AreEqual("Flying", dragon.Move(new FlyMoveBridge()));
        }