Пример #1
0
        public void TestGetExpectedRent()
        {
            //most straight foward example
            var firstOfYear = new DateTime(DateTime.Today.Year, 1, 1);

            var testSubject = new Rent(null, firstOfYear, 12, new Pecuniam(700), new Pecuniam(0));

            var testResult = testSubject.GetExpectedTotalRent(new DateTime(DateTime.Today.Year, 3, 1));

            //only two whole months have passed but rent's due on the first
            Assert.AreEqual(new Pecuniam(700 * 3), testResult);

            //after 15 days only first rent is due
            testResult = testSubject.GetExpectedTotalRent(firstOfYear.AddDays(15));
            Assert.AreEqual(new Pecuniam(700), testResult);

            //back the signing date to middle of Dec
            var newSigningDate = firstOfYear.AddDays(-16);

            testSubject = new Rent(null, newSigningDate, 12, new Pecuniam(700), new Pecuniam(0));

            //this should be only the pro-rated amount, first full month is due tommorrow
            testResult = testSubject.GetExpectedTotalRent(newSigningDate.AddDays(15));
            Assert.AreEqual(new Pecuniam(350), testResult);

            //add another day - this should be pro-rated amount plus first month
            testResult = testSubject.GetExpectedTotalRent(firstOfYear.AddDays(16));
            Assert.AreEqual(new Pecuniam(350 + 700), testResult);

            //move to first of Feb - this should be pro-rated amount plus two months rent
            testResult = testSubject.GetExpectedTotalRent(new DateTime(DateTime.Today.Year, 2, 1));
            Assert.AreEqual(new Pecuniam(350 + 700 * 2), testResult);

            //middle of march -should be prorated amount plus three months
            testResult = testSubject.GetExpectedTotalRent(new DateTime(DateTime.Today.Year, 3, 15));
            Assert.AreEqual(new Pecuniam(350 + 700 * 3), testResult);

            //on the last day of march - should still be the same
            testResult = testSubject.GetExpectedTotalRent(new DateTime(DateTime.Today.Year, 4, 1).AddDays(-1));
            Assert.AreEqual(new Pecuniam(350 + 700 * 3), testResult);
        }