Ejemplo n.º 1
0
        public void TestRealPieceOnTaskField()
        {
            //given
            var players = new List <(int x, int y, int id, Team team)>()
            {
                (x : 5, y : 5, 1, Team.Red)
            };
            var map = new Map(players: players);

            map.GetPlayerById(1).Holding = new Piece();
            var message = new Message <PutPieceRequest>()
            {
                AgentId        = 1,
                MessagePayload = new PutPieceRequest()
                {
                }
            };
            var moveHandler = new PutPieceRequestHandler();
            Message <PutPieceResponse> expectedResult = new Message <PutPieceResponse>()
            {
                AgentId        = 1,
                MessagePayload = new PutPieceResponse()
                {
                    PutResult = PutResultEnum.TaskField
                }
            };
            //when
            Message response = moveHandler.ProcessRequest(map, message, config);

            //then
            response.Should().BeEquivalentTo(expectedResult);
        }
Ejemplo n.º 2
0
        public void TestPlayerHaveNoPiece()
        {
            //given
            var players = new List <(int x, int y, int id, Team team)>()
            {
                (x : 5, y : 5, id : 1, team : Team.Red)
            };
            var map = new Map(players: players);

            map.GetPlayerById(1).Holding = null;
            var message = new Message <PutPieceRequest>()
            {
                AgentId        = 1,
                MessagePayload = new PutPieceRequest()
                {
                }
            };
            var moveHandler = new PutPieceRequestHandler();
            Message <PutPieceError> expectedResult = new Message <PutPieceError>()
            {
                AgentId        = 1,
                MessagePayload = new PutPieceError()
                {
                    ErrorSubtype = "AgentNotHolding"
                }
            };
            //when
            Message response = moveHandler.ProcessRequest(map, message, config);

            //then
            response.Should().BeEquivalentTo(expectedResult);
        }