GroupsUpdateTest.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 GroupsUpdateTest : MockPostApiBaseTest<GroupsUpdateRequest, GroupsUpdateResponse>
  9. {
  10. [Fact]
  11. public void GroupsUpdateRequestJsonTest()
  12. {
  13. //Console.WriteLine(Request.GetPostContent());
  14. }
  15. [Fact]
  16. public void MockGroupsUpdateTest()
  17. {
  18. MockSetup(false);
  19. var response = mock_client.Object.Execute(Request);
  20. Assert.Equal(0, response.ErrorCode);
  21. Assert.Equal("ok", response.ErrorMessage);
  22. }
  23. [Fact]
  24. public void MockGroupsUpdateError()
  25. {
  26. MockSetup(true);
  27. var response = mock_client.Object.Execute(Request);
  28. Assert.Equal(40013, response.ErrorCode);
  29. }
  30. protected override GroupsUpdateRequest InitRequestObject()
  31. {
  32. return new GroupsUpdateRequest
  33. {
  34. AccessToken = "123",
  35. Group = new Group
  36. {
  37. Name = "testupdate",
  38. ID = 100
  39. }
  40. };
  41. }
  42. protected override string GetReturnResult(bool errResult)
  43. {
  44. if (errResult)
  45. return "{\"errcode\":40013,\"errmsg\":\"invalid appid\"}";
  46. return "{\"errcode\": 0, \"errmsg\": \"ok\"}";
  47. }
  48. }
  49. }