コード例 #1
0
        public void TestContainsNumberInArray()
        {
            int[] numbers = { 1, 3, 6, 4 };

            Assert.That(ArrayUtils.ArrayContainsNumber(numbers, 6));
            Assert.That(!ArrayUtils.ArrayContainsNumber(numbers, 2));
            Assert.That(ArrayUtils.ArrayContainsNumber(numbers, 4));
        }
コード例 #2
0
 /// <summary>
 /// 
 /// Records that a ship has been hit in the current battle. Will only 
 /// record that a ship has been hit, not the number of 
 /// times it has been hit. 
 /// </summary>
 /// <param name="indexOfShipHit"></param>
 private void UpdateBattleInformation(int indexOfShipHit)
 {
     if (ArrayUtils.ArrayContainsNumber(ShipsHitInCurrentBattle, indexOfShipHit))
     {
         return;
     }
     ShipsHitInCurrentBattle = ArrayUtils.AddNumber(ShipsHitInCurrentBattle, indexOfShipHit);
 }
コード例 #3
0
 public void TestAddNumberToArray()
 {
     int[] numbers = { 1, 3, 6, 4, 2 };
     numbers = ArrayUtils.AddNumber(numbers, 5);
     Assert.That(numbers.Length, Is.EqualTo(6));
     Assert.That(numbers[5], Is.EqualTo(5));
     Assert.That(ArrayUtils.ArrayContainsNumber(numbers, 5));
 }
コード例 #4
0
 private bool HasShipBeenHitInCurrentBattle(int spaceShipPosition)
 {
     return ArrayUtils.ArrayContainsNumber(ShipsHitInCurrentBattle, spaceShipPosition);
 }