public static void AddLoginExceptionExpectation(IWebRequestHelper webRequestHelper, Exception exceptionToThrow)
 {
     Expect.Call(delegate { webRequestHelper.Login(null); })
     .IgnoreArguments()
     .Constraints(Is.TypeOf <Configuration>())
     .Throw(exceptionToThrow);
 }
Exemplo n.º 2
0
        internal override void OnInitialization()
        {
            base.OnInitialization();

            _helper = Helper as IWebRequestHelper;
            _helper.OnInitialization();
        }
Exemplo n.º 3
0
        private async Task <string> GetPageContent(string url)
        {
            IWebRequestHelper webRequestHelper = ServiceLocator.Current.GetInstance <IWebRequestHelper>();
            IWebCache         webCache         = ServiceLocator.Current.GetInstance <IWebCache>();

            ICacheItem cacheItem = await webCache.Get(url, TimeSpan.FromDays(CacheDurationDays), k =>
            {
                return(webRequestHelper.GetDataAsync(url, null, null, 30000, null, new Dictionary <HttpRequestHeader, string>
                {
                    { HttpRequestHeader.Accept, "application/json" }
                }));
            });

            if (cacheItem == null)
            {
                return(null);
            }

            if (cacheItem.Data == null)
            {
                return(null);
            }

            return(cacheItem.GetUTF8());
        }
