public void TestMirrBasic() { Mirr mirr = new Mirr(); double mirrValue; double financeRate = 0.12; double reinvestRate = 0.1; double[] values = { -120000d, 39000d, 30000d, 21000d, 37000d, 46000d, reinvestRate, financeRate }; try { mirrValue = mirr.Evaluate(values); } catch (EvaluationException e) { throw new AssertFailedException("MIRR should not failed with these parameters" + e); } Assert.AreEqual(0.126094130366, mirrValue, 0.0000000001, "mirr"); reinvestRate = 0.05; financeRate = 0.08; values = new double[] { -7500d, 3000d, 5000d, 1200d, 4000d, reinvestRate, financeRate }; try { mirrValue = mirr.Evaluate(values); } catch (EvaluationException e) { throw new AssertFailedException("MIRR should not failed with these parameters" + e); } Assert.AreEqual(0.18736225093, mirrValue, 0.0000000001, "mirr"); reinvestRate = 0.065; financeRate = 0.1; values = new double[] { -10000, 3400d, 6500d, 1000d, reinvestRate, financeRate }; try { mirrValue = mirr.Evaluate(values); } catch (EvaluationException e) { throw new AssertFailedException("MIRR should not failed with these parameters" + e); } Assert.AreEqual(0.07039493966, mirrValue, 0.0000000001, "mirr"); reinvestRate = 0.07; financeRate = 0.01; values = new double[] { -10000d, -3400d, -6500d, -1000d, reinvestRate, financeRate }; try { mirrValue = mirr.Evaluate(values); } catch (EvaluationException e) { throw new AssertFailedException("MIRR should not failed with these parameters" + e); } Assert.AreEqual(-1, mirrValue, 0.0, "mirr"); }
public void TestMirrErrors_expectDIV0() { Mirr mirr = new Mirr(); double reinvestRate = 0.05; double financeRate = 0.08; double[] incomes = { 120000d, 39000d, 30000d, 21000d, 37000d, 46000d, reinvestRate, financeRate }; try { mirr.Evaluate(incomes); } catch (EvaluationException e) { Assert.AreEqual(ErrorEval.DIV_ZERO, e.GetErrorEval()); return; } throw new AssertFailedException("MIRR should failed with all these positives values"); }