Ejemplo n.º 1
0
        public void TestPlayerAsksNotExistingAgnet()
        {
            //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);
            var message = new Message <ExchangeInformationRequest>()
            {
                AgentId        = 1,
                MessagePayload = new ExchangeInformationRequest()
                {
                    AskedAgentId = 2
                }
            };
            var exchangeInformationHandler           = new ExchangeInformationRequestHandler();
            Message <NotDefinedError> expectedResult = new Message <NotDefinedError>()
            {
                AgentId        = 1,
                MessagePayload = new NotDefinedError()
                {
                    Position = new Position()
                    {
                        X = 5, Y = 5
                    },
                    HoldingPiece = false
                }
            };
            //when
            Message response = exchangeInformationHandler.ProcessRequest(map, message, config);

            //then
            response.Should().BeEquivalentTo(expectedResult);
        }
Ejemplo n.º 2
0
        public void TestPlayerAsksAnother()
        {
            //given
            var players = new List <(int x, int y, int id, Team team)>()
            {
                (x : 5, y : 5, 1, Team.Red), (x : 4, y : 5, 2, Team.Red)
            };
            var map     = new Map(players: players);
            var message = new Message <ExchangeInformationRequest>()
            {
                AgentId        = 1,
                MessagePayload = new ExchangeInformationRequest()
                {
                    AskedAgentId = 2
                }
            };
            var exchangeInformationHandler = new ExchangeInformationRequestHandler();
            Message <RedirectedExchangeInformationRequest> expectedResult = new Message <RedirectedExchangeInformationRequest>()
            {
                AgentId        = 2,
                MessagePayload = new RedirectedExchangeInformationRequest()
                {
                    AskingId = 1,
                    Leader   = false,
                    TeamId   = "red"
                }
            };
            //when
            Message response = exchangeInformationHandler.ProcessRequest(map, message, config);

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