Exemple #1
0
        public void ProcessMessage_ExchangeInformationResponse_OnlyAgentIdShouldBeChanged()
        {
            var agent = new Agent(666, TeamId.Blue, new Point(3, 3), true);

            agent.InformationExchangeRequested(333, false);

            gameMaster.Agents.Add(agent);

            var payload = new ExchangeInformationResponse(
                333,
                new int[, ] {
                { 1, 2 }, { 3, 4 }
            },
                new GoalInformation[, ] {
                { GoalInformation.Goal, GoalInformation.NoGoal }, { GoalInformation.NoInformation, GoalInformation.NoInformation }
            },
                new GoalInformation[, ] {
                { GoalInformation.Goal, GoalInformation.NoGoal }, { GoalInformation.NoInformation, GoalInformation.NoInformation }
            });

            var message = GetBaseMessage(payload, 666);

            dynamic response = gameLogicComponent.ProcessMessage(message);

            Assert.AreEqual(333, response.AgentId);
            Assert.IsTrue(response.Payload is ExchangeInformationResponseForward);

            var responsePayload = response.Payload as ExchangeInformationResponseForward;

            Assert.AreEqual(agent.Id, responsePayload.RespondingId);
            Assert.AreEqual(payload.Distances, responsePayload.Distances);
            Assert.AreEqual(payload.BlueTeamGoalAreaInformation, responsePayload.BlueTeamGoalAreaInformation);
            Assert.AreEqual(payload.RedTeamGoalAreaInformation, responsePayload.RedTeamGoalAreaInformation);
            Assert.AreEqual(configuration.InformationExchangePenalty.TotalSeconds, agent.Timeout);
        }
Exemple #2
0
 protected override void ReadMessage(MessagePayload payload)
 {
     _requester = (int)((ExchangeInformationResponse)payload).RespondToID;
     _message   = (ExchangeInformationResponse)payload;
 }