Beispiel #1
0
        public void HitMethodOnMissedSquareReturnsHitResultMissed()
        {
            ship ship = new ship(new List <Square> {
                new Square(1, 4), new Square(1, 5), new Square(1, 6)
            });
            var result = ship.Hit(new Square(2, 5));

            Assert.AreEqual(HitResult.Missed, result);
        }
Beispiel #2
0
        public void ConstructorCreateShipFromSquaresProvided()
        {
            ship Ship = new ship(new List <Square> {
                new Square(1, 4), new Square(1, 5), new Square(1, 6)
            });

            Assert.IsTrue(Ship.squares.Contains(new Square(1, 4)));
            Assert.IsTrue(Ship.squares.Contains(new Square(1, 5)));
            Assert.IsTrue(Ship.squares.Contains(new Square(1, 6)));
        }
Beispiel #3
0
        public void HitMethodOnLastSquareReturnsHitResultSunken()
        {
            ship ship = new ship(new List <Square> {
                new Square(1, 4), new Square(1, 5), new Square(1, 6)
            });
            var result = ship.Hit(new Square(1, 5));

            result = ship.Hit(new Square(1, 4));
            result = ship.Hit(new Square(1, 6));
            Assert.AreEqual(HitResult.Sunken, result);
        }
Beispiel #4
0
        public void WhenShipIsSunkenAllSquaresAllMarkedSunken()
        {
            ship ship = new ship(new List <Square> {
                new Square(1, 1), new Square(1, 2), new Square(1, 3)
            });
            int x = 1;

            for (int i = 0; i < 3; ++i)
            {
                ship.Hit(new Square(1, x));
                ++x;
            }
            Assert.AreEqual(SquareState.Sunken, ship.squares.First().SquareState);
        }
Beispiel #5
0
 public void HitMethodOnFirstSquareReturnsHitResultHit()
 {
     {
         ship ship = new ship(new List <Square> {
             new Square(1, 4), new Square(1, 5), new Square(1, 6)
         });
         var result = ship.Hit(new Square(1, 5));
         Assert.AreEqual(HitResult.Hit, result);
     }
     {
         ship ship = new ship(new List <Square> {
             new Square(1, 4), new Square(1, 5), new Square(1, 6)
         });
         var result = ship.Hit(new Square(1, 4));
         Assert.AreEqual(HitResult.Hit, result);
     }
     {
         ship ship = new ship(new List <Square> {
             new Square(1, 4), new Square(1, 5), new Square(1, 6)
         });
         var result = ship.Hit(new Square(1, 6));
         Assert.AreEqual(HitResult.Hit, result);
     }
 }