Exemplo n.º 1
0
        public void GivenExistingMatch_WhenPreviousGameWonAndNoDynamitesAvailableInTheGame_ThenBotsMoveShouldBeOfOneThatBeatsItsPreviousHandWithNoDynamitAndNoWaterbomb()
        {
            // Assemble
            var           botStrategy = new BotStrategy();
            IMatchService service     = new MatchService(botStrategy);

            service.NewMatch(3, 0);

            //Act

            //first game
            service.AddGame();
            var botsFirstMove = service.BotsMove();

            service.GameResult(Outcome.Win, Move.Paper);

            //second game
            service.AddGame();
            var         botsSecondMove = service.BotsMove();
            MoveHelpers mh             = new MoveHelpers();
            var         beaters        = mh.GetBeaters(botsFirstMove).ToList();

            //Assert
            Assert.AreNotEqual(Move.Dynamite, botsSecondMove);
            Assert.AreNotEqual(Move.Waterbomb, botsSecondMove);
            Assert.Contains(botsSecondMove, beaters);
        }
Exemplo n.º 2
0
        public void GivenExistingMatch_WhenDynamiteAvailableInTheGameAndAlreadyUsedByBot_ThenBotsMoveShouldBeOfOneThatBeatsPlayersPreviousHand()
        {
            // Assemble
            var botStrategy = new BotStrategy();

            var strategyMock = new Mock <IBotStrategy>();

            var sequence = strategyMock.SetupSequence(m => m.GetBotsNextMove(It.IsAny <Game>(), It.IsAny <bool>(), It.IsAny <bool>()));


            IMatchService service = new MatchService(strategyMock.Object);


            service.NewMatch(3, 1);

            Move playersMove = Move.Waterbomb;

            //Act

            //first game
            sequence.Returns(Move.Dynamite);
            service.AddGame();
            var botsFirstMove = service.BotsMove();
            var gameResult    = service.GameResult(Outcome.Lose, playersMove);

            //second game
            sequence.Returns(botStrategy.GetBotsNextMove(gameResult, false, true));
            service.AddGame();
            var         botsSecondMove = service.BotsMove();
            MoveHelpers mh             = new MoveHelpers();
            var         beaters        = mh.GetBeaters(playersMove).ToList();

            //Assert
            Assert.Contains(botsSecondMove, beaters);
        }
Exemplo n.º 3
0
        public void GivenNewMatch_WhenFirstGameAndDynamitesAvailableInTheGame_ThenBotsMoveShouldBeMadeAccordingly()
        {
            // Assemble
            var           botStrategy = new BotStrategy();
            IMatchService service     = new MatchService(botStrategy);

            service.NewMatch(3, 0);

            //Act
            service.AddGame();
            var botsDecision = service.BotsMove();

            //Assert
            Assert.That(Enum.IsDefined(typeof(Move), botsDecision));
            Assert.Contains(botsDecision, Enum.GetValues(typeof(Move)).Cast <Move>().ToList());
        }
Exemplo n.º 4
0
        public void GivenNewMatch_WhenFirstGameAndNoDynamitesAvailableInTheGame_ThenBotsMoveShouldBeMadeWithNoDynamiteAndNoWaterbomb()
        {
            // Assemble
            var           botStrategy = new BotStrategy();
            IMatchService service     = new MatchService(botStrategy);

            service.NewMatch(3, 0);

            //Act
            service.AddGame();
            var botsDecision = service.BotsMove();

            //Assert
            Assert.AreNotEqual(Move.Dynamite, botsDecision);
            Assert.AreNotEqual(Move.Waterbomb, botsDecision);
        }