Exemplo n.º 1
0
        // 创建机器人,生命周期是RobotCase
        public static async ETTask NewRobot(this RobotCase self, int count, List <Scene> scenes)
        {
            ETTask[] tasks = new ETTask[count];
            for (int i = 0; i < count; ++i)
            {
                tasks[i] = self.NewRobot(scenes);
            }

            await ETTaskHelper.WaitAll(tasks);
        }
Exemplo n.º 2
0
 // 这个方法创建的是进程所属的机器人,建议使用RobotCase.NewRobot来创建
 private static async ETTask NewZoneRobot(this RobotCase self, int zone, List <Scene> scenes)
 {
     try
     {
         scenes.Add(await self.NewRobot(zone));
     }
     catch (Exception e)
     {
         Log.Error(e);
     }
 }
Exemplo n.º 3
0
        public async ETTask Run(RobotCase robotCase)
        {
            using ListComponent <Scene> robots = ListComponent <Scene> .Create();

            // 创建了两个机器人,生命周期是RobotCase,RobotCase_FirstCase.Run执行结束,机器人就会删除
            await robotCase.NewRobot(2, robots.List);

            foreach (Scene robotScene in robots.List)
            {
                M2C_TestRobotCase response = await robotScene.GetComponent <SessionComponent>().Session.Call(new C2M_TestRobotCase()
                {
                    N = robotScene.Zone
                }) as M2C_TestRobotCase;

                if (response.N != robotScene.Zone)
                {
                    // 跟预期不一致就抛异常,外层会catch住在控制台上打印
                    throw new Exception($"robot case: {RobotCaseType.FirstCase} run fail!");
                }
            }
        }
Exemplo n.º 4
0
 public static async ETTask <Scene> NewRobot(this RobotCase self, int zone)
 {
     return(await self.NewRobot(zone, $"Robot_{zone}"));
 }