GroupCreateTest.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using JCSoft.WX.Framework.Models.ApiRequests;
  3. using JCSoft.WX.Framework.Models.ApiResponses;
  4. using Xunit;
  5. using JCSoft.WX.Framework.Models;
  6. namespace FrameworkCoreTest
  7. {
  8. public class GroupCreateTest : MockPostApiBaseTest<GroupsCreateRequest, GroupCreateResponse>
  9. {
  10. [Fact]
  11. public void MockGroupCreateTest()
  12. {
  13. MockSetup(false);
  14. var response = mock_client.Object.Execute(Request);
  15. Console.WriteLine(response);
  16. }
  17. [Fact]
  18. public void MockGroupCreateErrorTest()
  19. {
  20. MockSetup(true);
  21. var response = mock_client.Object.Execute(Request);
  22. Console.WriteLine(response);
  23. }
  24. protected override string GetReturnResult(bool errResult)
  25. {
  26. if (!errResult)
  27. {
  28. return @"{
  29. ""group"":
  30. {
  31. ""id"": 0,
  32. ""name"": ""未分组"",
  33. ""count"": 72596
  34. }
  35. }";
  36. }
  37. else
  38. {
  39. return "{\"errcode\":40013,\"errmsg\":\"invalid appid\"}";
  40. }
  41. }
  42. protected override GroupsCreateRequest InitRequestObject()
  43. {
  44. return new GroupsCreateRequest
  45. {
  46. AccessToken = "123",
  47. Group = new Group
  48. {
  49. Name = "test"
  50. }
  51. };
  52. }
  53. }
  54. }