public ActionResult <IEnumerable <string> > SendInstructions(
     [FromBody]
     [Required]
     InstructionSetDto instructionSet)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState.Values));
     }
     if (!App.CheckLogin(instructionSet.Login))
     {
         return(Forbid());
     }
     return(Ok(App.SendInstructions(instructionSet.Instructions, instructionSet.Login.PlayerName)));
 }
Beispiel #2
0
        public void SendInstructionsTest()
        {
            var controller = new AilurusController();

            var instructionSet = new InstructionSetDto()
            {
                Login = new UserLoginDto()
                {
                    PlayerName = "panda",
                    Pass       = "******"
                },
                Instructions = new List <GlobalInstruction>()
                {
                    new GlobalInstruction {
                        TYPE        = "Collect",
                        DroneName   = "Drone_1",
                        Destination = null
                    },
                    new GlobalInstruction {
                        TYPE        = "MoveTo",
                        DroneName   = "Drone_2",
                        Destination = new CoordinateInt2D {
                            X = 10,
                            Y = 10
                        }
                    }
                }
            };

            ActionResult <IEnumerable <string> > expected = controller.Ok(new List <string>()
            {
                "Invalid Instruction: No mine near the drone for instruction: TYPE: Collect, DroneName: Drone_1, Destination: ",
                "OK, drone will do MoveTo"
            });

            controller.CreatePlayer(instructionSet.Login);
            var actual = controller.SendInstructions(instructionSet);

            actual.Should().BeEquivalentTo(expected);
        }