public void ApiInvokingCouldReachLimitation() { var service = new WeChatService(); wechat = new WeChatWithApiLimitation(1); service.Setup(wechat, TimeSpan.FromSeconds(0)); service.GetAccessToken("dummy_appid", "dummy_secret"); service.GetAccessToken("dummy_appid", "dummy_secret"); }
public void GetAccessTest() { var service = new WeChatService(); service.Setup(wechat, TimeSpan.FromSeconds(0)); var accessToken = service.GetAccessToken(testAppId, testAppSecret); Assert.AreEqual(accessToken, testAccessToken); }
public void GetWeChatServiceWithProvider() { var service = new WeChatService(); wechat = new WeChatWithApiLimitation(2); service.Setup(wechat, TimeSpan.FromSeconds(0)); var accessToken = service.GetAccessToken("dummy_appid", "dummy_secret"); Assert.IsTrue(accessToken.StartsWith("access_token_for_dummy_appid")); Assert.AreNotSame(accessToken.StartsWith("access_token_for_dummy_appid"), accessToken); var jsTicket = service.GetTicket("my_access_token"); Assert.IsTrue(jsTicket.StartsWith("jsticket_my_access_token")); Assert.AreNotSame(service.GetTicket("my_access_token"), jsTicket); }
public void ApiInvokingLimitationIsSeperatedOverAppIdsAndAccessTokens() { var service = new WeChatService(); wechat = new WeChatWithApiLimitation(1); service.Setup(wechat, TimeSpan.FromSeconds(0)); service.GetAccessToken("dummy_appid", "dummy_secret"); service.GetAccessToken("another_dummy_appid", "dummy_secret"); service.GetTicket("my_access_token"); service.GetTicket("another_my_access_token"); }
public void GetAccessTestByEmptyAppSecret() { var service = new WeChatService(); service.GetAccessToken(testAppId, string.Empty); }
public void CacheInWeChatServiceCouldExpire() { var service = new WeChatService(); wechat = new WeChatWithApiLimitation(1); service.Setup(wechat, TimeSpan.FromSeconds(1)); service.GetAccessToken("dummy_appid", "dummy_secret"); Thread.Sleep(2000); service.GetAccessToken("dummy_appid", "dummy_secret"); }
public void WeChatServiceCanCache() { var service = new WeChatService(); wechat = new WeChatWithApiLimitation(1); service.Setup(wechat, TimeSpan.FromSeconds(1)); var accessToken1 = service.GetAccessToken("dummy_appid", "dummy_secret"); var accessToken2 = service.GetAccessToken("dummy_appid", "dummy_secret"); Assert.AreEqual(accessToken1, accessToken2); }