示例#1
0
        public void PlayingTiesShouldReturnTieAndUpdateScore(string move)
        {
            // 1. arrange - setup objects
            var game             = new RPSgame();
            var score            = new Score();
            int initialLossCount = score.lossCount;
            int initialWinCount  = score.winCount;
            int initialTieCount  = score.tieCount;

            // 2. act - behavior we are testing
            string result = game.Play(move, move, score);

            // 3. assert - check results
            Assert.Equal(expected: "tie", actual: result);
            Assert.Equal(0, score.lossCount - initialLossCount);
            Assert.Equal(0, score.winCount - initialWinCount);
            Assert.Equal(1, score.tieCount - initialTieCount);
        }
示例#2
0
        public void PlayingTiesShouldReturnTieAndUpdateScore(string move)
        {
            // structuring a good unit test

            // 1. arrange
            var game             = new RPSgame();
            var score            = new Score();
            int initialLossCount = score.lossCount;
            int initialWinCount  = score.winCount;
            int initialTieCount  = score.tieCount;

            // 2. act
            string result = game.Play(move, move, score);

            // 3. assert
            Assert.Equal("tie", result);
            Assert.Equal(0, score.lossCount - initialLossCount);
            Assert.Equal(0, score.winCount - initialWinCount);
            Assert.Equal(1, score.tieCount - initialTieCount);
        }
示例#3
0
        public void PlayingTiesShouldReturnTieAndUpdateScore(string move)
        {
            // 1. arrange
            // and setup necessary to arrange the objects for "act"
            var game             = new RPSgame();
            var score            = new Score();
            int initialLossCount = score.lossCount;
            int initialWinCount  = score.winCount;
            int initialTieCount  = score.tieCount;

            // 2. act
            // the specific behavior we are testing
            string result = game.Play(move, move, score);

            // 3. assert
            // verify that everything went correctly with the "act"
            // (assume that the "arrange" part went fine.
            Assert.Equal("tie", result);
            Assert.Equal(initialLossCount, score.lossCount);
            Assert.Equal(initialWinCount, score.winCount);
            Assert.Equal(initialWinCount + 1, score.tieCount);
        }