RobotCase_FirstCase.cs 1006 B

1234567891011121314151617181920212223242526
  1. using System;
  2. namespace ET
  3. {
  4. [RobotCase(RobotCaseType.FirstCase)]
  5. public class RobotCase_FirstCase: IRobotCase
  6. {
  7. public async ETTask Run(RobotCase robotCase)
  8. {
  9. using ListComponent<Scene> robots = ListComponent<Scene>.Create();
  10. // 创建了两个机器人,生命周期是RobotCase,RobotCase_FirstCase.Run执行结束,机器人就会删除
  11. await robotCase.NewRobot(2, robots);
  12. foreach (Scene robotScene in robots)
  13. {
  14. M2C_TestRobotCase response = await robotScene.GetComponent<SessionComponent>().Session.Call(new C2M_TestRobotCase() {N = robotScene.Zone}) as M2C_TestRobotCase;
  15. if (response.N != robotScene.Zone)
  16. {
  17. // 跟预期不一致就抛异常,外层会catch住在控制台上打印
  18. throw new Exception($"robot case: {RobotCaseType.FirstCase} run fail!");
  19. }
  20. }
  21. }
  22. }
  23. }