示例#1
0
        public void Payout_WhenThereIsNotAWinner_Integration_ReturnsNegativeAmount()
        {
            //Arrange
            string      gamblersName        = "Otis";
            int         gamblersCash        = 25;
            RadioButton gamblersRadioButton = new RadioButton();
            Label       gamblersLabel       = new Label();

            Gambler bettor = new Gambler()
            {
                Name          = gamblersName,
                Cash          = gamblersCash,
                MyRadioButton = gamblersRadioButton,
                MyLabel       = gamblersLabel
            };

            int betAmount      = 20;
            int chosenSquirrel = 1;

            bettor.MyBet = new Bet()
            {
                Amount = betAmount, Squirrel = chosenSquirrel, Bettor = bettor
            };

            int expectedCash = 5;

            //Act
            bettor.Collect(2);
            int actualCash = bettor.Cash;

            //Assert
            Assert.AreEqual(expectedCash, actualCash);
        }
示例#2
0
        public void CollectBet_WhenGamblerLoses()
        {
            //Arrange
            string      gamblersName        = "Cloud";
            int         gamblersCash        = 25;
            Bet         gamblersBet         = null;
            RadioButton gamblersRadioButton = new RadioButton();
            Label       gamblersLabel       = new Label();

            Gambler bettor = new Gambler()
            {
                Name          = gamblersName,
                Cash          = gamblersCash,
                MyBet         = gamblersBet,
                MyRadioButton = gamblersRadioButton,
                MyLabel       = gamblersLabel
            };

            int betAmount      = 20;
            int chosenSquirrel = 1;

            bettor.MyBet = new Bet()
            {
                Amount = betAmount, Squirrel = chosenSquirrel, Bettor = bettor
            };

            int expectedCash = 5;

            //Act
            bettor.Collect(2);
            int actualCash = bettor.Cash;

            //Assert
            Assert.AreEqual(expectedCash, actualCash);
        }
示例#3
0
        public void Payout_WhenThereIsAWinner_Integration_ReturnsPositiveAmount()
        {
            /* TODO Get feedback on the best way to test a class that is only instantiated through another class.
             * Following the same assumption to test it like it's implemented (from Gambler), then this test
             * and the ReturnsNegativeAmount are copy/pastes of the GamblerTest\CollectBet tests.
             * */

            //Arrange
            string      gamblersName        = "Barney";
            int         gamblersCash        = 25;
            RadioButton gamblersRadioButton = new RadioButton();
            Label       gamblersLabel       = new Label();

            Gambler bettor = new Gambler()
            {
                Name          = gamblersName,
                Cash          = gamblersCash,
                MyRadioButton = gamblersRadioButton,
                MyLabel       = gamblersLabel
            };

            int betAmount      = 20;
            int chosenSquirrel = 1;

            bettor.MyBet = new Bet()
            {
                Amount = betAmount, Squirrel = chosenSquirrel, Bettor = bettor
            };

            int expectedCash = 45;

            //Act
            bettor.Collect(chosenSquirrel);
            int actualCash = bettor.Cash;

            //Assert
            Assert.AreEqual(expectedCash, actualCash);
        }