Exemplo n.º 4
0
 public AuthHelper(
     string autharizationApiUrl,
     IWebRequestHelper webRequestHelper)
 {
     this.autharizationApiUrl = autharizationApiUrl;
     this.webRequestHelper    = webRequestHelper;
 }
 public static void AddSearchExpectation(IWebRequestHelper webRequestHelper, string licenseExpected, string rawResponse)
 {
     Expect.On(webRequestHelper)
     .Call(webRequestHelper.Search(null, null))
     .IgnoreArguments()
     .Constraints(Is.Equal(licenseExpected), Is.TypeOf <Configuration>())
     .Return(rawResponse);
 }
        public MainWindow()
        {
            InitializeComponent();

            _webRequestHelper = new WebRequestHelper();
            _cdoMHTMLHelper   = new CDOMHTMLHelper(_webRequestHelper);
            _mailMHTMLHelper  = new MailMHTMLHelper(_webRequestHelper);
        }
        public ErrorLogDownloader(NetworkConnection connection, IWebRequestHelper webRequst, IFileSystemHelper fileSystemHelper, ICsvParser csvParser, ISettingsManager settingsManager)
        {
            Connection = connection;

            _webRequst = webRequst;
            _fileSystemsHelper = fileSystemHelper;
            _csvParser = csvParser;
            _settingsManager = settingsManager;

            ResolveDownloadDirectory();
        }
 public string Search(IWebRequestHelper webRequestHelper, string licenseNumber)
 {
     try
     {
         webRequestHelper.Search(licenseNumber, _config);
         return("success");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
 public string LoginHttp(IWebRequestHelper webRequestHelper)
 {
     try
     {
         webRequestHelper.Login(_config);
         return("success");
     }
     catch (ArgumentException ex)
     {
         throw new ArgumentException(ex.Message);
     }
 }
Exemplo n.º 10
0
 public TeamCity(IConfiguration configuration, IWebRequestHelper webRequestHelper)
 {
     this._configuration    = configuration;
     this._webRequestHelper = webRequestHelper;
     this._log          = LoggingProvider.GetLogger <TeamCity>();
     this._buildIdRegex = new Regex(configuration.ChangeProviderConfiguration.BuildIdFormat,
                                    RegexOptions.Compiled);
     if (!string.IsNullOrEmpty(configuration.ChangeProviderConfiguration.IssueFormat))
     {
         this._log.Info("Compiling the following regex: " + configuration.ChangeProviderConfiguration.IssueFormat);
         this._issueIdRegex = new Regex(configuration.ChangeProviderConfiguration.IssueFormat);
     }
 }
Exemplo n.º 11
0
 public string LoginAndTest(IWebRequestHelper webRequestHelper)
 {
     try
     {
         webRequestHelper.Login(_config);
         webRequestHelper.Test();
         return("success");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Exemplo n.º 12
0
        public UsNavalSolarAltitudeService(TraceWriter tracer, IWebRequestHelper requestHelper, bool testMode = false)
        {
            Debug.Assert(requestHelper != null);

            _testMode = testMode;

            _tracer        = tracer;
            _requestHelper = requestHelper;

            _lineParseRegex = new Regex(@"^\s*(?<time>\d\d\:\d\d)\s+(?<alt>\-?\d+(\.\d+)?)",
                                        RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline);

            Throttle = testMode ? 0 : 1;
        }
Exemplo n.º 13
0
        public UrlStatusService(IWebRequestHelper webRequestHelper, ICacheHelper cacheHelper)
        {
            if (webRequestHelper == null)
            {
                throw new ArgumentNullException(nameof(webRequestHelper));
            }
            if (cacheHelper == null)
            {
                throw new ArgumentNullException(nameof(cacheHelper));
            }

            _webRequestHelper = webRequestHelper;
            _statusCache      = cacheHelper;
        }
 public CDOMHTMLHelper(IWebRequestHelper webRequestHelper)
 {
     _webRequestHelper = webRequestHelper;
 }
Exemplo n.º 15
0
 public Bills(IWebRequestHelper webRequestHelper)
     : base(webRequestHelper)
 {
 }
Exemplo n.º 16
0
 public void Dispose(IWebRequestHelper webRequestHelper)
 {
     webRequestHelper.Dispose();
 }
Exemplo n.º 17
0
 public VkAPI(string appId, string appSecret, IWebRequestHelper webRequest)
 {
     this.appId      = appId;
     this.appSecret  = appSecret;
     this.webRequest = webRequest;
 }
Exemplo n.º 18
0
 public static void AddTestExpectation(IWebRequestHelper webRequestHelper)
 {
     Expect.Call(() => webRequestHelper.Test()).IgnoreArguments();
 }
Exemplo n.º 19
0
        public string MakeWebRequestCall(IWebRequestHelper webServiceHelper, HttpWebRequest webRequest, string request)
        {
            string returnString = webServiceHelper.GetResponse(webRequest, request);

            return(returnString);
        }
Exemplo n.º 20
0
 public void Test(IWebRequestHelper webRequestHelper)
 {
     webRequestHelper.Test();
 }
Exemplo n.º 21
0
 public CoordinatesService(IWebRequestHelper web)
 {
     this.web = web;
 }
Exemplo n.º 22
0
        protected override void OnRuntimeEnable()
        {
            base.OnRuntimeEnable();

            _webRequestHelper = Target.GetType().GetField("_helper", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Target) as IWebRequestHelper;
        }
Exemplo n.º 23
0
 public WebDictionaryRequestHelper(IWebRequestHelper webRequestHelper)
 {
     _webRequestHelper = webRequestHelper;
 }
Exemplo n.º 24
0
 public static void AddDisposeExpectation(IWebRequestHelper webRequestHelper)
 {
     Expect.Call(delegate { webRequestHelper.Dispose(); }) //delegate needed since it is a void method
     .IgnoreArguments().Constraints();
 }
Exemplo n.º 25
0
 public static void AddLoginExpectation(IWebRequestHelper webRequestHelper, Configuration config)
 {
     Expect.Call(() => webRequestHelper.Login(config))
     .IgnoreArguments()
     .Constraints(Is.TypeOf <Configuration>());
 }
Exemplo n.º 26
0
 public BillingApi(IWebRequestHelper webRequestHelper)
 {
     _bills = new Bills(webRequestHelper);
 }
Exemplo n.º 27
0
 public FacebookAPI(string appId, string appSecret, IWebRequestHelper webRequest)
 {
     this.appId     = appId;
     this.appSecret = appSecret;
 }
Exemplo n.º 28
0
 public ItemsAPI(IWebRequestHelper webRequestHelper, string authToken)
 {
     this.webRequestHelper = webRequestHelper;
     this.authToken        = authToken;
 }
        protected override void OnRuntimeEnable()
        {
            base.OnRuntimeEnable();

            _webRequestHelper = _helper as IWebRequestHelper;
        }
Exemplo n.º 30
0
 public AuthorizationAPI(IWebRequestHelper webRequestHelper)
 {
     this.webRequestHelper = webRequestHelper;
 }
 public AuthorizeController(IWebRequestHelper helper, IOptions <SMApiConfigurationModel> smApiConfigModel)
 {
     _helper           = helper;
     _smApiConfigModel = smApiConfigModel.Value;
 }
Exemplo n.º 32
0
 /// <summary>
 /// 设置网页请求帮助类
 /// </summary>
 /// <param name="helper"></param>
 public void SetWebRequestHelper(IWebRequestHelper helper)
 {
     _webRequestHelper = helper;
 }
Exemplo n.º 33
0
 public static void AddHttpRequestExpectation(IWebRequestHelper webRequestHelper, HttpWebRequest httpRequest, string request, string response)
 {
     Expect.On(webRequestHelper).Call(webRequestHelper.GetResponse(httpRequest, request)).Return(response);
 }