MediaGetTest.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 MediaGetTest : MockPostApiBaseTest<MediaGetRequest, MediaGetResponse>
  12. {
  13. [Fact]
  14. public void MockMediaGetTest()
  15. {
  16. IsMock = true;
  17. MockSetup(false);
  18. var response = mock_client.Object.Execute(Request);
  19. Console.WriteLine(response);
  20. }
  21. [Fact]
  22. public void MockMediaGetErrorTest()
  23. {
  24. IsMock = true;
  25. MockSetup(true);
  26. var response = mock_client.Object.Execute(Request);
  27. Assert.Equal(true, response.IsError);
  28. Assert.Equal(40004, response.ErrorCode);
  29. }
  30. [Fact]
  31. public void ReallyMediaGetTest()
  32. {
  33. IsMock = false;
  34. var response = mock_client.Object.Execute(Request);
  35. Console.WriteLine(response);
  36. }
  37. protected override MediaGetRequest InitRequestObject()
  38. {
  39. return new MediaGetRequest
  40. {
  41. AccessToken = GetCurrentToken(),
  42. MediaId = "iofROOOriAPeiX6zeMG4rt2LKGWgav7kPKNZKxXqhc7l4BYCNx_JLWQyUfKqzR_i"
  43. };
  44. }
  45. protected override string GetReturnResult(bool errResult)
  46. {
  47. if (errResult)
  48. return "{\"errcode\":40004,\"errmsg\":\"invalid media type\"}";
  49. return "200";
  50. }
  51. }
  52. }