public void Given_I_Have_a_card_list_containing_a_3_and_a_6_and_a_9_and_a_2_return_a_total_of_20() { //Given I have a list of 3 cards List <Card> dealer = new List <Card>(); //And they are 3 and 6 and 9 and 2 dealer.Add(new Card { Suit = Suit.Clubs, Value = "3" }); dealer.Add(new Card { Suit = Suit.Clubs, Value = "6" }); dealer.Add(new Card { Suit = Suit.Clubs, Value = "9" }); dealer.Add(new Card { Suit = Suit.Clubs, Value = "2" }); //And the ace == 1 (false) Boolean aceBool = false; //When i call the calculate score method ICalculateTotal calculateTotal = new CalculateTotal(new CalculateCardValue()); int total = calculateTotal.Calculate(dealer, aceBool); //Then i get back a total of 20 Assert.AreEqual(20, total); }
public void Given_I_Have_5_Cards_calculateCardValue_is_called_five_times() { //Given I have a list of 3 cards List <Card> dealer = new List <Card>(); //And they are 3, 6, 9, King and Ace dealer.Add(new Card { Suit = Suit.Clubs, Value = "3" }); dealer.Add(new Card { Suit = Suit.Clubs, Value = "6" }); dealer.Add(new Card { Suit = Suit.Clubs, Value = "9" }); dealer.Add(new Card { Suit = Suit.Clubs, Value = "King" }); dealer.Add(new Card { Suit = Suit.Clubs, Value = "Ace" }); //And the ace == 1 (false) Boolean aceBool = false; //And I have a calculateTotal object Mock <ICalculateCardValue> mock = new Mock <ICalculateCardValue>(); //When i call the calculate score Flow method ICalculateTotal calculateTotalFlow = new CalculateTotal(mock.Object); calculateTotalFlow.Calculate(dealer, aceBool); //Then i will verify that the Calculate card value object is called twice mock.Verify(m => m.Calculate(It.IsAny <string>(), It.IsAny <Boolean>()), Times.Exactly(5)); }
public void Given_I_Have_a_card_list_containing_a_3_and_a_6_return_a_total_of_9() { //Given I have a list of 2 cards List <Card> dealer = new List <Card>(); //And they are 3 and 6 dealer.Add(new Card { Suit = Suit.Clubs, Value = "3" }); dealer.Add(new Card { Suit = Suit.Clubs, Value = "6" }); //And the ace == 1 (false) Boolean aceBool = false; //And I have a calculateTotal object Mock <ICalculateCardValue> mock = new Mock <ICalculateCardValue>(); //When i call the calculate score Flow method ICalculateTotal calculateTotalFlow = new CalculateTotal(new CalculateCardValue()); int total = calculateTotalFlow.Calculate(dealer, aceBool); ////Then i get back a total of 9 Assert.AreEqual(9, total); //Then i will verify that the Calculate card value object is called twice //mock.Verify(m => m.Calculate(It.IsAny<List<Card>>(), aceBool), Times.Once); }
public void TestMethod1() { CalculateTotal calculateTest = new CalculateTotal(); decimal result = calculateTest.GetFinalTotal(50.00m); Assert.AreEqual(53.00m, result); }
public void Given_I_Have_a_card_list_containing_a_10_and_a_king_return_a_total_of_20() { //Given I have a list of 2 cards List <Card> dealer = new List <Card>(); //And they are 10 and King dealer.Add(new Card { Suit = Suit.Clubs, Value = "10" }); dealer.Add(new Card { Suit = Suit.Clubs, Value = "King" }); //And the ace == 1 (false) Boolean aceBool = false; //When i call the calculate score method ICalculateTotal calculateTotal = new CalculateTotal(new CalculateCardValue()); int total = calculateTotal.Calculate(dealer, aceBool); Assert.AreEqual(20, total); }
public void Given_I_Have_a_card_list_containing_a_3_and_an_Ace_with_the_ace_being_true_return_a_total_of_14() { //Given I have a list of 3 cards List <Card> dealer = new List <Card>(); //And they are 3 and an Ace dealer.Add(new Card { Suit = Suit.Clubs, Value = "3" }); dealer.Add(new Card { Suit = Suit.Clubs, Value = "Ace" }); //And the ace == 1 (false) Boolean aceBool = true; //When i call the calculate score method ICalculateTotal calculateTotal = new CalculateTotal(new CalculateCardValue()); int total = calculateTotal.Calculate(dealer, aceBool); //Then i get back a total of 14 Assert.AreEqual(14, total); }
public void Given_I_Have_a_card_list_containing_an_Ace_and_a_Queen_with_the_option_of_ace_being_false_return_a_total_of_11() { //Given I have a list of 2 cards List <Card> dealer = new List <Card>(); //And they are Jack and Ace dealer.Add(new Card { Suit = Suit.Clubs, Value = "Ace" }); dealer.Add(new Card { Suit = Suit.Clubs, Value = "Jack" }); //And the ace == 1 (false) Boolean aceBool = false; //When i call the calculate score method ICalculateTotal calculateTotal = new CalculateTotal(new CalculateCardValue()); int total = calculateTotal.Calculate(dealer, aceBool); //Then i get back a total of 11 Assert.AreEqual(11, total); }