Example #1
0
        public async void When_FullDepreciationIsApplied_Expect_CurrentPriceEqualsOne(int id)
        {
            var item = await _inventoryItemRepository.GetById(id);

            var category = await _inventoryCategoryRepository.GetById(item.InventoryCategoryId);

            var lifeExpectancyInDays = _timeService.ConvertYearsToDays((int)category.Deprecation);

            for (int i = 0; i < lifeExpectancyInDays; i++)
            {
                await _backgroundInventoryUpdater.ApplyDepreciationToInventoryItems();
            }

            var itemAfterFullDepreciation = await _inventoryItemRepository.GetById(id);

            var priceAfterFullDepreciation = Math.Round(itemAfterFullDepreciation.CurrentPrice);

            Assert.True(priceAfterFullDepreciation == 1, "Failed to apply full depreciation.");
        }