public void GetSessionId_CalledSimultaneously_Only1ApiCallRequested() { //A var apiCallsCount = 0; var serviceLowLevelSoapV11410Ee = new MagentoServiceLowLevelSoap_v_1_14_1_0_EE("qwe", "qwe", "https://magento.com", "1", 300000, true, 30) { PullSessionId = async() => { await Task.Delay(1000); Interlocked.Increment(ref apiCallsCount); return(Tuple.Create("qwe", DateTime.UtcNow)); } }; var list = new List <int>(); const int tasksCount = 3000; for (var i = 0; i < tasksCount; list.Add(i++)) { } //A var getSessionTasks = list.ProcessInBatchAsync(tasksCount, async x => await serviceLowLevelSoapV11410Ee.GetSessionId(false).ConfigureAwait(false)); getSessionTasks.Wait(); //A apiCallsCount.Should().Be(1); }
public void TestFixtureSetup() { this._testData = new TestData(@"..\..\Files\magento_ConsumerKey.csv", @"..\..\Files\magento_AuthorizeEndPoints.csv", @"..\..\Files\magento_AccessToken.csv", @"..\..\Files\magento_VerifierCode.csv"); this._consumer = this._testData.GetMagentoConsumerCredentials(); this._authorityUrls = this._testData.GetMagentoUrls(); this._accessToken = this._testData.GetMagentoAccessToken(); this._soapUserCredentials = this._testData.GetMagentoSoapUser(); this.transmitVerificationCode = () => this._testData.TransmitVerification(); this._magentoLowLevelSoapVFrom17To19CeService = new MagentoServiceLowLevelSoap_v_from_1_7_to_1_9_CE(this._soapUserCredentials.ApiUser, this._soapUserCredentials.ApiKey, this._authorityUrls.MagentoBaseUrl, null); this._magentoServiceLowLevelSoapV11410Ee = new MagentoServiceLowLevelSoap_v_1_14_1_0_EE(this._soapUserCredentials.ApiUser, this._soapUserCredentials.ApiKey, this._authorityUrls.MagentoBaseUrl, null); this._magentoServiceLowLevelRestRestRestRestNotAuth = new MagentoServiceLowLevelRestRest(this._consumer.Key, this._consumer.Secret, this._authorityUrls.MagentoBaseUrl, this._authorityUrls.RequestTokenUrl, this._authorityUrls.AuthorizeUrl, this._authorityUrls.AccessTokenUrl); this._magentoServiceLowLevelRestRestRestRest = new MagentoServiceLowLevelRestRest(this._consumer.Key, this._consumer.Secret, this._authorityUrls.MagentoBaseUrl, this._accessToken.AccessToken, this._accessToken.AccessTokenSecret); //this.CreateProducts(); //this.CreateOrders(); }
public void GetSessionId_IncorrectApiUser_NoExceptionThrowns() { //------------ Arrange //------------ Act Action act = () => { var service = new MagentoServiceLowLevelSoap_v_1_14_1_0_EE( "incorrect api user", this._testData.GetMagentoSoapUser().ApiKey, this._testData.GetMagentoUrls().MagentoBaseUrl, null); var getProductsTask = service.GetSessionId(false); getProductsTask.Wait(); }; //------------ Assert act.ShouldNotThrow(); }