public IHTTPClient getHTTPClient(IUtil util) { if (null == client) { client = new HTTPClient (util); } return client; }
public AnalyticsReporter(Biller biller, UnibillConfiguration config, IHTTPClient client, IStorage storage, IUtil util, ILevelLoadListener listener) { this.config = config; this.client = client; this.util = util; this.userId = getUserId (storage); biller.onPurchaseComplete += onSucceeded; biller.onPurchaseCancelled += (PurchasableItem obj) => onEvent(EventType.purchase_cancelled, obj, null); biller.onPurchaseRefunded += (PurchasableItem obj) => onEvent(EventType.purchase_refunded, obj, null); biller.onTransactionRestoreBegin += (bool obj) => restoreInProgress = true; biller.onTransactionsRestored += (bool obj) => restoreInProgress = false; listener.registerListener (() => onLevelLoad ()); onEvent (EventType.new_session, null, null); this.levelName = util.loadedLevelName (); this.levelLoadTime = DateTime.UtcNow; }
public void Setup() { currentTime = 1; lastTimeSyncTime = 1; newSessions = new List <SessionWrapper>(); openSessions = new List <SessionWrapper>(); finishedSessions = new List <SessionWrapper>(); // http client httpClient = Substitute.For <IHTTPClient>(); // provider timingProvider = Substitute.For <ITimingProvider>(); timingProvider.ProvideTimestampInMilliseconds().Returns(x => { return(++currentTime); }); // every access is a tick httpClientProvider = Substitute.For <IHTTPClientProvider>(); httpClientProvider.CreateClient(Arg.Any <HTTPClientConfiguration>()).Returns(x => httpClient); // context context = Substitute.For <IBeaconSendingContext>(); context.HTTPClientProvider.Returns(x => httpClientProvider); context.GetHTTPClient().Returns(x => httpClient); context.LastTimeSyncTime.Returns(x => currentTime); // always return the current time to prevent re-sync context.IsCaptureOn.Returns(true); // beacon sender var logger = Substitute.For <ILogger>(); beaconSender = new BeaconSender(logger, config, httpClientProvider, timingProvider); // return true by default context.IsTimeSyncSupported.Returns(true); // current time getter context.CurrentTimestamp.Returns(x => timingProvider.ProvideTimestampInMilliseconds()); // last time sycn getter + setter context.LastTimeSyncTime = Arg.Do <long>(x => lastTimeSyncTime = x); context.LastTimeSyncTime = lastTimeSyncTime; // sessions context.NewSessions.Returns(newSessions); context.OpenAndConfiguredSessions.Returns(openSessions); context.FinishedAndConfiguredSessions.Returns(finishedSessions); }
public void Setup() { currentTime = 0; lastTimeSyncTime = -1; httpClient = Substitute.For <IHTTPClient>(); context = Substitute.For <IBeaconSendingContext>(); context.GetHTTPClient().Returns(httpClient); // return true by default context.IsTimeSyncSupported.Returns(true); // current time getter context.CurrentTimestamp.Returns(x => { return(++currentTime); }); // last time sycn getter + setter context.LastTimeSyncTime = Arg.Do <long>(x => lastTimeSyncTime = x); context.LastTimeSyncTime = lastTimeSyncTime; // init with -1 }
public void Setup() { currentTime = 0; lastStatusCheckTime = -1; logger = Substitute.For <ILogger>(); httpClient = Substitute.For <IHTTPClient>(); context = Substitute.For <IBeaconSendingContext>(); context.GetHTTPClient().Returns(httpClient); // default return success httpClient.SendStatusRequest().Returns(new StatusResponse(logger, string.Empty, 200, new Dictionary <string, List <string> >())); // current time getter context.CurrentTimestamp.Returns(x => { return(++currentTime); }); // last time sycn getter + setter context.LastStatusCheckTime = Arg.Do <long>(x => lastStatusCheckTime = x); context.LastStatusCheckTime = lastStatusCheckTime; // init with -1 }
/// <summary> /// This config spefies the internal parts of the SpotifyClient. /// </summary> /// <param name="baseAddress"></param> /// <param name="authenticator"></param> /// <param name="jsonSerializer"></param> /// <param name="httpClient"></param> /// <param name="retryHandler"></param> /// <param name="httpLogger"></param> /// <param name="defaultPaginator"></param> /// <param name="apiConnector"></param> public SpotifyClientConfig( Uri baseAddress, IAuthenticator?authenticator, IJSONSerializer jsonSerializer, IHTTPClient httpClient, IRetryHandler?retryHandler, IHTTPLogger?httpLogger, IPaginator defaultPaginator, IAPIConnector?apiConnector = null ) { BaseAddress = baseAddress; Authenticator = authenticator; JSONSerializer = jsonSerializer; HTTPClient = httpClient; RetryHandler = retryHandler; HTTPLogger = httpLogger; DefaultPaginator = defaultPaginator; APIConnector = apiConnector; }
// helper method for beacon sending with retries private StatusResponse SendBeaconRequest(IHTTPClient httpClient, byte[] beaconData, int numRetries) { StatusResponse response = null; var retry = 0; var retrySleepMillis = INITIAL_RETRY_SLEEP_TIME_MILLISECONDS; while (true) { response = httpClient.SendBeaconRequest(clientIPAddress, beaconData); if (response != null || (retry >= numRetries)) { // success OR max retry count reached break; } timingProvider.Sleep(retrySleepMillis); retrySleepMillis *= 2; retry++; } return(response); }
public void Setup() { httpClient = Substitute.For <IHTTPClient>(); finishedSessions = new Queue <Session>(); openSessions = new List <Session>(); // provider timingProvider = Substitute.For <ITimingProvider>(); httpClientProvider = Substitute.For <IHTTPClientProvider>(); httpClientProvider.CreateClient(Arg.Any <HTTPClientConfiguration>()).Returns(x => httpClient); // context context = Substitute.For <IBeaconSendingContext>(); context.GetHTTPClient().Returns(httpClient); context.HTTPClientProvider.Returns(httpClientProvider); // beacon sender beaconSender = new BeaconSender(context); // sessions context.GetAllOpenSessions().Returns(openSessions); context.GetNextFinishedSession().Returns(x => (finishedSessions.Count == 0) ? null : finishedSessions.Dequeue()); }
public void Setup() { currentTime = 0; lastTimeSyncTime = -1; httpClient = Substitute.For <IHTTPClient>(); context = Substitute.For <IBeaconSendingContext>(); context.GetHTTPClient().Returns(httpClient); // return true by default context.IsTimeSyncSupported.Returns(true); // current time getter context.CurrentTimestamp.Returns(x => { return(++currentTime); }); // last time sycn getter + setter context.LastTimeSyncTime = Arg.Do <long>(x => lastTimeSyncTime = x); context.LastTimeSyncTime = lastTimeSyncTime; // init with -1 // by default return erroneous responses httpClient.SendTimeSyncRequest() .Returns(new TimeSyncResponse(Substitute.For <ILogger>(), string.Empty, Response.HttpBadRequest, new Dictionary <string, List <string> >())); }
public VoiceFileUploader(int appid, string appkey, IHTTPClient httpclient) : base(appid, appkey, httpclient) { }
public void OnAfterHttpResponseEventHandler(IHTTPClient source, HTTPResponse response) { Response = response; }
public SmsVoicePromptSender(int appid, string appkey, IHTTPClient httpclient) : base(appid, appkey, httpclient) { }
public void Setup() { httpClient = Substitute.For <IHTTPClient>(); context = Substitute.For <IBeaconSendingContext>(); }
static HTTPClient() { SharedClient = new HTTPClient(); }
public SicopClient(string urlBase, IHTTPClient cliente) { _urlBase = urlBase; _cliente = cliente; }
public SmsVoiceVerifyCodeSender(int appid, String appkey, IHTTPClient httpclient) : base(appid, appkey, httpclient) { }
public WifiControllerViewModel(ICommandGenerator commandGenerator, ISettingAccess settingAccess, INavigator navigator, IHTTPClient httpClient, IPlatformToast platformToast) : base(navigator) { _commandGenerator = commandGenerator; _settingAccess = settingAccess; _httpClient = httpClient; _platformToast = platformToast; InitializeCommands(); }
public SmsBase(int appid, string appkey, IHTTPClient httpclient) { this.appid = 1400150305; this.appkey = "5b458e6700046c36f5f252ae4efe0478"; this.httpclient = httpclient; }
//Remember: Parameters for this constructor are the depenedency injections public CatalogService(IConfiguration config, IHTTPClient client) { _baseUri = $"{config["CatalogUrl"]}/api/catalog"; _client = client; }
public TencentSmsService(int appid, string appkey, IHTTPClient httpclient) { this.appid = appid; this.appkey = appkey; this.httpclient = httpclient; }
public HomeController(IConfiguration configuration, IHTTPClient httpClient) { _configuration = configuration; _httpClient = httpClient; }
public SmsMultiSender(int appid, string appkey, IHTTPClient httpclient) : base(appid, appkey, httpclient) { }
public void Setup() { httpClient = Substitute.For <IHTTPClient>(); context = Substitute.For <IBeaconSendingContext>(); context.GetHTTPClient().Returns(httpClient); }
public TtsVoiceSender(int appid, string appkey, IHTTPClient httpclient) : base(appid, appkey, httpclient) { }
public SmsBase(int appid, string appkey, IHTTPClient httpclient) { this.appid = appid; this.appkey = appkey; this.httpclient = httpclient; }
public SmsMobileStatusPuller(int appid, string appkey, IHTTPClient httpclient) : base(appid, appkey, httpclient) { }
public void StartSession() { RestClient = new RestClient(Proxy, ProxyUrl); }
public HTTPBaseRequestImpl(IHTTPClient client) { this.client = client; }
public void Setup() { _httpClient = new FakeHttpClient(); // _httpClient = new Sicop.Client.Http.DefaultHttpClient(); _cliente = new SicopClient("http://www.sefaz.es.gov.br/wsSicopImportacao/", _httpClient); }
public void OnBeforeHttpRequestEventHandler(IHTTPClient source, HTTPRequest request) { Request = request; }