Beispiel #1
0
        public void Should_have_correct_player_step(bool coinTossIsHeads)
        {
            var coinTossService = new Mock <ICoinTossService>();

            coinTossService
            .Setup(x => x.IsHeads())
            .Returns(coinTossIsHeads);

            var subject = new CoinTossHandler(coinTossService.Object);
            var data    = subject.Run(CreateStep());

            data.HostTurn.Should().Be(coinTossIsHeads);
        }
Beispiel #2
0
        public void Should_have_correct_log_entry(bool coinTossIsHeads, string logEntry)
        {
            var coinTossService = new Mock <ICoinTossService>();

            coinTossService
            .Setup(x => x.IsHeads())
            .Returns(coinTossIsHeads);

            var subject = new CoinTossHandler(coinTossService.Object);
            var data    = subject.Run(CreateStep());

            data.Log.Last().Should().Be(logEntry);
        }
Beispiel #3
0
        public void Should_throw_CoinTossAlreadyHappenedException(bool hostWon)
        {
            var gameData = new GameData
            {
                HostWonCoinToss = hostWon
            };

            var coinTossService = new Mock <ICoinTossService>();
            var subject         = new CoinTossHandler(coinTossService.Object);

            Action act = () => subject.ValidateAndThrow(CreateStep(gameData));

            act.Should()
            .Throw <CoinTossAlreadyHappenedException>()
            .Where(x => x.GameData == gameData &&
                   x.HostWonCoinToss == hostWon);
        }
Beispiel #4
0
        public void Should_throw_PlayerStillSelectingCardsException(
            IEnumerable <Card> hostCards,
            IEnumerable <Card> challengerCards,
            bool hostStillSelecting,
            bool challengerStillSelecting)
        {
            var gameData = new GameData
            {
                HostCards       = hostCards,
                ChallengerCards = challengerCards
            };

            var coinTossService = new Mock <ICoinTossService>();
            var subject         = new CoinTossHandler(coinTossService.Object);

            Action act = () => subject.ValidateAndThrow(CreateStep(gameData));

            act.Should()
            .Throw <PlayerStillSelectingCardsException>()
            .Where(x => x.GameData == gameData &&
                   x.Host == hostStillSelecting &&
                   x.Challenger == challengerStillSelecting);
        }