public virtual async Task <GetPcLoginACodeOutput> GetPcLoginACodeAsync(string miniProgramName) { var miniProgram = await _miniProgramRepository.GetAsync(x => x.Name == miniProgramName); var options = new AbpWeChatMiniProgramOptions { OpenAppId = miniProgram.OpenAppIdOrName, AppId = miniProgram.AppId, AppSecret = miniProgram.AppSecret, EncodingAesKey = miniProgram.EncodingAesKey, Token = miniProgram.Token }; using (_weChatMiniProgramAsyncLocal.Change(options)) { var token = Guid.NewGuid().ToString("N"); var handlePage = await SettingProvider.GetOrNullAsync(MiniProgramsSettings.PcLogin.HandlePage); var aCodeResponse = await _aCodeService.GetUnlimitedACodeAsync(token, handlePage); if (aCodeResponse.ErrorCode != 0) { throw new WeChatBusinessException(aCodeResponse.ErrorCode, aCodeResponse.ErrorMessage); } return(new GetPcLoginACodeOutput { Token = token, ACode = aCodeResponse.BinaryData }); } }
public async Task Should_Get_Unlimited_ACode() { var result = await _aCodeService.GetUnlimitedACodeAsync("test"); result.ShouldNotBeNull(); result.ErrorMessage.ShouldBeNull(); result.ErrorCode.ShouldBe(0); result.BinaryData.ShouldNotBeEmpty(); }