GroupsGetIdTest.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using JCSoft.WX.Framework.Models.ApiRequests;
  7. using JCSoft.WX.Framework.Models.ApiResponses;
  8. using Xunit;
  9. namespace FrameworkCoreTest
  10. {
  11. public class GroupsGetIdTest : MockPostApiBaseTest<GroupsGetIdRequest, GroupsGetIdResponse>
  12. {
  13. private static string m_openId = "oI1_vjirqEuoDttmL-eRcsO-G9to";
  14. [Fact]
  15. public void MockGroupsGetIdTest()
  16. {
  17. MockSetup(false);
  18. Console.WriteLine(mock_client.Object.Execute(Request));
  19. }
  20. [Fact]
  21. public void MockGroupsGetIdErrorTest()
  22. {
  23. MockSetup(true);
  24. Console.WriteLine(mock_client.Object.Execute(Request));
  25. }
  26. protected override string GetReturnResult(bool errResult)
  27. {
  28. if (errResult)
  29. {
  30. return "{\"errcode\":40003,\"errmsg\":\"invalid openid\"}";
  31. }
  32. else
  33. {
  34. return @"{
  35. ""groupid"": 102
  36. }";
  37. }
  38. }
  39. protected override GroupsGetIdRequest InitRequestObject()
  40. {
  41. return new GroupsGetIdRequest
  42. {
  43. AccessToken = "123",
  44. OpenId = m_openId
  45. };
  46. }
  47. }
  48. }