public void Test_Issue_44() // Origins from https://github.com/FortnoxAB/csharp-api-sdk/issues/44
        {
            //Arrange
            var customerConnector = new CustomerConnector();
            var tmpCustomer       = customerConnector.Create(new Customer()
            {
                Name = "TmpTestCustomer"
            });

            IInvoiceConnector connector = new InvoiceConnector();

            var newInvoce = connector.Create(new Invoice()
            {
                InvoiceDate    = new DateTime(2019, 1, 20), //"2019-01-20",
                DueDate        = new DateTime(2019, 2, 20), //"2019-02-20",
                CustomerNumber = tmpCustomer.CustomerNumber,
                InvoiceType    = InvoiceType.Invoice,
                InvoiceRows    = new List <InvoiceRow>()
                {                     //Add Empty rows
                    new InvoiceRow(), //Empty Row
                    new InvoiceRow(), //Empty Row
                    new InvoiceRow()
                    {
                        AccountNumber = 0000
                    },
                    new InvoiceRow(), //Empty Row
                }
            });

            MyAssert.HasNoError(connector);
        }
예제 #2
0
        public void Test_Find_ParamsAdded()
        {
            var connector = new CustomerConnector
            {
                Name         = "TestName",
                City         = "TestCity",
                FilterBy     = Filter.Customer.Active,
                SortBy       = Sort.By.Customer.Name,
                SortOrder    = Sort.Order.Ascending,
                LastModified = new DateTime(2000, 01, 01, 20, 10, 05), //2000-01-20 20:10:05
                Limit        = 10,
                Offset       = 0,
                Page         = 1
            };

            connector.Find();
            MyAssert.HasNoError(connector);
            Assert.IsTrue(connector.RequestUriString.Contains("name=TestName"));
            Assert.IsTrue(connector.RequestUriString.Contains("city=TestCity"));
            Assert.IsTrue(connector.RequestUriString.Contains("filter=active"));
            Assert.IsTrue(connector.RequestUriString.Contains("sortby=name"));
            Assert.IsTrue(connector.RequestUriString.Contains("sortorder=ascending"));
            Assert.IsTrue(connector.RequestUriString.Contains("lastmodified=2000-01-01+20%3a10%3a05")); //"lastmodified=2000-01-20 20:10:05" in URL encoding
            Assert.IsTrue(connector.RequestUriString.Contains("limit=10"));
            Assert.IsTrue(connector.RequestUriString.Contains("offset=0"));
            Assert.IsTrue(connector.RequestUriString.Contains("page=1"));
        }
        public void Test_Issue95_fixed() //Origins from https://github.com/FortnoxAB/csharp-api-sdk/issues/95
        {
            //Arrange
            //Creates a customer with ElectronicInvoice option for deliviery type
            var connector   = new CustomerConnector();
            var tmpCustomer = connector.Create(new Customer()
            {
                Name = "TestCustomer",
                DefaultDeliveryTypes = new DefaultDeliveryTypes()
                {
                    Invoice = DefaultDeliveryType.ElectronicInvoice
                }
            });

            MyAssert.HasNoError(connector);

            //Act && Assert
            var customer = connector.Get(tmpCustomer.CustomerNumber);

            MyAssert.HasNoError(connector);
            Assert.AreEqual(DefaultDeliveryType.ElectronicInvoice, customer.DefaultDeliveryTypes.Invoice);

            //Clean
            connector.Delete(tmpCustomer.CustomerNumber);
            MyAssert.HasNoError(connector);
        }
        public void Test_issue73_async_non_blockable()
        {
            var connector = new CustomerConnector();

            connector.Search.Limit = 2;
            var watch = new Stopwatch();

            watch.Start();

            var runningTasks = new List <Task <EntityCollection <CustomerSubset> > >();

            for (int i = 0; i < 40; i++)
            {
                runningTasks.Add(connector.FindAsync());
            }

            Console.WriteLine(@"Thread free after: " + watch.ElapsedMilliseconds);
            Assert.IsTrue(watch.ElapsedMilliseconds < 1000);

            watch.Start();
            foreach (var runningTask in runningTasks)
            {
                var result = runningTask.Result;
                MyAssert.HasNoError(connector);
                Assert.IsNotNull(result);
            }
            watch.Stop();
            Console.WriteLine(@"Total time: " + watch.ElapsedMilliseconds);
        }
