mirror of
				https://github.com/inf112-v20/Fiasko.git
				synced 2025-10-31 09:43:45 +01:00 
			
		
		
		
	Laget test for shuffle
This commit is contained in:
		| @@ -3,10 +3,13 @@ package inf112.fiasko.roborally.objects; | |||||||
| import inf112.fiasko.roborally.element_properties.Action; | import inf112.fiasko.roborally.element_properties.Action; | ||||||
| import org.junit.Before; | import org.junit.Before; | ||||||
| import org.junit.Test; | import org.junit.Test; | ||||||
| import static org.junit.Assert.assertEquals; |  | ||||||
|  |  | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
|  |  | ||||||
|  | import static org.junit.Assert.*; | ||||||
|  |  | ||||||
|  |  | ||||||
| public class TestPlayerDeck { | public class TestPlayerDeck { | ||||||
|     private ProgrammingCard programmingCard1 = new ProgrammingCard(5, Action.MOVE_1); |     private ProgrammingCard programmingCard1 = new ProgrammingCard(5, Action.MOVE_1); | ||||||
|     private ProgrammingCard programmingCard2 = new ProgrammingCard(6, Action.MOVE_2); |     private ProgrammingCard programmingCard2 = new ProgrammingCard(6, Action.MOVE_2); | ||||||
| @@ -75,35 +78,32 @@ public class TestPlayerDeck { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Test |     @Test | ||||||
|     public void testshuffle(){ |     public void testShuffle(){ | ||||||
|         ProgrammingCard card1 =(ProgrammingCard)  testDeck.getCards().get(0); |         Boolean atLeastOneShuffle = false; | ||||||
|         int noe = card1.getValue(); |         ArrayList<Boolean> resultList = new ArrayList<>(); | ||||||
|         ProgrammingCard card2 =(ProgrammingCard)  testDeck.getCards().get(1); |         ArrayList<ProgrammingCard> beforeShuffle = (ArrayList<ProgrammingCard>)testDeck.getCards(); | ||||||
|         int noe2 = card2.getValue(); |  | ||||||
|         ProgrammingCard card3 =(ProgrammingCard)  testDeck.getCards().get(2); |  | ||||||
|         int noe3 = card3.getValue(); |  | ||||||
|  |  | ||||||
|         System.out.println(noe); |  | ||||||
|         System.out.println(noe2); |  | ||||||
|         System.out.println(noe3); |  | ||||||
|  |  | ||||||
|  |         for (int i = 0; i < 10; i++){ //Saves result of ten shuffles | ||||||
|             testDeck.shuffle(); |             testDeck.shuffle(); | ||||||
|  |             ArrayList<ProgrammingCard> afterShuffle = (ArrayList<ProgrammingCard>)testDeck.getCards(); | ||||||
|  |             if (beforeShuffle != afterShuffle) { | ||||||
|  |                 resultList.add(true); | ||||||
|  |             } | ||||||
|  |             else { | ||||||
|  |                 resultList.add(false); | ||||||
|  |             } | ||||||
|  |  | ||||||
|         ProgrammingCard scard1 =(ProgrammingCard)  testDeck.getCards().get(0); |         } | ||||||
|         int snoe = scard1.getValue(); |         //Looks to see if at least one shuffle is different from before | ||||||
|         ProgrammingCard scard2 =(ProgrammingCard)  testDeck.getCards().get(1); |         for (int i = 0; i < resultList.size(); i++) { | ||||||
|         int snoe2 = scard2.getValue(); |             if (resultList.get(i)==true) { | ||||||
|         ProgrammingCard scard3 =(ProgrammingCard)  testDeck.getCards().get(2); |                 atLeastOneShuffle = true; | ||||||
|         int snoe3 = scard3.getValue(); |             } | ||||||
|  |  | ||||||
|         System.out.println(snoe); |  | ||||||
|         System.out.println(snoe2); |  | ||||||
|         System.out.println(snoe3); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         } | ||||||
|  |         assertTrue(atLeastOneShuffle); | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 GabrielMagnus
					GabrielMagnus