public void CanAttack_Diagonally_true()
 {
     QueenAttack queen = new QueenAttack(4, 4);
       Assert.Equal(true, queen.CanAttack(1,1));
       Assert.Equal(true, queen.CanAttack(8,8));
       Assert.Equal(true, queen.CanAttack(1,7));
       Assert.Equal(true, queen.CanAttack(7,1));
 }
Example #2
0
        public HomeModule()
        {
            Get["/"] = _ => {
            return View["queen.cshtml", "Tell me where your queen is"];
              };

              Get["/queen/{x}/{y}"] = parameters => {
            string output = "Choose a square to attack.";
            QueenAttack queenAttack = new QueenAttack(parameters.x, parameters.y);
            queenAttack.message = output;
            return View["canattack.cshtml", queenAttack];
              };

              Get["/attack/{x}/{y}"] = parameters => {
            string output = "Cannot attack!";
            QueenAttack currentQueenAttack = QueenAttack.GetQueen();
            if (currentQueenAttack.CanAttack(parameters.x, parameters.y)) {
              output = "Take the piece!";
            }
            currentQueenAttack.message = output;
            return View["canattack.cshtml", currentQueenAttack];
              };
        }
 public QueenAttack(int x, int y)
 {
     _x = x;
       _y = y;
       _currentQueenAttack = this;
 }
 public void QueenAttack_ForCoordinants_SeeCoordinants()
 {
     QueenAttack queen = new QueenAttack(8, 2);
       Assert.Equal(8, queen.GetX());
       Assert.Equal(2, queen.GetY());
 }
 public void CanAttack_Vertically_true()
 {
     QueenAttack queen = new QueenAttack(8,2);
       Assert.Equal(true, queen.CanAttack(7,2));
 }
 public void CanAttack_Horizontally_true()
 {
     QueenAttack queen = new QueenAttack(8,2);
       Assert.Equal(true, queen.CanAttack(8,3));
 }
 public QueenAttack(int x, int y)
 {
     _x = x;
     _y = y;
     _currentQueenAttack = this;
 }