package com.definidev;

import org.junit.Assert;
import org.junit.Test;

public class DeckTest extends Assert {

	@Test
	public void testInitCount() {
		Card cards[] = {new Card(Rank.ACE, Suit.CLUBS), new Card(Rank.TWO, Suit.CLUBS), new Card(Rank.THREE, Suit.HEARTS)};
		Deck deck = new Deck(cards);
		assertEquals(3, deck.count());
	}
	
	@Test
	public void testToString() {
		Card cards[] = {new Card(Rank.ACE, Suit.CLUBS), new Card(Rank.TWO, Suit.CLUBS), new Card(Rank.THREE, Suit.HEARTS)};
		Deck deck = new Deck(cards);
		assertEquals("AC 2C 3H", deck.toString());
	}
	
	/* ===== Test sorting methods (depends on tests above) ===== */

	@Test
	public void testSortByRank() {
		Card cards[] = {new Card(Rank.KING, Suit.CLUBS), new Card(Rank.FOUR, Suit.CLUBS), new Card(Rank.SIX, Suit.HEARTS)};
		Deck deck = new Deck(cards);
		deck.sortByRank();
		
		assertEquals("4C 6H KC", deck.toString());
	}

	@Test
	public void testSortBySuit() {
		Card cards[] = {new Card(Rank.KING, Suit.DIAMONDS), new Card(Rank.FOUR, Suit.SPADES), new Card(Rank.SIX, Suit.HEARTS)};
		Deck deck = new Deck(cards);
		deck.sortBySuit();
		
		assertEquals("KD 6H 4S", deck.toString());
	}
	
	/* ===== End sorting methods (depends on tests above) ===== */

	
	@Test
	public void testGetAtIndex() {
		Card cards[] = {new Card(Rank.KING, Suit.DIAMONDS), new Card(Rank.FIVE, Suit.SPADES), new Card(Rank.SIX, Suit.HEARTS)};
		Deck deck = new Deck(cards);
		Card fourOfSpades = new Card(Rank.FIVE, Suit.SPADES);
		
		assertEquals(fourOfSpades, deck.getAtIndex(1));
	}
}

@@ -154,32 +154,37 @@
 Card cards%5B%5D = %7B
+%0A%09%09%09%09
 new Card(Rank.AC
@@ -191,32 +191,37 @@
 E, Suit.CLUBS), 
+%0A%09%09%09%09
 new Card(Rank.TW
@@ -228,32 +228,37 @@
 O, Suit.CLUBS), 
+%0A%09%09%09%09
 new Card(Rank.TH
@@ -266,32 +266,35 @@
 EE, Suit.HEARTS)
+%0A%09%09
 %7D;%0A%09%09Deck deck =
@@ -396,32 +396,37 @@
 Card cards%5B%5D = %7B
+%0A%09%09%09%09
 new Card(Rank.AC
@@ -433,32 +433,37 @@
 E, Suit.CLUBS), 
+%0A%09%09%09%09
 new Card(Rank.TW
@@ -469,33 +469,37 @@
 WO, Suit.CLUBS),
- 
+%0A%09%09%09%09
 new Card(Rank.TH
@@ -507,32 +507,35 @@
 EE, Suit.HEARTS)
+%0A%09%09
 %7D;%0A%09%09Deck deck =
@@ -717,32 +717,37 @@
 Card cards%5B%5D = %7B
+%0A%09%09%09%09
 new Card(Rank.KI
@@ -755,32 +755,37 @@
 G, Suit.CLUBS), 
+%0A%09%09%09%09
 new Card(Rank.FO
@@ -797,24 +797,29 @@
 uit.CLUBS), 
+%0A%09%09%09%09
 new Card(Ran
@@ -829,32 +829,35 @@
 IX, Suit.HEARTS)
+%0A%09%09
 %7D;%0A%09%09Deck deck =
@@ -996,32 +996,37 @@
 Card cards%5B%5D = %7B
+%0A%09%09%09%09
 new Card(Rank.KI
@@ -1037,32 +1037,37 @@
 Suit.DIAMONDS), 
+%0A%09%09%09%09
 new Card(Rank.FO
@@ -1076,32 +1076,37 @@
 , Suit.SPADES), 
+%0A%09%09%09%09
 new Card(Rank.SI
@@ -1112,32 +1112,35 @@
 IX, Suit.HEARTS)
+%0A%09%09
 %7D;%0A%09%09Deck deck =
@@ -1355,16 +1355,21 @@
 ds%5B%5D = %7B
+%0A%09%09%09%09
 new Card
@@ -1392,24 +1392,29 @@
 .DIAMONDS), 
+%0A%09%09%09%09
 new Card(Ran
@@ -1435,16 +1435,21 @@
 PADES), 
+%0A%09%09%09%09
 new Card
@@ -1471,16 +1471,19 @@
 .HEARTS)
+%0A%09%09
 %7D;%0A%09%09Dec

clean up DeckTest