Beispiel #1
0
        public void EndRoundShouldAddToLoggerAndCallBaseMethod()
        {
            var logger           = new MemoryLogger();
            var playerMock       = new Mock <IPlayer>();
            var playerWithLogger = new PlayerWithLoggerDecorator(playerMock.Object, logger);

            playerWithLogger.EndRound();
            Assert.IsTrue(logger.ToString().Length > 0);
            playerMock.Verify(x => x.EndRound(), Times.Once());
        }
Beispiel #2
0
        public void AddCardShouldAddToLoggerAndCallBaseMethod()
        {
            var logger           = new MemoryLogger();
            var playerMock       = new Mock <IPlayer>();
            var playerWithLogger = new PlayerWithLoggerDecorator(playerMock.Object, logger);

            playerWithLogger.AddCard(Card.GetCard(CardSuit.Club, CardType.Ace));

            Assert.IsTrue(logger.ToString().Length > 0);
            playerMock.Verify(x => x.AddCard(It.IsAny <Card>()), Times.Once());
        }
Beispiel #3
0
        public void StartGameShouldAddToLoggerAndCallBaseMethod()
        {
            const string OtherPlayerIdentifier = "тест";
            var          logger           = new MemoryLogger();
            var          playerMock       = new Mock <IPlayer>();
            var          playerWithLogger = new PlayerWithLoggerDecorator(playerMock.Object, logger);

            playerWithLogger.StartGame(OtherPlayerIdentifier);

            Assert.IsTrue(logger.ToString().Length > 0);
            Assert.IsTrue(logger.ToString().Contains(OtherPlayerIdentifier));
            playerMock.Verify(x => x.StartGame(It.IsAny <string>()), Times.Once());
        }
Beispiel #4
0
        public void NameShouldReturnBaseName()
        {
            const string PlayerName = "тест";

            var logger     = new MemoryLogger();
            var playerMock = new Mock <IPlayer>();

            playerMock.SetupGet(x => x.Name).Returns(PlayerName);

            var playerWithLogger = new PlayerWithLoggerDecorator(playerMock.Object, logger);

            Assert.AreEqual(PlayerName, playerWithLogger.Name);
        }
Beispiel #5
0
        public void EndTurnShouldAddToLoggerAndCallBaseMethod()
        {
            var logger           = new MemoryLogger();
            var playerMock       = new Mock <IPlayer>();
            var playerWithLogger = new PlayerWithLoggerDecorator(playerMock.Object, logger);

            playerWithLogger.EndTurn(
                new PlayerTurnContext(
                    new StartRoundState(new StateManager()),
                    Card.GetCard(CardSuit.Club, CardType.Ace),
                    0,
                    0,
                    0));

            Assert.IsTrue(logger.ToString().Length > 0);
            playerMock.Verify(x => x.EndTurn(It.IsAny <PlayerTurnContext>()), Times.Once());
        }
Beispiel #6
0
        public void StartRoundShouldAddToLoggerAndCallBaseMethod()
        {
            var logger           = new MemoryLogger();
            var playerMock       = new Mock <IPlayer>();
            var playerWithLogger = new PlayerWithLoggerDecorator(playerMock.Object, logger);

            var card  = Card.GetCard(CardSuit.Diamond, CardType.King);
            var cards = new List <Card> {
                card
            };
            var trumpCard = Card.GetCard(CardSuit.Club, CardType.Ace);

            playerWithLogger.StartRound(cards, trumpCard, 1, 4);

            Assert.IsTrue(logger.ToString().Length > 0);
            Assert.IsTrue(logger.ToString().Contains(card.ToString()));
            Assert.IsTrue(logger.ToString().Contains(trumpCard.ToString()));
            playerMock.Verify(x => x.StartRound(cards, trumpCard, 1, 4), Times.Once());
        }