示例#1
0
        public void GildedDressCanGenerateCorrectDepreciation()
        {
            var thisMonth      = DateTime.Now.AddDays(-1);
            var addedThisMonth = new Dress(thisMonth)
            {
                Name = "A", Price = 10
            };

            var tenWeeksAgo           = DateTime.Now.AddDays(-70).AddTicks(-1);
            var priceReducesThisMonth = new Dress(tenWeeksAgo)
            {
                Name = "A", Price = 10
            };

            var stockItems = new List <Dress> {
                addedThisMonth, priceReducesThisMonth
            };

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

            financialReport.ValueOfStock.Should().Be(17.5M);
            financialReport.Depreciation.Should().Be(2.5M);
        }
示例#2
0
        public void GildedDressCanGenerateZeroDepreciation()
        {
            var stockAdded = DateTime.Now.AddDays(-1);
            var stockItems = new List <Dress> {
                new Dress(stockAdded)
                {
                    Name = "A", Price = 10
                }
            };

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

            financialReport.ValueOfStock.Should().Be(10);
            financialReport.Depreciation.Should().Be(0);
        }
示例#3
0
        public void TheGildedDressDecreasesPriceAfterTenWeeks()
        {
            var stockAdded = DateTime.Now.AddDays(-100);
            var stockItems = new List <Dress> {
                new Dress(stockAdded)
                {
                    Name = "A", Price = 10
                }
            };

            var tenWeekslater      = stockAdded.AddDays(70);
            var stockAfterTenWeeks = GildedStockManagerFactory
                                     .GildedDress()
                                     .WithStock(stockItems)
                                     .GetStockList(tenWeekslater);

            var stockItem = stockAfterTenWeeks.Single();

            stockItem.Name.Should().Be("A");
            stockItem.Price.Should().Be(10 * 0.75M);
        }