public BlobRulesDriver(Uri url, IWebClientFactory webClientFactory, IScheduler scheduler = null) { _url = url; _subject = new ReplaySubject <Dictionary <string, RuleDefinition> >(1); scheduler = scheduler ?? TaskPoolScheduler.Default; _subscription = Observable.Interval(TimeSpan.FromSeconds(30)) .StartWith(0) .SubscribeOn(scheduler) .Select((_) => Observable.FromAsync(async() => { using (var client = webClientFactory.Create()) { client.Encoding = Encoding.UTF8; return(await client.DownloadStringTaskAsync(_url)); } })) .Switch() .DistinctUntilChanged() .Select(JsonConvert.DeserializeObject <Dictionary <string, RuleDefinition> >) .DistinctUntilChanged(new DictionaryEqualityComparer <string, RuleDefinition>(new RuleDefinitionComparer())) .Catch((Exception exception) => { //Trace.TraceWarning($"Failed to update rules from {url}\r\n{exception}"); return(Observable.Empty <Dictionary <string, RuleDefinition> >().Delay(TimeSpan.FromMinutes(1))); }) .Repeat() .Do(_subject) .Subscribe(x => OnRulesChange?.Invoke(x)); }
protected override void GivenThat() { base.GivenThat(); _webClientFactory = GenerateMock <IWebClientFactory>(); _webClient = GenerateMock <IWebClient>(); _directoryInfoProvider = GenerateMock <IDirectoryInfoProvider>(); _directoryInfo = GenerateMock <IDirectoryInfo>(); _fileUtilities = GenerateMock <IFileUtilities>(); _stateProvider = GenerateMock <IStateProvider>(); _counterFactory = GenerateMock <ICounterFactory>(); _averageCounterTime = GenerateMock <IAverageCounter>(); _averageCounterSize = GenerateMock <IAverageCounter>(); _state = GenerateMock <IState>(); _commandExecuter = GenerateMock <ICommandExecuter>(); _syncItem = new SyncItem(); _exception = null; SetupData(); SetupStubs(); _downloader = new EpisodeDownloader(_webClientFactory, _directoryInfoProvider, _fileUtilities, _stateProvider, _counterFactory, _commandExecuter); _downloader.StatusUpdate += new EventHandler <StatusUpdateEventArgs>(DownloaderStatusUpdate); _downloader.ProgressUpdate += new EventHandler <ProgressEventArgs>(DownloaderProgressUpdate); }
internal TestRailApiClient(TestRailApiClientConfiguration config, IWebClientFactory webClientFactory = null) { _config = config; _webClientFactory = webClientFactory ?? new WebClientFactory(); if (string.IsNullOrEmpty(config.Url)) { throw new TestRailClientException("Url is not provided in TestRail client configuration."); } if (string.IsNullOrEmpty(config.UserName)) { throw new TestRailClientException("UserName is not provided in TestRail client configuration."); } if (string.IsNullOrEmpty(config.AppKey)) { throw new TestRailClientException("AppKey is not provided in TestRail client configuration."); } if (config.Url.Last() != '/') { config.Url += "/"; } _statuses = new Lazy <TestRailStatusDictionary>( () => InnerGetStatusesAsync().Result); _priorities = new Lazy <TestRailPriorityDictionary>( () => InnerGetPrioritiesAsync().Result); }
public DownloadProvider(ILoggingService loggingService, IDateTimeService dateTimeService, IWebClientFactory webClientFactory) { this.loggingService = loggingService; this.dateTimeService = dateTimeService; this.webClientFactory = webClientFactory; }
protected override void GivenThat() { base.GivenThat(); _controlFile = TestControlFileFactory.CreateControlFile(); _stateProvider = GenerateMock <IStateProvider>(); _state = GenerateMock <IState>(); _timeProvider = GenerateMock <ITimeProvider>(); _webClientFactory = GenerateMock <IWebClientFactory>(); _webClient = GenerateMock <IWebClient>(); _feedFactory = GenerateMock <IPodcastFeedFactory>(); _fileUtilities = GenerateMock <IFileUtilities>(); _podcastFeed = GenerateMock <IPodcastFeed>(); _directoryInfoProvider = GenerateMock <IDirectoryInfoProvider>(); _directoryInfo = GenerateMock <IDirectoryInfo>(); _commandGenerator = GenerateMock <ICommandGenerator>(); _pathUtilities = GenerateMock <IPathUtilities>(); SetupData(); SetupStubs(); _episodeFinder = new EpisodeFinder(_fileUtilities, _feedFactory, _webClientFactory, _timeProvider, _stateProvider, _directoryInfoProvider, _commandGenerator, _pathUtilities); _episodeFinder.StatusUpdate += new EventHandler <StatusUpdateEventArgs>(EpisodeFinderStatusUpdate); _latestUpdate = null; }
public void SetUp() { _webClientFactory = Substitute.For <IWebClientFactory>(); _target = new BulkSender(_webClientFactory, Substitute.For <IInternalLogger>()); _webClient = Substitute.For <IWebClient>(); _webClientFactory.GetWebClient().Returns(x => _webClient); }
public AnnualReportService( IAnnualReportSearchService annualReportSearchService, IWebClientFactory webClientFactory) { this.annualReportSearchService = annualReportSearchService; this.webClientFactory = webClientFactory; }
public BulkSender(IWebClientFactory webClientFactory, IInternalLogger internalLogger) { _webClientFactory = webClientFactory; _internalLogger = internalLogger; _jsonSerializer = new JsonSerializer { ContractResolver = new CamelCasePropertyNamesContractResolver() }; }
public BuildDataFetcher(ViewUrl viewUrl, IConfigSettings configSettings, IWebClientFactory webClientFactory) { _viewUrl = viewUrl; _webClientFactory = webClientFactory; _webClient = webClientFactory.GetWebClient(configSettings.URL); configSettings.AddObserver(this); }
public CameraImageDownloading(ICameraInfoHelper cameraInfoHelper = null, IImageManipulator imageSaver = null, IWebClientFactory webClientFactory = null) { _cameraInfoHelper = cameraInfoHelper ?? new CameraInfoHelper(); _imageSaver = imageSaver ?? new LocalImageManipulator(); _webClientFactory = webClientFactory ?? new CustomWebClientFactory(); }
public void TestSetup() { _factory = Substitute.For <IWebClientFactory>(); _client = Substitute.For <IWebClient>(); _writer = Substitute.For <IDataWriter>(); _factory.Create().Returns(_client); }
public BuildDataFetcher(CruiseAddress cruiseAddress, IConfigSettings configSettings, IWebClientFactory webClientFactory) { _cruiseAddress = cruiseAddress; _webClientFactory = webClientFactory; _webClient = webClientFactory.GetWebClient(configSettings.URL); configSettings.AddObserver(this); }
//public string BehavioHost { get; set; } //string _behavioEnvironment; //public string BehavioEnvironment //{ // get { return _behavioEnvironment; } // set // { // var v = value; // if (!string.IsNullOrEmpty(value)) // { // v = v.TrimEnd('/'); // if (!v.StartsWith("/")) // { // v = "/" + v; // } // } // _behavioEnvironment = v; // } //} /// <summary> /// Creates instance of the AccessSdk, allowing the client to specify version of responses to request. /// </summary> /// <param name="host">host FQDN of the host that AccessSdk will talk to.</param> /// <param name="merchantId">merchantId Merchant ID (6 digit value).</param> /// <param name="apiKey">apiKey The API Key for the merchant.</param> /// <param name="version">version The version of the API response to return.</param> /// <param name="webClientFactory">Used for webClient mockup in tests.</param> /// <param name="behavioHost">FQDN of the host that AccessSdk will use for BehavioSec requests.</param> /// <param name="behavioEnvironment">Environment used for BehavioSec requests (e.g. sandbox).</param> public AccessSdk(string host, int merchantId, string apiKey, string version = DefaultVersion, IWebClientFactory webClientFactory = null, string behavioHost = null, string behavioEnvironment = null) { if (webClientFactory == null) { this._webClientFactory = new SystemWebClientFactory(); } else { this._webClientFactory = webClientFactory; } if (apiKey == null) { throw new AccessException(AccessErrorType.INVALID_DATA, "Missing apiKey"); } if (String.IsNullOrEmpty(apiKey.Trim())) { throw new AccessException(AccessErrorType.INVALID_DATA, "Invalid apiKey(" + apiKey + ")"); } if (merchantId < 99999 || merchantId > 1000000) { throw new AccessException(AccessErrorType.INVALID_DATA, "Invalid merchantId"); } if (string.IsNullOrEmpty(host)) { throw new AccessException(AccessErrorType.INVALID_DATA, "Missing host"); } this._host = host; //this.BehavioHost = behavioHost; //this.BehavioEnvironment = behavioEnvironment; ILoggerFactory factory = LogFactory.GetLoggerFactory(); this._logger = factory.GetLogger(typeof(AccessSdk).ToString()); this._merchantId = merchantId; this._apiKey = apiKey.Trim(); this._version = version; this._encodedCredentials = GetBase64Credentials(merchantId.ToString(), apiKey); this._logger.Info("Access SDK using merchantId = " + merchantId + ", host = " + host + ", API key = " + apiKey); this._logger.Debug("velocity endpoint: " + VelocityEndpoint); this._logger.Debug("decision endpoint: " + DecisionEndpoint); this._logger.Debug("device endpoint: " + DeviceEndpoint); this._logger.Debug("info endpoint: " + InfoEndpoint); this._logger.Debug("devices endpoint: " + DevicesEndpoint); this._logger.Debug("uniques endpoint: " + UniquesEndpoint); this._logger.Debug("Device trust by session endpoint: " + DeviceTrustBySessionEndpoint); this._logger.Debug("Device trust by device endpoint: " + DeviceTrustByDeviceEndpoint); //this._logger.Debug("BehavioSec endpoint: " + BehavioSecEndpoint); //this._logger.Debug("BehavioSec environment: " + BehavioEnvironment); }
/// <summary> /// construct the factory /// </summary> public EpisodeDownloaderFactory(IWebClientFactory webClientFactory, IDirectoryInfoProvider directoryInfoProvider, IFileUtilities fileUtilities, IStateProvider stateProvider, ICounterFactory counterFactory, ICommandExecuter commandExecuter) { _webClientFactory = webClientFactory; _commandExecuter = commandExecuter; _counterFactory = counterFactory; _stateProvider = stateProvider; _fileUtilities = fileUtilities; _directoryInfoProvider = directoryInfoProvider; }
public LibroLibWebClient( IWebClientFactory webClientFactory, IWebConfiguration configuration, IFileSystem fileSystem) { this.webClientFactory = webClientFactory; this.configuration = configuration; this.fileSystem = fileSystem; }
/// <summary> /// discover items to be downloaded from a feed /// </summary> public EpisodeFinder(IFileUtilities fileFinder, IPodcastFeedFactory feedFactory, IWebClientFactory webClientFactory, ITimeProvider timeProvider, IStateProvider stateProvider, IDirectoryInfoProvider directoryInfoProvider, ICommandGenerator commandGenerator) { _fileUtilities = fileFinder; _commandGenerator = commandGenerator; _directoryInfoProvider = directoryInfoProvider; _stateProvider = stateProvider; _timeProvider = timeProvider; _webClientFactory = webClientFactory; _feedFactory = feedFactory; }
public void SetUp() { _view = MockRepository.GenerateMock<ICradiatorView>(); _configSettings = MockRepository.GenerateMock<IConfigSettings>(); _configSettings.Expect(c => c.ProjectNameRegEx).Return(".*").Repeat.Any(); _kernel = new StandardKernel(new CradiatorNinjaModule(_view, _configSettings)); _factory = _kernel.Get<IWebClientFactory>(); _kernel.Get<BuildDataTransformer>(); }
/// <summary> /// create a task /// </summary> public EpisodeDownloader(IWebClientFactory webClientFactory, IDirectoryInfoProvider directoryInfoProvider, IFileUtilities fileUtilities, IStateProvider stateProvider, ICounterFactory counterFactory, ICommandExecuter commandExecuter) { _webClientFactory = webClientFactory; _commandExecuter = commandExecuter; _counterFactory = counterFactory; _stateProvider = stateProvider; _fileUtilities = fileUtilities; _directoryInfoProvider = directoryInfoProvider; TaskComplete = new ManualResetEvent(false); }
protected override void GivenThat() { base.GivenThat(); _counterFactory = GenerateMock <ICounterFactory>(); _stateProvider = GenerateMock <IStateProvider>(); _webClientFactory = new WebClientFactory(); _directoryInfoProvider = GenerateMock <IDirectoryInfoProvider>(); _fileUtilities = GenerateMock <IFileUtilities>(); _commandExecuter = GenerateMock <ICommandExecuter>(); _factory = new EpisodeDownloaderFactory(_webClientFactory, _directoryInfoProvider, _fileUtilities, _stateProvider, _counterFactory, _commandExecuter); }
public CountryRetriever(IWebClientFactory webClientFactory=null, Uri importURL=null) { this.engine = new FileHelperEngine<SourceModels.Country>(); this.importURL = importURL ?? new Uri( ConfigurationManager.AppSettings["GeoNamesCountryImport:ImportURL"] ?? DefaultImportURL ); this.webClientFactory = webClientFactory ?? (IWebClientFactory)new WebClientFactory(); }
public TasksService(IOptions<SourceControlRestApiConfiguration> sourceControlRestApiConfiguration, ITasksRepository tasksRepository, IGroupsRepository groupsRepository, IUserService userService, IWebClientFactory webClientFactory) { _sourceControlRestApiConfiguration = sourceControlRestApiConfiguration; _tasksRepository = tasksRepository; _groupsRepository = groupsRepository; _userService = userService; _webClientFactory = webClientFactory; _sourceControlUrl = "http://it-learning-source-control.azurewebsites.net/";// _sourceControlRestApiConfiguration.Value.Url; }
public DomainLoader(IWebClientFactory client, IDataWriter writer, string domain) { client.ThrowIfNull(nameof(client)); writer.ThrowIfNull(nameof(writer)); _domain = Url.Create(domain); _client = client; _writer = writer; _simplifier = new HtmlSimplifier(); _queue.Enqueue(_domain); }
public void SetUp() { _view = MockRepository.GenerateMock <ICradiatorView>(); _configSettings = MockRepository.GenerateMock <IConfigSettings>(); _configSettings.Expect(c => c.ProjectNameRegEx).Return(".*").Repeat.Any(); _configSettings.Expect(c => c.CategoryRegEx).Return(".*").Repeat.Any(); _configSettings.Expect(c => c.ServerNameRegEx).Return(".*").Repeat.Any(); _kernel = new StandardKernel(new CradiatorNinjaModule(_view, _configSettings)); _factory = _kernel.Get <IWebClientFactory>(); _kernel.Get <BuildDataTransformer>(); }
public void SetUp() { _webClientFactory = MockRepository.GenerateMock<IWebClientFactory>(); _webClient = MockRepository.GenerateStub<IWebClient>(); _webClientFactory.Expect(w => w.GetWebClient(Arg<string>.Is.Anything)).Return(_webClient).Repeat.Once(); _configSettings = new ConfigSettings { ProjectNameRegEx = ".*" }; _urlUpdateResponder = new UrlUpdateResponder( new StatusFetcher(new CruiseAddress("url"), _configSettings, _webClientFactory), _configSettings, _webClientFactory); _configSettings.URL = "currentUrl"; }
public FileDownloader(ILogger <FileDownloader> logger, IWebClientFactory webClientFactory, IConfigurationOptions configuration, ILinksCache linksCache, IDownloadProgressCache downloadProgressCache, INotificationService notificationService) { _logger = logger; _webClientFactory = webClientFactory; _configuration = configuration; _linksCache = linksCache; _downloadProgressCache = downloadProgressCache; _notificationService = notificationService; }
public RegistrationManager(Uri registrationServiceUri, string uniqueClientId, IWebClientFactory webClientFactory) { if (registrationServiceUri == null) throw new ArgumentNullException("registrationServiceUri"); _registrationServiceUri = registrationServiceUri; if (uniqueClientId == null) throw new ArgumentNullException("uniqueClientId"); _uniqueClientId = uniqueClientId; if (webClientFactory == null) throw new ArgumentNullException("webClientFactory"); _webClientFactory = webClientFactory; }
public PrintParser( Credentials credentials, int room, MeTLLib.Providers.Structure.IConversationDetailsProvider conversationDetailsProvider, HttpHistoryProvider historyProvider, CachedHistoryProvider cachedHistoryProvider, MetlConfiguration metlServerAddress, ResourceCache cache, IReceiveEvents receiveEvents, IWebClientFactory webClientFactory, HttpResourceProvider httpResourceProvider, IAuditor _auditor) : base(credentials, room, conversationDetailsProvider, historyProvider, cachedHistoryProvider, metlServerAddress, cache, receiveEvents, webClientFactory, httpResourceProvider,_auditor) { }
protected override void GivenThat() { base.GivenThat(); _counterFactory = GenerateMock <ICounterFactory>(); _stateProvider = GenerateMock <IStateProvider>(); _webClientFactory = GenerateMock <IWebClientFactory>(); _commandExecuter = GenerateMock <ICommandExecuter>(); _downloaderFactory = new EpisodeDownloaderFactory(_webClientFactory, _directoryInfoProvider, _fileUtilities, _stateProvider, _counterFactory, _commandExecuter); _downloadItems = new List <ISyncItem>(10); SetupData(); SetupStubs(); _converter = new SyncItemToEpisodeDownloaderTaskConverter(_downloaderFactory); }
public void SetUp() { _webClientFactory = MockRepository.GenerateMock <IWebClientFactory>(); _webClient = MockRepository.GenerateStub <IWebClient>(); _webClientFactory.Expect(w => w.GetWebClient(Arg <string> .Is.Anything)).Return(_webClient).Repeat.Once(); _configSettings = new ConfigSettings { ProjectNameRegEx = ".*" }; _urlUpdateResponder = new UrlUpdateResponder( new StatusFetcher(new CruiseAddress("url"), _configSettings, _webClientFactory), _configSettings, _webClientFactory); _configSettings.URL = "currentUrl"; }
private static void SetDefaults() { if (FileSystem == null) { FileSystem = new FileSystem(); } if (Environment == null) { Environment = new EnvironmentWrapper(); } if (WebClientFactory == null) { WebClientFactory = new WebClientFactory(); } }
public StubFileConversationDetailsProvider(IWebClientFactory factory, IResourceUploader uploader) : base(factory, uploader) { }
public void SetUp() { _factory = MockRepository.GenerateStub<IWebClientFactory>(); _responseDecoder = MockRepository.GenerateStub<IResponseDecoder>(); _webClient = MockRepository.GenerateStub<WebClient>(); _factory.Stub(f => f.Create()).Return(_webClient); _webClient.Headers = new WebHeaderCollection(); }
/// <summary> /// Initialises a new <see cref="HttpConnection"/> to a remote server. /// </summary> /// <param name="serverAddress">The address of the remote server.</param> /// <param name="clientfactory">The clientfactory.</param> public HttpConnection(Uri serverAddress, IWebClientFactory clientfactory) { this.serverAddress = serverAddress; this.WebClientfactory = clientfactory; }
public void SetUp() { _webClientFactory = Create.Stub<IWebClientFactory>(); _webClient = Create.Mock<IWebClient>(); _webClientFactory.Stub(w => w.GetWebClient(Arg<string>.Is.Anything)).Return(_webClient); }
public AppVeyor(IEnvironment environment, IWebClientFactory webClientFactory) { _environment = environment; _webClientFactory = webClientFactory; _appVeyorApiUrl = _environment.GetEnvironmentVariable("APPVEYOR_API_URL"); }
public XmlABTestingConfigurationReader(IWebClientFactory webClientFactory, IClientUrlBuilder clientUrlBuilder) { _webClientFactory = webClientFactory; _clientUrlBuilder = clientUrlBuilder; }
public HttpPostResolver(IWebClientFactory webClientFactory, string parametersAsString) { _webClientFactory = webClientFactory; ParametersAsString = parametersAsString; }
public ConfigurationProvider(IWebClientFactory factory,IAuditor auditor) : base(factory,auditor) {}
public HttpResourceProvider(IWebClientFactory factory) { _clientFactory = factory; }
public HttpPostResolver(IWebClientFactory webClientFactory) { _webClientFactory = webClientFactory; }
public AuthorisationProvider(IWebClientFactory factory, MeTLServerAddress server) : base(factory) { this.server = server; }
public void SetUp() { _webClientFactory = MockRepository.GenerateStub<IWebClientFactory>(); _webClient = MockRepository.GenerateMock<IWebClient>(); _webClientFactory.Stub(w => w.GetWebClient(Arg<string>.Is.Anything, "dummy", "dummy")).Return(_webClient); }
public AspClient(IWebClientFactory webClientFactory, IResponseDecoder responseDecoder) { _factory = webClientFactory; _responseDecoder = responseDecoder; }
public ConfigurationProvider(IWebClientFactory factory) : base(factory) {}
public MobileServiceClient(string serviceUrl, string applicationKey, IWebClientFactory clientFactory) { _serviceUrl = serviceUrl; _applicationKey = applicationKey; _clientFactory = clientFactory; }
public BuildDataFetcher(ViewUrl viewUrl, string url, IWebClientFactory webClientFactory) { _viewUrl = viewUrl; _webClient = webClientFactory.GetWebClient(url); }
public AuthorisationProvider(IWebClientFactory factory, MetlConfiguration server, IAuditor auditor) : base(factory,auditor) { this.webclientFactory = factory; this.server = server; }
/// <summary> /// コンストラクタ /// </summary> /// <param name="factory">使用するIWebClientFactoryオブジェクト</param> public LivetubeClient(IWebClientFactory factory) { _webClient = factory.CreateWebClient(); }
/// <summary> /// IWebClientFactoryを外から選択可能なコンストラクタ /// </summary> /// <param name="factory">LivetubeClientが使用するIWebClientFactory</param> public LivetubeClientFactory(IWebClientFactory factory) { _webClientFactory = factory; }
public JournalTocsJsonClient(JournalTocsSettings settings, IWebClientFactory webClientFactory) { _settings = settings; _webClientFactory = webClientFactory; }
public JournalTocsClient(JournalTocsSettings settings, IWebClientFactory webClientFactory) { _settings = settings; _webClientFactory = webClientFactory; }
public void SetUp() { _webClientFactory = Create.Stub <IWebClientFactory>(); _webClient = Create.Mock <IWebClient>(); _webClientFactory.Stub(w => w.GetWebClient(Arg <string> .Is.Anything)).Return(_webClient); }
public UriToStream(IWebClientFactory w, String u) { webClientFactory = w; uri = u; }