예제 #5
0
        public void Test_Issue96_fixed() // Origins from https://github.com/FortnoxAB/csharp-api-sdk/issues/96
        {
            #region Arrange
            var tmpSupplier = new SupplierConnector().Create(new Supplier()
            {
                Name = "TmpSupplier"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", PurchasePrice = 100
            });
            #endregion Arrange

            var connector = new SupplierInvoiceConnector();

            var createdInvoice = connector.Create(new SupplierInvoice()
            {
                SupplierNumber      = tmpSupplier.SupplierNumber,
                Comments            = "InvoiceComments",
                InvoiceDate         = new DateTime(2010, 1, 1),
                DueDate             = new DateTime(2010, 2, 1),
                SalesType           = SalesType.Stock,
                OCR                 = "123456789",
                Total               = 5000,
                SupplierInvoiceRows = new List <SupplierInvoiceRow>()
                {
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 10, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    },
                    new SupplierInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, Quantity = 20, Price = 100
                    }
                }
            });
            MyAssert.HasNoError(connector);
            Assert.AreEqual(false, createdInvoice.Cancelled);

            var retrievedInvoice = connector.Get(createdInvoice.GivenNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(false, retrievedInvoice.Cancelled);

            connector.LastModified = DateTime.Today;
            var invoiceSubsets = connector.Find().Entities;
            MyAssert.HasNoError(connector);
            foreach (var supplierInvoiceSubset in invoiceSubsets)
            {
                Assert.IsNotNull(supplierInvoiceSubset.Cancelled);
            }

            #region Delete arranged resources
            new CustomerConnector().Delete(tmpSupplier.SupplierNumber);
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            #endregion Delete arranged resources
        }
예제 #6
0
        public void Test_Customer_Update_UndefinedProperties()
        {
            var connector = new CustomerConnector();

            //Arrange - Create customer
            var existingCustomer = connector.Create(new Customer()
            {
                Name     = "TestCustomer",
                Address1 = "TestStreet 1",
                Type     = CustomerType.PRIVATE,
                VATType  = VATType.EUVAT
            });

            MyAssert.HasNoError(connector);

            //Act - Update customer
            var updatedCustomerData = new Customer()
            {
                CustomerNumber = existingCustomer.CustomerNumber,
                Address1       = "Updated Address"
            };

            var updatedCustomer = connector.Update(updatedCustomerData);

            MyAssert.HasNoError(connector);
            Assert.AreEqual("Updated Address", updatedCustomer.Address1);
            Assert.AreEqual("TestCustomer", updatedCustomer.Name);
            Assert.AreEqual(CustomerType.PRIVATE, updatedCustomer.Type);
            Assert.AreEqual(VATType.EUVAT, updatedCustomer.VATType);

            //Clean
            connector.Delete(existingCustomer.CustomerNumber);
            MyAssert.HasNoError(connector);
        }
        public void Test_issue51_fixed() //Origins from https://github.com/FortnoxAB/csharp-api-sdk/issues/51
        {
            //Arrange
            /* Assuming several (at least 5) vouchers exists */

            //Act & Assert
            var connector = new VoucherConnector();

            connector.Search.FinancialYearID = 1;

            connector.Search.Limit = 2;
            var voucherResult = connector.Find();

            MyAssert.HasNoError(connector);

            connector.Search.Page = 2;
            var voucherResult2 = connector.Find();

            MyAssert.HasNoError(connector);

            connector.Search.Page = 3;
            var voucherResult3 = connector.Find();

            MyAssert.HasNoError(connector);
        }
