Esempio n. 1
0
 static void TestInvestment(double rate, double payment, int paymentCount, double presentValue = 0, double futureValue = 0, bool payAtEnd = true)
 {
     AssertEqual(futureValue, F.FutureValue(rate, payment, paymentCount, presentValue, payAtEnd));
     AssertEqual(payment, F.Payment(rate, paymentCount, presentValue, futureValue, payAtEnd));
     AssertEqual(paymentCount, F.Periods(rate, payment, presentValue, futureValue, payAtEnd));
     AssertEqual(presentValue, F.PresentValue(rate, payment, paymentCount, futureValue, payAtEnd));
 }
Esempio n. 2
0
        public void T05_Periods()
        {
            AssertEqual(60.082122853761722554, F.Periods(0.01, -100, -1000, 10000, true));
            AssertEqual(59.673865674294625588, F.Periods(0.01, -100, -1000, 10000, false));
            AssertEqual(-9.5785940398131666704, F.Periods(0.01, -100, -1000, 0));
            AssertEqual(28.911809737480831494, F.Periods(0.01, 100, -1000, -2000));
            AssertEqual(8.6690930741204999513, F.Periods(0.01, 100, 1000, -2000, false));
            AssertEqual(10.802372638626807957, F.Periods(.05 / 12, -1000, 100000) / 12);
            AssertEqual(3.8598661626226451824, F.Periods(F.PeriodicRate(.025, 12), 0, -2000, 2200) / 12);
            AssertEqual(14.51957583084954867337, F.Periods(-.05 / 12, 100, -1500));
            AssertEqual(10, F.Periods(-0.06765766138943930352052, 100, -1500));
            Assert.AreEqual(0, F.Periods(0.01, 100, -1000, 1000));

            TestInvestment(0, -100, 10, 1000);
            TestInvestment(0, -100, 30, 1000, 2000);
            Assert.AreEqual(0, F.Periods(0, -100, 1000, -1000));

            Assert.AreEqual(0, F.Periods(0, 0, 1000, 1000));
            Assert.IsNaN(F.Periods(0, 0, 1000, 2000));
            Assert.IsNaN(F.Periods(0, 0, 1000, -2000));
        }