Ejemplo n.º 1
0
        public void Init()
        {
            var credentials = LoadCredentials();

            ShopName = credentials.ShopName;
            var config = new EtsyConfig(credentials.ShopName, credentials.Token, credentials.TokenSecret);

            var factory   = new EtsyServicesFactory(credentials.ApplicationKey, credentials.SharedSecret);
            var throttler = new Throttler(config.ThrottlingMaxRequestsPerRestoreInterval, config.ThrottlingRestorePeriodInSeconds, config.ThrottlingMaxRetryAttempts);

            EtsyOrdersService         = factory.CreateOrdersService(config, throttler);
            EtsyItemsService          = factory.CreateItemsService(config, throttler);
            EtsyAuthenticationService = factory.CreateAuthenticationService(config);
            EtsyAdminService          = factory.CreateAdminService(config, throttler);
            CancellationTokenSource   = new CancellationTokenSource();
        }
        public void RequestTimesOut()
        {
            var          requestTimeout = 1;
            const string message        = "TaskCanceledException";
            var          credentials    = LoadCredentials();
            var          config         = new EtsyConfig(credentials.ShopName, credentials.Token, credentials.TokenSecret, requestTimeout);

            var factory   = new EtsyServicesFactory(credentials.ApplicationKey, credentials.SharedSecret);
            var throttler = new Throttler(config.ThrottlingMaxRequestsPerRestoreInterval, config.ThrottlingRestorePeriodInSeconds, config.ThrottlingMaxRetryAttempts);

            EtsyOrdersService = factory.CreateOrdersService(config, throttler);
            var cancellationTokenSource = new CancellationTokenSource();

            var etsyException = Assert.Throws <EtsyException>(() =>
            {
                base.EtsyOrdersService.GetOrders(DateTime.Now.AddMonths(-3), DateTime.Now, cancellationTokenSource.Token);
            });

            Assert.IsNotNull(etsyException);
            Assert.That(etsyException.ToString().Contains(message));
        }