コード例 #1
0
ファイル: StockTest.cs プロジェクト: Novakov/MedicinePlan
        public void CannotBeReducedBelowZero()
        {
            // arrange
            var initialStock = new Stock(100, new DateTime(2014, 1, 1));

            // act
            var reduced = initialStock.Reduce(120, new DateTime(2014, 2, 2));

            // assert
            Assert.That(reduced, Is.EqualTo(new Stock(0, new DateTime(2014, 2, 2))));
        }
コード例 #2
0
ファイル: PlanTest.cs プロジェクト: Novakov/MedicinePlan
        public void ShouldReturnProperExhaustionDateWithOneDosage()
        {
            // arrange
            var plan = new Plan();
            var startDate = new DateTime(2014, 1, 1);
            plan.RegisterDosage(startDate, FivePerDay);
            var stock = new Stock(100, startDate);

            // act
            var exhaustionDate = plan.CalculateExhaustionDate(stock);

            // assert
            Assert.That(exhaustionDate, Is.EqualTo(new DateTime(2014, 1, 20)));
        }
コード例 #3
0
ファイル: PlanTest.cs プロジェクト: Novakov/MedicinePlan
        public void ShouldIgnoreDosagesAfterEndDateWhenCalculatingRemaining()
        {
            // arrange
            var plan = new Plan();
            var startDate = new DateTime(2014, 1, 1);
            plan.RegisterDosage(startDate, TenPerDay);
            plan.RegisterDosage(new DateTime(2014, 1, 10), FivePerDay);

            var initialStock = new Stock(100, startDate);

            // act
            var remaining = plan.CalculateRemaining(initialStock, new DateTime(2014, 1, 5));

            // assert
            Assert.That(remaining, Is.EqualTo(new Stock(60, new DateTime(2014, 1, 5))));
        }
コード例 #4
0
ファイル: PlanTest.cs プロジェクト: Novakov/MedicinePlan
        public void ShouldIgnoreDosagesPreviousToStartDate()
        {
            // arrange
            var plan = new Plan();
            var startDate = new DateTime(2014, 1, 1);
            plan.RegisterDosage(startDate.AddDays(-7), TenPerDay);
            plan.RegisterDosage(startDate, FivePerDay);

            var initialStock = new Stock(100, startDate);

            // act
            var remaining = plan.CalculateRemaining(initialStock, new DateTime(2014, 1, 5));
            var exhaustionDate = plan.CalculateExhaustionDate(initialStock);

            // assert
            Assert.That(remaining, Is.EqualTo(new Stock(80, new DateTime(2014, 1, 5))));
            Assert.That(exhaustionDate, Is.EqualTo(new DateTime(2014, 1, 20)));
        }
コード例 #5
0
ファイル: PlanTest.cs プロジェクト: Novakov/MedicinePlan
        public void ShouldReturnProperStockWithOneDosage()
        {
            // arrange
            var plan = new Plan();
            var startDate = new DateTime(2014, 1, 1);
            plan.RegisterDosage(startDate, FivePerDay);

            var calculateFor = new DateTime(2014, 1, 5);
            var initialStock = new Stock(100, startDate);

            // act
            var remaining = plan.CalculateRemaining(initialStock, calculateFor);

            // assert
            Assert.That(remaining, Is.EqualTo(new Stock(80, calculateFor)));
        }
コード例 #6
0
ファイル: PlanTest.cs プロジェクト: Novakov/MedicinePlan
        public void ShouldTakeIntoAccountDosagesOverlapingWithStartDate()
        {
            // arrange
            var plan = new Plan();
            var startDate = new DateTime(2014, 1, 1);
            plan.RegisterDosage(startDate.AddDays(-7), TenPerDay);
            plan.RegisterDosage(startDate.AddDays(1), FivePerDay);

            var initialStock = new Stock(100, startDate);

            // act
            var remaining = plan.CalculateRemaining(initialStock, new DateTime(2014, 1, 5));
            var exhaustionDate = plan.CalculateExhaustionDate(initialStock);

            // assert
            Assert.That(remaining, Is.EqualTo(new Stock(75, new DateTime(2014, 1, 5))));
            Assert.That(exhaustionDate, Is.EqualTo(new DateTime(2014, 1, 19)));
        }
コード例 #7
0
 public StockTest()
 {
     st = Enhancer.Enhancer.Build <Stock>("Apple", "Dow Jones");
 }