public void TestInsertAndGetByUidWithDecimalQuantity()
        {
            CrudProxy proxy             = new InventoryAdjustmentProxy();
            InventoryAdjustmentDto dto1 = this.GetInventoryAdjustment2();

            proxy.Insert(dto1);

            Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save.");

            InventoryAdjustmentDto dto2 = (InventoryAdjustmentDto)proxy.GetByUid(dto1.Uid);

            AssertEqual(dto1, dto2);
        }
        public void TestUpdate()
        {
            CrudProxy proxy             = new InventoryAdjustmentProxy();
            InventoryAdjustmentDto dto1 = this.GetInventoryAdjustment1();

            proxy.Insert(dto1);

            Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save.");
            dto1.Summary = "Updated inventory adjustment";
            proxy.Update(dto1);

            InventoryAdjustmentDto dto2 = (InventoryAdjustmentDto)proxy.GetByUid(dto1.Uid);

            AssertEqual(dto1, dto2);
        }
        public void TestDelete()
        {
            CrudProxy proxy             = new InventoryAdjustmentProxy();
            InventoryAdjustmentDto dto1 = this.GetInventoryAdjustment1();

            proxy.Insert(dto1);

            proxy.DeleteByUid(dto1.Uid);

            try
            {
                proxy.GetByUid(dto1.Uid);
                throw new Exception("The expected exception was not thrown.");
            }
            catch (RestException ex)
            {
                Assert.AreEqual("RecordNotFoundException", ex.Type, "Incorrect exception type.");
            }
        }
        public void TestUpdateWithDecimalQuantity()
        {
            CrudProxy proxy             = new InventoryAdjustmentProxy();
            InventoryAdjustmentDto dto1 = this.GetInventoryAdjustment2();

            proxy.Insert(dto1);

            Assert.IsTrue(dto1.Uid > 0, "Uid must be > 0 after save.");
            dto1.Summary = "Updated inventory adjustment";
            var adjustmentItem = (InventoryAdjustmentItemDto)dto1.Items[0];

            adjustmentItem.Quantity          = 1.5M;
            adjustmentItem.UnitPriceExclTax  = 100.00M;
            adjustmentItem.TotalPriceExclTax = 150.00M;

            proxy.Update(dto1);

            InventoryAdjustmentDto dto2 = (InventoryAdjustmentDto)proxy.GetByUid(dto1.Uid);

            AssertEqual(dto1, dto2);
        }
        public void TestUpdatingStockOnHand()
        {
            CrudProxy proxy            = new InventoryAdjustmentProxy();
            InventoryAdjustmentDto dto = new InventoryAdjustmentDto();

            dto.Date    = DateTime.Now;
            dto.Summary = "Update stock on hand only";

            InventoryAdjustmentItemDto dtoItem = new InventoryAdjustmentItemDto();

            dtoItem.InventoryItemUid = this.AsusLaptop.Uid;
            dtoItem.Quantity         = 5;
            dto.Items.Add(dtoItem);

            proxy.Insert(dto);

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after save.");

            InventoryAdjustmentDto dtoFromDB = (InventoryAdjustmentDto)proxy.GetByUid(dto.Uid);

            AssertEqual(dto, dtoFromDB);
        }
        public void TestUpdatingTotal()
        {
            CrudProxy proxy            = new InventoryAdjustmentProxy();
            InventoryAdjustmentDto dto = new InventoryAdjustmentDto();

            dto.Date = DateTime.Now;

            InventoryAdjustmentItemDto dtoItem = new InventoryAdjustmentItemDto();

            dtoItem.InventoryItemUid  = this.AsusLaptop.Uid;
            dtoItem.Quantity          = 10;
            dtoItem.AccountUid        = this.AssetInventory.Uid;
            dtoItem.UnitPriceExclTax  = 150.00M;
            dtoItem.TotalPriceExclTax = 1500.00M;
            dto.Items.Add(dtoItem);

            proxy.Insert(dto);

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after save.");

            dto         = new InventoryAdjustmentDto();
            dto.Date    = DateTime.Now;
            dto.Summary = "Update Total only";

            dtoItem = new InventoryAdjustmentItemDto();
            dtoItem.InventoryItemUid  = this.AsusLaptop.Uid;
            dtoItem.AccountUid        = this.AssetInventory.Uid;
            dtoItem.TotalPriceExclTax = 1800.00M;
            dto.Items.Add(dtoItem);

            proxy.Insert(dto);

            Assert.IsTrue(dto.Uid > 0, "Uid must be > 0 after save.");

            InventoryAdjustmentDto dtoFromDB = (InventoryAdjustmentDto)proxy.GetByUid(dto.Uid);

            AssertEqual(dto, dtoFromDB);
        }