ClientTest.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using NUnit.Framework;
  2. using Alipay.EasySDK.Factory;
  3. using Alipay.EasySDK.Base.OAuth.Models;
  4. using Alipay.EasySDK.Kernel.Util;
  5. namespace UnitTest.Base.OAuth
  6. {
  7. public class ClientTest
  8. {
  9. [SetUp]
  10. public void SetUp()
  11. {
  12. Factory.SetOptions(TestAccount.Mini.CONFIG);
  13. }
  14. [Test]
  15. public void TestGetToken()
  16. {
  17. AlipaySystemOauthTokenResponse response = Factory.Base.OAuth().GetToken("1234567890");
  18. Assert.IsFalse(ResponseChecker.Success(response));
  19. Assert.AreEqual(response.Code, "40002");
  20. Assert.AreEqual(response.Msg, "Invalid Arguments");
  21. Assert.AreEqual(response.SubCode, "isv.code-invalid");
  22. Assert.AreEqual(response.SubMsg, "授权码code无效");
  23. Assert.NotNull(response.HttpBody);
  24. }
  25. [Test]
  26. public void TestRefreshToken()
  27. {
  28. AlipaySystemOauthTokenResponse response = Factory.Base.OAuth().RefreshToken("1234567890");
  29. Assert.IsFalse(ResponseChecker.Success(response));
  30. Assert.AreEqual(response.Code, "40002");
  31. Assert.AreEqual(response.Msg, "Invalid Arguments");
  32. Assert.AreEqual(response.SubCode, "isv.refresh-token-invalid");
  33. Assert.AreEqual(response.SubMsg, "刷新令牌refresh_token无效");
  34. Assert.NotNull(response.HttpBody);
  35. }
  36. }
  37. }