Ejemplo n.º 1
0
        public void GildedTinCanCanGenerateCorrectDepreciation()
        {
            var twoYearsAgo             = DateTime.Now.AddYears(-2);
            var expiredBeforeThisReport = new TinnedFood(twoYearsAgo)
            {
                Name = "A", Price = 10
            };

            var oneYearAgo = DateTime.Now.AddYears(-1).AddTicks(-1);
            var expiredDuringThisReport = new TinnedFood(oneYearAgo)
            {
                Name = "A", Price = 15
            };

            var yesterday  = DateTime.Now.AddDays(-1);
            var notExpired = new TinnedFood(yesterday)
            {
                Name = "A", Price = 20
            };

            var stockItems = new List <TinnedFood>
            {
                expiredBeforeThisReport,
                expiredDuringThisReport,
                notExpired
            };

            var financialReport = GildedStockManagerFactory
                                  .GildedTinCan()
                                  .WithStock(stockItems)
                                  .FinancialReportAsAt(DateTime.Now);

            financialReport.ValueOfStock.Should().Be(20M);
            financialReport.Depreciation.Should().Be(15M);
        }
Ejemplo n.º 2
0
        public void TheGildedTinCanCannotSellYearOldPlusTins()
        {
            var oneYearAndOneDayAgo = DateTime.Now.AddYears(-1).AddDays(-1);
            var twoMonthsAgo        = DateTime.Now.AddMonths(-2);
            var stock = new List <TinnedFood>
            {
                new TinnedFood(oneYearAndOneDayAgo)
                {
                    Name = "old", Price = 10
                },
                new TinnedFood(twoMonthsAgo)
                {
                    Name = "new", Price = 10
                }
            };

            var stockNow = GildedStockManagerFactory
                           .GildedTinCan()
                           .WithStock(stock)
                           .GetStockList(DateTime.Now);

            var stockItem = stockNow.Single();

            stockItem.Name.Should().Be("new");
        }