コード例 #1
0
        public void Attacking_A_Target_Yields_A_Result()
        {
            // Arrange
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();

            // Act
            ICombatResult result = attacker.PerformAttack(attacker.BasicAttack(target));

            // Assert
            Assert.IsNotNull(result);
        }
コード例 #2
0
        public void An_Attack_Is_Logged_In_Global_Combat_Log()
        {
            // Arrange
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();
            double logCount = GlobalLog.GetInstance().GetLogCount();

            // Act
            attacker.PerformAttack(attacker.BasicAttack(target));

            // Assert
            Assert.AreNotEqual(GlobalLog.GetInstance().GetLogCount(), logCount);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: patrikeidelof/CombatApp
        /// <summary>
        /// This is the "main"
        /// </summary>
        /// <param name="args">
        /// The args. ??
        /// </param>
        public static void Main(string[] args)
        {
            logger.LogMessage += LogMessageHandler;

            var dummy1 = new TargetDummy("Kalle");
            var dummy2 = new TargetDummy("Urban");
            var drunkenness = new HitModifier() { Description = "Drunk", Value = -10 };
            for (int i = 0; i < 10; i++)
            {
                dummy1.PerformAttack(dummy1.BasicAttack(dummy2).ModifyHit(drunkenness));
                drunkenness.Value -= 10;
            }

            Console.ReadLine();
        }
コード例 #4
0
        public void Hitting_A_Target_Yields_A_Hit_Result()
        {
            // Arrange
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();
            HitModifier guaranteedHit = new HitModifier() { Description = "GuaranteeHit", Value = 100 };

            // Act
            ICombatResult result = attacker.PerformAttack(attacker.BasicAttack(target).ModifyHit(guaranteedHit));

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(HitResult));
        }
コード例 #5
0
        public void Performing_An_Attack_Created_By_Another_Entity_Yields_An_Exception()
        {
            // Arrange
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();

            // Act
            // The Attacker performs an attack that is created by the target.
            // In other words the attacker commands another entity to perform an attack
            ICombatResult result = attacker.PerformAttack(target.BasicAttack(target));

            // Assert
            // Assert is made by expecting exception
            Assert.IsNull(result);
        }
コード例 #6
0
        public void Hitting_A_Target_Yields_A_Result_With_Damage()
        {
            // Arrange, make target defenceless to guarantee a hit
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();
            HitModifier guaranteedHit = new HitModifier() { Description = "GuaranteeHit", Value = 100 };

            // Act
            HitResult result = attacker.PerformAttack(attacker.BasicAttack(target).ModifyHit(guaranteedHit)) as HitResult;

            // Assert
            Assert.IsTrue(result.InflictedDamage > 0);
        }