Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.86 KB | None | 0 0
  1. /*
  2. *File: TestBoardMethods.java
  3. *Author: Valerie Lynn Castellano
  4. *Team: PUNishers
  5. *Project: Aggie Chess Game
  6. *Course: CSCE 315
  7. *Section: 501
  8. *Github Repository:
  9. * https://github.tamu.edu/valerie-lynn25/315-game-PUNishers
  10. *Visual Studio Team Repository:
  11. * https://punishers.visualstudio.com/Aggie%20Chess
  12. */
  13. /*----------PACKAGE----------*/
  14. package com.aggieChessGame.engine.gameBoard.tests;
  15.  
  16. /*----------IMPORTS----------*/
  17. import org.junit.Test;
  18. //import org.junit.BeforeClass;
  19. import org.junit.runner.Result;
  20. import java.lang.Long;
  21. import java.util.ArrayList;
  22. import static org.junit.Assert.assertEquals;
  23.  
  24. /*----------FROM PACKAGE----------*/
  25. import com.aggieChessGame.engine.gameBoard.Board;
  26.  
  27. /**
  28. *Unit test for the Board class methods.
  29. *@author Valerie Lynn Castellano
  30. *@version 1.0
  31. */
  32.  
  33. public class TestBoardMethods{
  34. Board test = new Board();
  35. ArrayList<String> moves = new ArrayList();
  36.  
  37. @Test
  38. public void testBoardMethods(){/*
  39. System.out.println("TEST FOR WHITE QUEEN LEGAL MOVES WITH NO MODIFIERS:");
  40. test.newPosition("whiteQueen", test.convertLocation2("a3"));
  41. moves = test.legalMoves("whiteQueen");
  42. for(int i = 0; i < moves.size(); i++){
  43. System.out.println(moves.get(i));
  44. }
  45.  
  46. //GRADUATION
  47. System.out.println("TEST FOR WHITE QUEEN LEGAL MOVES WHEN SOMEONE ELSE(EITHER OPPONENT OR ALLY) IS ON GRADUATION:");
  48. test.newPosition("blackKnight1", test.convertLocation2("a5"));
  49. test.getModifiers().get(5).setPosition(test.convertLocation2("a5"));
  50.  
  51. for(int i = 0; i < test.getBlackPieces().size(); i++){
  52. if(test.getBlackPieces().get(i).getName().equals("blackKnight1")){
  53. try{
  54. test.getBlackPieces().get(i).setMod("graduation");
  55. }catch(Exception e){
  56. e.printStackTrace();
  57. }
  58. }
  59. }
  60.  
  61. moves = test.legalMoves("whiteQueen");
  62. for(int i = 0; i < moves.size(); i++){
  63. System.out.println(moves.get(i));
  64. }
  65.  
  66. for(int i = 0; i < test.getBlackPieces().size(); i++){
  67. if(test.getBlackPieces().get(i).getName().equals("blackKnight1")){
  68. try{
  69. test.getBlackPieces().get(i).setMod(null);
  70. }catch(Exception e){
  71. e.printStackTrace();
  72. }
  73. }
  74. }
  75.  
  76.  
  77. System.out.println("TEST FOR WHITE QUEEN LEGAL MOVES WHEN ON ANGRY TEACHER:");
  78. System.out.println("As done for angryTeacher, should return empty arraylist");
  79. //angryTeacher
  80. System.out.println(test.convertLocation2("a3") + "\n");
  81.  
  82. test.getModifiers().get(1).setPosition(test.convertLocation2("a3"));
  83.  
  84. System.out.println(test.getModifiers().get(1).getPosition() + "\n");
  85. for(int i = 0; i < test.getWhitePieces().size(); i++){
  86. if(test.getWhitePieces().get(i).getName().equals("whiteQueen")){
  87. try{
  88. test.getWhitePieces().get(i).setMod("angryTeacher");
  89. }catch(Exception e){
  90. e.printStackTrace();
  91. }
  92. }
  93. }
  94.  
  95. moves = test.legalMoves("whiteQueen");
  96. for(int i = 0; i < moves.size(); i++){
  97. System.out.println(moves.get(i));
  98. }
  99. for(int i = 0; i < test.getWhitePieces().size(); i++){
  100. if(test.getWhitePieces().get(i).getName().equals("whiteQueen")){
  101. try{
  102. test.getWhitePieces().get(i).setMod(null);
  103. }catch(Exception e){
  104. e.printStackTrace();
  105. }
  106. }
  107. }
  108.  
  109.  
  110.  
  111.  
  112.  
  113. //RIDE THE BUS
  114. System.out.println("TEST FOR WHITE QUEEN LEGAL MOVES WHEN ON RIDE THE BUS:");
  115.  
  116. System.out.println(test.convertLocation2("a3") + "\n");
  117.  
  118. test.getModifiers().get(0).setPosition(test.convertLocation2("a3"));
  119.  
  120. System.out.println(test.getModifiers().get(0).getPosition() + "\n");
  121. for(int i = 0; i < test.getWhitePieces().size(); i++){
  122. if(test.getWhitePieces().get(i).getName().equals("whiteQueen")){
  123. try{
  124. test.getWhitePieces().get(i).setMod("rideTheBus");
  125. }catch(Exception e){
  126. e.printStackTrace();
  127. }
  128. }
  129. }
  130.  
  131. moves = test.legalMoves("whiteQueen");
  132. for(int i = 0; i < moves.size(); i++){
  133. System.out.println(moves.get(i));
  134. }
  135. for(int i = 0; i < test.getWhitePieces().size(); i++){
  136. if(test.getWhitePieces().get(i).getName().equals("whiteQueen")){
  137. try{
  138. test.getWhitePieces().get(i).setMod(null);
  139. }catch(Exception e){
  140. e.printStackTrace();
  141. }
  142. }
  143. }
  144.  
  145. */
  146. System.out.println("TEST FOR RESET COUNT AND SUCCESSIVE SPAWNING OF NEW MODS:");
  147. // test.getModifiers().get(0).setOnBoard();
  148. // test.getModifiers().get(0).setPosition(test.convertLocation2("d1"));
  149.  
  150. // test.getModifiers().get(3).setOnBoard();
  151. // test.getModifiers().get(3).setPosition(test.convertLocation2("d7"));
  152. // test.getModifiers().get(3).setActive();
  153.  
  154. // test.newPosition("blackBishop1", test.convertLocation2("d7"));
  155. // for(int i = 0; i < test.getBlackPieces().size(); i++){
  156. // if(test.getBlackPieces().get(i).getName().equals("blackBishop1")){
  157. // try{
  158. // test.getBlackPieces().get(i).setMod("coffee");
  159. // }catch(Exception e){
  160. // e.printStackTrace();
  161. // }
  162. // }
  163. // }
  164. test.resetCount();/*
  165. *File: TestBoardMethods.java
  166. *Author: Valerie Lynn Castellano
  167. *Team: PUNishers
  168. *Project: Aggie Chess Game
  169. *Course: CSCE 315
  170. *Section: 501
  171. *Github Repository:
  172. * https://github.tamu.edu/valerie-lynn25/315-game-PUNishers
  173. *Visual Studio Team Repository:
  174. * https://punishers.visualstudio.com/Aggie%20Chess
  175. */
  176. /*----------PACKAGE----------*/
  177. package com.aggieChessGame.engine.gameBoard.tests;
  178.  
  179. /*----------IMPORTS----------*/
  180. import org.junit.Test;
  181. //import org.junit.BeforeClass;
  182. import org.junit.runner.Result;
  183. import java.lang.Long;
  184. import java.util.ArrayList;
  185. import static org.junit.Assert.assertEquals;
  186.  
  187. /*----------FROM PACKAGE----------*/
  188. import com.aggieChessGame.engine.gameBoard.Board;
  189.  
  190. /**
  191. *Unit test for the Board class methods.
  192. *@author Valerie Lynn Castellano
  193. *@version 1.0
  194. */
  195.  
  196. public class TestBoardMethods{
  197. Board test = new Board();
  198. ArrayList<String> moves = new ArrayList();
  199.  
  200. @Test
  201. public void testBoardMethods(){
  202. System.out.println("TEST FOR WHITE QUEEN LEGAL MOVES WITH NO MODIFIERS:");
  203. test.newPosition("whiteQueen", test.convertLocation2("a3"));
  204. moves = test.legalMoves("whiteQueen");
  205. for(int i = 0; i < moves.size(); i++){
  206. System.out.println(moves.get(i));
  207. }
  208.  
  209. //GRADUATION
  210. System.out.println("TEST FOR WHITE QUEEN LEGAL MOVES WHEN SOMEONE ELSE(EITHER OPPONENT OR ALLY) IS ON GRADUATION:");
  211. test.newPosition("blackKnight1", test.convertLocation2("a5"));
  212. test.getModifiers().get(5).setPosition(test.convertLocation2("a5"));
  213.  
  214. for(int i = 0; i < test.getBlackPieces().size(); i++){
  215. if(test.getBlackPieces().get(i).getName().equals("blackKnight1")){
  216. try{
  217. test.getBlackPieces().get(i).setMod("graduation");
  218. }catch(Exception e){
  219. e.printStackTrace();
  220. }
  221. }
  222. }
  223. test.resetCount();
  224.  
  225. /*
  226. moves = test.legalMoves("whiteQueen");
  227. for(int i = 0; i < moves.size(); i++){
  228. System.out.println(moves.get(i));
  229. }
  230.  
  231. for(int i = 0; i < test.getBlackPieces().size(); i++){
  232. if(test.getBlackPieces().get(i).getName().equals("blackKnight1")){
  233. try{
  234. test.getBlackPieces().get(i).setMod(null);
  235. }catch(Exception e){
  236. e.printStackTrace();
  237. }
  238. }
  239. }
  240.  
  241.  
  242. System.out.println("TEST FOR WHITE QUEEN LEGAL MOVES WHEN ON ANGRY TEACHER:");
  243. System.out.println("As done for angryTeacher, should return empty arraylist");
  244. //angryTeacher
  245. System.out.println(test.convertLocation2("a3") + "\n");
  246.  
  247. test.getModifiers().get(1).setPosition(test.convertLocation2("a3"));
  248.  
  249. System.out.println(test.getModifiers().get(1).getPosition() + "\n");
  250. for(int i = 0; i < test.getWhitePieces().size(); i++){
  251. if(test.getWhitePieces().get(i).getName().equals("whiteQueen")){
  252. try{
  253. test.getWhitePieces().get(i).setMod("angryTeacher");
  254. }catch(Exception e){
  255. e.printStackTrace();
  256. }
  257. }
  258. }
  259.  
  260. moves = test.legalMoves("whiteQueen");
  261. for(int i = 0; i < moves.size(); i++){
  262. System.out.println(moves.get(i));
  263. }
  264. for(int i = 0; i < test.getWhitePieces().size(); i++){
  265. if(test.getWhitePieces().get(i).getName().equals("whiteQueen")){
  266. try{
  267. test.getWhitePieces().get(i).setMod(null);
  268. }catch(Exception e){
  269. e.printStackTrace();
  270. }
  271. }
  272. }
  273.  
  274.  
  275.  
  276.  
  277.  
  278. //RIDE THE BUS
  279. System.out.println("TEST FOR WHITE QUEEN LEGAL MOVES WHEN ON RIDE THE BUS:");
  280.  
  281. System.out.println(test.convertLocation2("a3") + "\n");
  282.  
  283. test.getModifiers().get(0).setPosition(test.convertLocation2("a3"));
  284.  
  285. System.out.println(test.getModifiers().get(0).getPosition() + "\n");
  286. for(int i = 0; i < test.getWhitePieces().size(); i++){
  287. if(test.getWhitePieces().get(i).getName().equals("whiteQueen")){
  288. try{
  289. test.getWhitePieces().get(i).setMod("rideTheBus");
  290. }catch(Exception e){
  291. e.printStackTrace();
  292. }
  293. }
  294. }
  295.  
  296. moves = test.legalMoves("whiteQueen");
  297. for(int i = 0; i < moves.size(); i++){
  298. System.out.println(moves.get(i));
  299. }
  300. for(int i = 0; i < test.getWhitePieces().size(); i++){
  301. if(test.getWhitePieces().get(i).getName().equals("whiteQueen")){
  302. try{
  303. test.getWhitePieces().get(i).setMod(null);
  304. }catch(Exception e){
  305. e.printStackTrace();
  306. }
  307. }
  308. }
  309.  
  310. */
  311. System.out.println("TEST FOR RESET COUNT AND SUCCESSIVE SPAWNING OF NEW MODS:");
  312. // test.getModifiers().get(0).setOnBoard();
  313. // test.getModifiers().get(0).setPosition(test.convertLocation2("d1"));
  314.  
  315. // test.getModifiers().get(3).setOnBoard();
  316. // test.getModifiers().get(3).setPosition(test.convertLocation2("d7"));
  317. // test.getModifiers().get(3).setActive();
  318.  
  319. // test.newPosition("blackBishop1", test.convertLocation2("d7"));
  320. // for(int i = 0; i < test.getBlackPieces().size(); i++){
  321. // if(test.getBlackPieces().get(i).getName().equals("blackBishop1")){
  322. // try{
  323. // test.getBlackPieces().get(i).setMod("coffee");
  324. // }catch(Exception e){
  325. // e.printStackTrace();
  326. // }
  327. // }
  328. // }
  329.  
  330. //test.spawnMods();
  331.  
  332.  
  333. //test.spawnMods();
  334.  
  335.  
  336.  
  337.  
  338. assertEquals(true, true);
  339.  
  340.  
  341. }
  342.  
  343. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement