ClientTest.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using NUnit.Framework;
  3. using Alipay.EasySDK.Factory;
  4. using Alipay.EasySDK.Member.Identification.Models;
  5. using Alipay.EasySDK.Kernel.Util;
  6. namespace UnitTest.Member.Identification
  7. {
  8. public class ClientTest
  9. {
  10. [SetUp]
  11. public void SetUp()
  12. {
  13. Factory.SetOptions(TestAccount.Mini.CONFIG);
  14. }
  15. [Test]
  16. public void TestInit()
  17. {
  18. IdentityParam identityParam = new IdentityParam()
  19. {
  20. IdentityType = "CERT_INFO",
  21. CertType = "IDENTITY_CARD",
  22. CertName = "张三",
  23. CertNo = "513901198008089876"
  24. };
  25. MerchantConfig merchantConfig = new MerchantConfig()
  26. {
  27. ReturnUrl = "www.taobao.com"
  28. };
  29. AlipayUserCertifyOpenInitializeResponse response = Factory.Member.Identification().Init(
  30. Guid.NewGuid().ToString(), "FACE", identityParam, merchantConfig);
  31. Assert.IsTrue(ResponseChecker.Success(response));
  32. Assert.AreEqual(response.Code, "10000");
  33. Assert.AreEqual(response.Msg, "Success");
  34. Assert.IsNull(response.SubCode);
  35. Assert.IsNull(response.SubMsg);
  36. Assert.NotNull(response.HttpBody);
  37. Assert.NotNull(response.CertifyId);
  38. }
  39. [Test]
  40. public void TestCertify()
  41. {
  42. AlipayUserCertifyOpenCertifyResponse response = Factory.Member.Identification().Certify("bbdb57e87211279e2c22de5846d85161");
  43. Assert.IsTrue(ResponseChecker.Success(response));
  44. Assert.IsTrue(response.Body.Contains("https://openapi.alipay.com/gateway.do?alipay_sdk=alipay-easysdk-net"));
  45. Assert.IsTrue(response.Body.Contains("sign"));
  46. }
  47. [Test]
  48. public void TestQuery()
  49. {
  50. AlipayUserCertifyOpenQueryResponse response = Factory.Member.Identification().Query("89ad1f1b8171d9741c3e5620fd77f9de");
  51. Assert.IsFalse(ResponseChecker.Success(response));
  52. Assert.AreEqual(response.Code, "40004");
  53. Assert.AreEqual(response.Msg, "Business Failed");
  54. Assert.AreEqual(response.SubCode, "CERTIFY_ID_EXPIRED");
  55. Assert.AreEqual(response.SubMsg, "认证已失效");
  56. Assert.NotNull(response.HttpBody);
  57. Assert.IsNull(response.Passed);
  58. Assert.IsNull(response.IdentityInfo);
  59. Assert.IsNull(response.MaterialInfo);
  60. }
  61. }
  62. }