예제 #8
0
        public void Test_File_Upload_Download_Delete()
        {
            //Arrange
            var tmpPath = TestUtils.GetTempFilePath();

            System.IO.File.WriteAllBytes(tmpPath, Resource.fortnox_image); //Create local file

            var connector = new ArchiveConnector();

            //UPLOAD FILE
            var uploadedFile = connector.UploadFile(tmpPath, "");

            MyAssert.HasNoError(connector);

            System.IO.File.Delete(tmpPath); //Delete local file
            Assert.IsFalse(System.IO.File.Exists(tmpPath));

            //DOWNLOAD FILE
            connector.DownloadFile(uploadedFile.Id, tmpPath);
            MyAssert.HasNoError(connector);
            Assert.IsTrue(System.IO.File.Exists(tmpPath)); //Local file created by download

            //DELETE FILE
            connector.DeleteFile(uploadedFile.Id);
            MyAssert.HasNoError(connector);

            System.IO.File.Delete(tmpPath);
        }
예제 #9
0
        public void Test_Find_ParamsNullable()
        {
            var connector = new CustomerConnector()
            {
                Name         = "TestName",
                City         = null,
                FilterBy     = null,
                SortBy       = null,
                SortOrder    = null,
                LastModified = null,
                Limit        = null,
                Offset       = null,
                Page         = null
            };

            connector.Find();
            MyAssert.HasNoError(connector);
            Assert.IsFalse(connector.RequestUriString.Contains("city="));
            Assert.IsFalse(connector.RequestUriString.Contains("filter="));
            Assert.IsFalse(connector.RequestUriString.Contains("sortby="));
            Assert.IsFalse(connector.RequestUriString.Contains("sortorder="));
            Assert.IsFalse(connector.RequestUriString.Contains("lastmodified="));
            Assert.IsFalse(connector.RequestUriString.Contains("limit="));
            Assert.IsFalse(connector.RequestUriString.Contains("offset="));
            Assert.IsFalse(connector.RequestUriString.Contains("page="));
        }
예제 #10
0
        public void Test_LockedPeriod_Get()
        {
            var connector = new LockedPeriodConnector();
            var period    = connector.Get();

            MyAssert.HasNoError(connector);
            Assert.IsNotNull(period);
        }
예제 #11
0
        public void Test_CompanySettings_Get()
        {
            var connector = new CompanySettingsConnector();
            var settings  = connector.Get();

            MyAssert.HasNoError(connector);
            Assert.IsNotNull(settings?.Name);
        }
예제 #12
0
        public void TestFinicialYear()
        {
            /* Assumes a financial year exists (Financial year can not be deleted, therefore test should not create one */

            var connector    = new FinancialYearConnector();
            var finicialYear = connector.Get(1);

            MyAssert.HasNoError(connector);
        }
예제 #13
0
        public void TestAuth()
        {
            var authorizationCode = "Placeholder";
            var authConnector     = new AuthorizationConnector();
            var token             = authConnector.GetAccessToken(authorizationCode, TestCredentials.Client_Secret);

            MyAssert.HasNoError(authConnector);
            Assert.IsNotNull(token);
        }
예제 #14
0
        public void Test_SIE_ExportData()
        {
            var connector = new SIEConnector();

            var data = connector.ExportSIE(SIEType.SIE3);

            MyAssert.HasNoError(connector);
            Assert.IsTrue(data.Length > 0);
        }
        public void Test_Issue98_fixed() // Origins from https://github.com/FortnoxAB/csharp-api-sdk/issues/98
        {
            #region Arrange

            var tmpCustomer = new CustomerConnector().Create(new Customer()
            {
                Name = "TmpCustomer", CountryCode = "SE", City = "Testopolis"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", Type = ArticleType.Stock, PurchasePrice = 100
            });

            #endregion Arrange

            IInvoiceConnector connector = new InvoiceConnector();

            var largeId = (long)2 * int.MaxValue + TestUtils.RandomInt();

            var newInvoice = new Invoice()
            {
                DocumentNumber = largeId,
                CustomerNumber = tmpCustomer.CustomerNumber,
                InvoiceDate    = new DateTime(2019, 1, 20), //"2019-01-20",
                DueDate        = new DateTime(2019, 2, 20), //"2019-02-20",
                InvoiceType    = InvoiceType.CashInvoice,
                PaymentWay     = PaymentWay.Cash,
                Comments       = "TestInvoice",
                InvoiceRows    = new List <InvoiceRow>()
                {
                    new InvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 10, Price = 100
                    },
                    new InvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 20, Price = 100
                    },
                    new InvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 15, Price = 100
                    }
                }
            };

            var createdInvoice = connector.Create(newInvoice);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(largeId, createdInvoice.DocumentNumber);

            #region Delete arranged resources

            new CustomerConnector().Delete(tmpCustomer.CustomerNumber);
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);

            #endregion Delete arranged resources
        }
