Esempio n. 1
0
        public void TestPutPieceSetsHasPieceToFalse()
        {
            //given
            var               strategy  = new Mock <IStrategy>();
            AgentInfo         agentInfo = new AgentInfo(strategy.Object, defaultGameStartedMessage);
            PutPieceResponse  putPiece  = new PutPieceResponse();
            PickPieceResponse pickPiece = new PickPieceResponse();
            //when
            Message pickUp = new Message <PickPieceResponse>(pickPiece);

            agentInfo.UpdateFromMessage(pickUp);
            Message checkUp = new Message <PutPieceResponse>(putPiece);

            agentInfo.UpdateFromMessage(checkUp);
            //then
            Assert.AreEqual(false, agentInfo.HasPiece);
        }
Esempio n. 2
0
        public void TestCheckHoldedPieceIfNotSham()
        {
            //given
            var       strategy  = new Mock <IStrategy>();
            AgentInfo agentInfo = new AgentInfo(strategy.Object, defaultGameStartedMessage);
            CheckHoldedPieceResponse checkHoldedPiece = new CheckHoldedPieceResponse()
            {
                Sham = false
            };
            PickPieceResponse pickPiece = new PickPieceResponse();
            //when
            Message pickUp = new Message <PickPieceResponse>(pickPiece);

            agentInfo.UpdateFromMessage(pickUp);
            Message checkUp = new Message <CheckHoldedPieceResponse>(checkHoldedPiece);

            agentInfo.UpdateFromMessage(checkUp);
            //then
            Assert.AreEqual(true, agentInfo.HasPiece);
        }
Esempio n. 3
0
 private void HandleReceived(Message received)
 {
     Log.Information("Received message with id {MessageId}", received.MessageId);
     if (received.MessageId == MessageType.GameEnded)
     {
         _gameOver = true;
         return;
     }
     _agentInfo.UpdateFromMessage(received);
     _penalizer.PenalizeOnReceive(received);
     if (received.MessageId.IsError() && received.MessageId != MessageType.PenaltyNotWaitedError)
     {
         _penalizer.ClearPenalty();
     }
 }
Esempio n. 4
0
        public void TestUpdateAgentPosition()
        {
            //given
            var          strategy     = new Mock <IStrategy>();
            AgentInfo    agentInfo    = new AgentInfo(strategy.Object, defaultGameStartedMessage);
            MoveResponse moveResponse = new MoveResponse()
            {
                CurrentPosition = new Position()
                {
                    X = 3, Y = 4
                }
            };
            //when
            Message message = new Message <MoveResponse>(moveResponse);

            agentInfo.UpdateFromMessage(message);
            //then
            Assert.AreEqual(moveResponse.CurrentPosition.X.Value, agentInfo.Position.X);
            Assert.AreEqual(moveResponse.CurrentPosition.Y.Value, agentInfo.Position.Y);
        }