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);
        }
Exemple #2
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);
            }
        }
        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);
        }
Exemple #4
0
        public void Test_Vouchers_Find_By_Series()
        {
            //Arrange
            Thread.Sleep(2);

            var voucher1 = new Voucher()
            {
                Description     = "TestVoucher",
                Comments        = "Some comments",
                VoucherSeries   = "TST", //predefined series
                TransactionDate = new DateTime(2020, 1, 1),
                VoucherRows     = new List <VoucherRow>()
                {
                    new VoucherRow()
                    {
                        Account = 1930, Debit = 1500, Credit = 0
                    },
                    new VoucherRow()
                    {
                        Account = 1910, Debit = 0, Credit = 1500
                    }
                }
            };
            var voucher2 = new Voucher()
            {
                Description     = "TestVoucher",
                Comments        = "Some comments",
                VoucherSeries   = "TST", //predefined series
                TransactionDate = new DateTime(2020, 1, 1),
                VoucherRows     = new List <VoucherRow>()
                {
                    new VoucherRow()
                    {
                        Account = 1930, Debit = 1500, Credit = 0
                    },
                    new VoucherRow()
                    {
                        Account = 1910, Debit = 0, Credit = 1500
                    }
                }
            };
            var voucher3 = new Voucher()
            {
                Description     = "TestVoucher",
                Comments        = "Some comments",
                VoucherSeries   = "A", //predefined series
                TransactionDate = new DateTime(2020, 1, 1),
                VoucherRows     = new List <VoucherRow>()
                {
                    new VoucherRow()
                    {
                        Account = 1930, Debit = 1500, Credit = 0
                    },
                    new VoucherRow()
                    {
                        Account = 1910, Debit = 0, Credit = 1500
                    }
                }
            };

            IVoucherConnector connector = new VoucherConnector();

            voucher1 = connector.Create(voucher1);
            voucher2 = connector.Create(voucher2);
            voucher3 = connector.Create(voucher3);

            //Act
            var settings = new VoucherSearch()
            {
                LastModified  = DateTime.Now.AddSeconds(-2),
                VoucherSeries = "TST"
            };

            //Assert
            var vouchers = connector.Find(settings);

            Assert.AreEqual(2, vouchers.TotalResources);

            //Clean
            connector.Delete(voucher3.VoucherNumber, voucher3.VoucherSeries, voucher3.Year);
            connector.Delete(voucher2.VoucherNumber, voucher2.VoucherSeries, voucher2.Year);
            connector.Delete(voucher1.VoucherNumber, voucher1.VoucherSeries, voucher1.Year);
        }