예제 #16
0
        public void Test_Account_CRUD()
        {
            var connector = new AccountConnector();

            if (connector.Get("8454") != null) //Delete if already exists
            {
                connector.Delete("8454");
            }

            #region CREATE
            var newAccount = new Account
            {
                Description        = "Test Account",
                Active             = false,
                Number             = "8454",
                CostCenterSettings = CostCenterSettingsValue.ALLOWED,
                ProjectSettings    = ProjectSettingsValue.ALLOWED,
                SRU = 123
            };

            //Act
            var createdAccount = connector.Create(newAccount);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("Test Account", createdAccount.Description);

            #endregion CREATE

            #region UPDATE

            createdAccount.Description = "Updated Test Account";

            var updatedAccount = connector.Update(createdAccount);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("Updated Test Account", updatedAccount.Description);

            #endregion UPDATE

            #region READ / GET

            var retrievedAccount = connector.Get(createdAccount.Number);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("Updated Test Account", retrievedAccount.Description);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdAccount.Number);
            MyAssert.HasNoError(connector);

            retrievedAccount = connector.Get(createdAccount.Number);
            Assert.AreEqual(null, retrievedAccount, "Entity still exists after Delete!");

            #endregion DELETE
        }
예제 #17
0
        public void Test_TooManyRequests_fixed()
        {
            var connector = new VoucherConnector();

            for (int i = 0; i < 40; i++)
            {
                connector.Limit = 2;
                connector.Find();
                MyAssert.HasNoError(connector);
            }
        }
예제 #18
0
        public void Test_Currency_CRUD()
        {
            var connector = new CurrencyConnector();

            //Random currency code is not accepted by the server, therefore "SKK" is used.
            if (connector.Get("SKK") != null) //Delete currency if already exists
            {
                connector.Delete("SKK");
            }

            #region CREATE
            var newCurrency = new Currency()
            {
                Description = "TestCurrency",
                Code        = "SKK",
                BuyRate     = 1.11m,
                SellRate    = 1.21m
            };


            var createdCurrency = connector.Create(newCurrency);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(createdCurrency.Description, "TestCurrency");

            #endregion CREATE

            #region UPDATE

            createdCurrency.Description = "UpdatedTestCurrency";

            var updatedCurrency = connector.Update(createdCurrency);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestCurrency", updatedCurrency.Description);

            #endregion UPDATE

            #region READ / GET

            var retrievedCurrency = connector.Get(createdCurrency.Code);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestCurrency", retrievedCurrency.Description);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdCurrency.Code);
            MyAssert.HasNoError(connector);

            retrievedCurrency = connector.Get(createdCurrency.Code);
            Assert.AreEqual(null, retrievedCurrency, "Entity still exists after Delete!");

            #endregion DELETE
        }
