ClientTestManager.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using JsonRpcLite.Network;
  2. using JsonRpcLite.Rpc;
  3. using System;
  4. using System.Net;
  5. using WingInterfaceLibrary.Enum;
  6. using WingInterfaceLibrary.Interface;
  7. using WingInterfaceLibrary.Request.User;
  8. namespace Flyinsono.Client.Test
  9. {
  10. internal interface IClientTestManager : IClientManager
  11. {
  12. /// <summary>
  13. /// Run the test cases
  14. /// </summary>
  15. void Run(string remoteUrl);
  16. }
  17. internal class ClientTestManager : IClientTestManager
  18. {
  19. public async void Run(string remoteUrl)
  20. {
  21. try {
  22. var clientEngine = new JsonRpcHttpClientEngine(remoteUrl);
  23. var client = new JsonRpcClient();
  24. client.UseEngine(clientEngine);
  25. var proxy = client.CreateProxy<ILoginService>();
  26. var request = new CommonLoginRequest();
  27. request.LoginSource = LoginSource.PC;
  28. request.AnyAccount = "fly11";
  29. request.Password = "7a9da7f9ffc92a1d9e3b9d87137eb3c1";
  30. var result = await proxy.CommonLoginAsync(request);
  31. Logger.WriteLineInfo($"result:{result.AccountName}- {result.LoginState} - {result.Token}");
  32. }
  33. catch(Exception ex)
  34. {
  35. Logger.WriteLineError($"Test run ex:{ex}");
  36. }
  37. }
  38. public void Dispose()
  39. {
  40. //throw new System.NotImplementedException();
  41. }
  42. }
  43. }