You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Xml.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
namespace Senparc.Weixin.Open.Test.CommonApi
{
[TestClass]
public class CommonApi
{
private dynamic _appConfig;
protected dynamic AppConfig
{
get
{
if (_appConfig == null)
{
if (File.Exists("../../test.config"))
{
var doc = XDocument.Load("../../test.config");
_appConfig = new
{
AppId = doc.Root.Element("AppId").Value,
Secret = doc.Root.Element("Secret").Value,
Ticket = doc.Root.Element("Ticket").Value
};
}
else
{
_appConfig = new
{
AppId = "YourAppId", //换成你的信息
Secret = "YourSecret",//换成你的信息
Ticket = "YourTicket"//换成你的信息
};
}
}
return _appConfig;
}
}
protected string _appId
{
get { return AppConfig.AppId; }
}
protected string _appSecret
{
get { return AppConfig.Secret; }
}
protected string _ticket
{
get { return AppConfig.Ticket; }
}
[TestMethod]
public void GetComponentAccessTokenTest()
{
var component_access_tokenResult = Open.ComponentAPIs.ComponentApi.GetComponentAccessToken(_appId, _appSecret, _ticket);
//运行此测试务必将本地IP加入到白名单否则可能发生错误错误代码61004说明access clientip is not registered tips: requestIP: 49.73.28.245
Assert.IsNotNull(component_access_tokenResult);
}
}
}