예제 #19
0
        public void Test_Supplier_CRUD()
        {
            var connector = new SupplierConnector();

            #region CREATE
            var newSupplier = new Supplier()
            {
                Name        = "TestSupplier",
                Address1    = "TestStreet 1",
                Address2    = "TestStreet 2",
                ZipCode     = "01010",
                City        = "Testopolis",
                CountryCode = "SE", //CountryCode needs to be valid
                Email       = "*****@*****.**",
                Active      = false,
                Bank        = "TestBank",
                Currency    = "SEK",
                Phone1      = "01011111345",
            };

            var createdSupplier = connector.Create(newSupplier);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(createdSupplier.Name, "TestSupplier");

            #endregion CREATE

            #region UPDATE

            createdSupplier.Name = "UpdatedTestSupplier";

            var updatedSupplier = connector.Update(createdSupplier);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestSupplier", updatedSupplier.Name);

            #endregion UPDATE

            #region READ / GET

            var retrievedSupplier = connector.Get(createdSupplier.SupplierNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestSupplier", retrievedSupplier.Name);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdSupplier.SupplierNumber);
            MyAssert.HasNoError(connector);

            retrievedSupplier = connector.Get(createdSupplier.SupplierNumber);
            Assert.AreEqual(null, retrievedSupplier, "Entity still exists after Delete!");

            #endregion DELETE
        }
예제 #20
0
        public void Test_SIE_ExportToFile()
        {
            var tmpPath   = TestUtils.GetTempFilePath();
            var connector = new SIEConnector();

            connector.ExportSIE(SIEType.SIE3, tmpPath);
            MyAssert.HasNoError(connector);
            Assert.IsTrue(File.Exists(tmpPath) && new FileInfo(tmpPath).Length > 0);

            File.Delete(tmpPath);
        }
예제 #21
0
        public void Test_Article_CRUD()
        {
            var connector = new ArticleConnector();

            #region CREATE
            var newArticle = new Article
            {
                Description   = "Test Article",
                Height        = 60,
                Width         = 150,
                Type          = ArticleType.STOCK,
                PurchasePrice = 2499.50m,
                FreightCost   = "200",
                OtherCost     = "210",
                Note          = "Definitely not worth the price."
            };

            //Act
            var createdArticle = connector.Create(newArticle);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("Test Article", createdArticle.Description);

            #endregion CREATE

            #region UPDATE

            createdArticle.Description = "Updated Test Article";

            var updatedArticle = connector.Update(createdArticle);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("Updated Test Article", updatedArticle.Description);

            #endregion UPDATE

            #region READ / GET

            var retrievedArticle = connector.Get(createdArticle.ArticleNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("Updated Test Article", retrievedArticle.Description);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdArticle.ArticleNumber);
            MyAssert.HasNoError(connector);

            retrievedArticle = connector.Get(createdArticle.ArticleNumber);
            Assert.AreEqual(null, retrievedArticle, "Entity still exists after Delete!");

            #endregion DELETE
        }
예제 #22
0
        public void TestConnection_GlobalCredentials_Set()
        {
            //Arrange
            ConnectionCredentials.AccessToken  = TestCredentials.Access_Token;
            ConnectionCredentials.ClientSecret = TestCredentials.Client_Secret;

            //Act
            ICustomerConnector connector = new CustomerConnector();

            var customers = connector.Find();

            MyAssert.HasNoError(connector);
            Assert.IsNotNull(customers);
        }
예제 #23
0
        public void Test_Project_CRUD()
        {
            var connector = new ProjectConnector();

            #region CREATE
            var newProject = new Project()
            {
                Description   = "TestProject",
                Status        = Status.ONGOING,
                StartDate     = new DateTime(2019, 10, 10).ToString(APIConstants.DateFormat),
                EndDate       = new DateTime(2021, 10, 10).ToString(APIConstants.DateFormat),
                ProjectLeader = "TestProjectLeader",
                ContactPerson = "TestContactPerson",
                Comments      = "TestComments"
            };

            var createdProject = connector.Create(newProject);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(createdProject.Description, "TestProject");

            #endregion CREATE

            #region UPDATE

            createdProject.Description = "UpdatedTestProject";

            var updatedProject = connector.Update(createdProject);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestProject", updatedProject.Description);

            #endregion UPDATE

            #region READ / GET

            var retrievedProject = connector.Get(createdProject.ProjectNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestProject", retrievedProject.Description);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdProject.ProjectNumber);
            MyAssert.HasNoError(connector);

            retrievedProject = connector.Get(createdProject.ProjectNumber);
            Assert.AreEqual(null, retrievedProject, "Entity still exists after Delete!");

            #endregion DELETE
        }
예제 #24
0
        public void Test_ReadOnlyProperty_Deserialized()
        {
            var connector = new CustomerConnector();

            var createdCustomer = connector.Create(new Customer()
            {
                Name = "TestUser", CountryCode = "SE"
            });

            MyAssert.HasNoError(connector);
            Assert.AreEqual("Sverige", createdCustomer.Country);

            connector.Delete(createdCustomer.CustomerNumber);
            MyAssert.HasNoError(connector);
        }
        public void Test_issue61_fixed() // Origins from https://github.com/FortnoxAB/csharp-api-sdk/issues/61
        {
            var connector  = new ArticleConnector();
            var newArticle = connector.Create(new Article()
            {
                Description = "TestArticle", FreightCost = 10, OtherCost = 10, CostCalculationMethod = "MANUAL"
            });

            MyAssert.HasNoError(connector);

            //NOTE: Server does not create the properties FreightCost, OtherCost and CostCalculationMethod
            //Assert.AreEqual("10", newArticle.FreightCost); //Always fails
            connector.Delete(newArticle.ArticleNumber);
            MyAssert.HasNoError(connector);
        }
예제 #26
0
        public void Test_EmptyNestedObject()
        {
            var connector = new CustomerConnector();

            var createdCustomer = connector.Create(new Customer()
            {
                Name = "TestUser",
                DefaultDeliveryTypes = new InvoiceDefaultDeliveryTypes() //Empty Object
            });

            MyAssert.HasNoError(connector);

            connector.Delete(createdCustomer.CustomerNumber);
            MyAssert.HasNoError(connector);
        }
예제 #27
0
        public void Test_RateLimiter_NoError()
        {
            var connector = new CustomerConnector();

            var watch = new Stopwatch();

            watch.Start();
            for (var i = 0; i < 200; i++)
            {
                connector.Search.City = TestUtils.RandomString(); //Needs to be random to make unique GET request
                connector.Find();
                MyAssert.HasNoError(connector);
            }

            watch.Stop();
            Console.WriteLine(@"Total time: " + watch.ElapsedMilliseconds);
        }
예제 #28
0
        public void Test_Find_ParamsNotAdded()
        {
            var connector = new CustomerConnector();

            connector.Name = "TestName";

            connector.Find();
            MyAssert.HasNoError(connector);
            Assert.IsFalse(connector.RequestUriString.Contains("city="));
            Assert.IsFalse(connector.RequestUriString.Contains("filter="));
            Assert.IsFalse(connector.RequestUriString.Contains("sortby="));
            Assert.IsFalse(connector.RequestUriString.Contains("sortorder="));
            Assert.IsFalse(connector.RequestUriString.Contains("lastmodified="));
            Assert.IsFalse(connector.RequestUriString.Contains("limit="));
            Assert.IsFalse(connector.RequestUriString.Contains("offset="));
            Assert.IsFalse(connector.RequestUriString.Contains("page="));
        }
예제 #29
0
        public void Test_AllInOnePage()
        {
            //To make this test make sense, over 100 customers must exist, ideally over 500

            ICustomerConnector connector = new CustomerConnector();
            var result = connector.Find();

            MyAssert.HasNoError(connector);
            Assert.IsTrue(result.TotalPages > 1);

            connector.Search.Limit = APIConstants.Unlimited;
            var allInOneResult = connector.Find();

            MyAssert.HasNoError(connector);

            Assert.AreEqual(1, allInOneResult.TotalPages);
            Assert.AreEqual(result.TotalResources, allInOneResult.Entities.Count);
        }
예제 #30
0
        public void Test_TooManyRequests_fixed()
        {
            var connector = new VoucherConnector();

            connector.Limit = 2;

            var watch = new Stopwatch();

            watch.Start();
            for (int i = 0; i < 40; i++)
            {
                connector.Find();
                MyAssert.HasNoError(connector);
            }

            watch.Stop();
            Console.WriteLine(@"Total time: " + watch.ElapsedMilliseconds);
        }