Exemplo n.º 1
0
        public void FindPurchaseOrderTotalTest()
        {
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser, true);

            var poh   = GetTestPurchaseOrderHeader(testCompany, testUser, 1);
            var model = PurchasingService.FindPurchaseOrderDetailListModel(poh);

            var     pod        = model.Items.First();
            decimal totalValue = pod.OrderQty.Value * pod.UnitPriceExTax.Value;

            for (int i = 0; i < 16; i++)
            {
                pod          = model.Items.First();
                pod.Id       = 0;
                pod.OrderQty = RandomInt();
                totalValue  += pod.OrderQty.Value * pod.UnitPriceExTax.Value;

                var error = PurchasingService.InsertOrUpdatePurchaseOrderDetail(pod, testUser, "");
                Assert.IsTrue(!error.IsError, error.Message);
            }

            var result = PurchasingService.FindPurchaseOrderTotal(poh);

            Assert.IsTrue(result == totalValue, $"Error: {result} was returned when {totalValue} was expected");
        }