AccessTokenCodeTests.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using FrameworkCoreTest;
  2. using JCSoft.WX.Framework.Models.ApiRequests;
  3. using JCSoft.WX.Framework.Models.ApiResponses;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Text;
  7. using Xunit;
  8. namespace JCSoft.WX.FrameworkTest.Api
  9. {
  10. public class AccessTokenCodeTests : MockPostApiBaseTest<AccessTokenCodeRequest, AccessTokenCodeResponse>
  11. {
  12. [Fact]
  13. public void SuccessTests()
  14. {
  15. MockSetup(false);
  16. var response = mock_client.Object.Execute(Request);
  17. Assert.Equal(response.IsError, false);
  18. Assert.Equal(response.OpenId, "OPENID");
  19. }
  20. protected override string GetReturnResult(bool errResult)
  21. {
  22. if (errResult)
  23. {
  24. return @"{""errcode"":40029,""errmsg"":""invalid code""}";
  25. }
  26. else
  27. {
  28. return @"{""access_token"":""ACCESS_TOKEN"",
  29. ""expires_in"":7200,
  30. ""refresh_token"":""REFRESH_TOKEN"",
  31. ""openid"":""OPENID"",
  32. ""scope"":""SCOPE"" }";
  33. }
  34. }
  35. protected override AccessTokenCodeRequest InitRequestObject()
  36. {
  37. return new AccessTokenCodeRequest
  38. {
  39. AppId = "123",
  40. AppSecret = "123123",
  41. Code = "123123123"
  42. };
  43. }
  44. }
  45. }