internal void AddTransactionsOld(FixedRateLoan testSubject) { //monthly payments testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-360), new Pecuniam(-450.0M)); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-240), new Pecuniam(-454.0M)); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-300), new Pecuniam(-452.0M)); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-270), new Pecuniam(-453.0M)); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-210), new Pecuniam(-455.0M)); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-330), new Pecuniam(-451.0M)); //charges testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-365), new Pecuniam(8000.0M)); testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-350), new Pecuniam(164.4M)); testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-198), new Pecuniam(165.4M)); testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-24), new Pecuniam(166.4M)); testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-74), new Pecuniam(167.4M)); testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-88), new Pecuniam(168.4M)); testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-92), new Pecuniam(169.4M)); testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-121), new Pecuniam(170.4M)); testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-180), new Pecuniam(171.4M)); testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-142), new Pecuniam(172.4M)); testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-155), new Pecuniam(173.4M)); }
public void TestGetStatus() { var testSubject = new FixedRateLoan(DateTime.UtcNow.AddYears(-3).Date, 0.0125F); AddTransactionsOld(testSubject); AddRecentPayments(testSubject); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-15), new Pecuniam(-461.0M)); var testResult = testSubject.GetStatus(DateTime.UtcNow); Assert.AreEqual(SpStatus.Current, testResult); testSubject = new FixedRateLoan(DateTime.UtcNow.AddYears(-3).Date, 0.0125F); testResult = testSubject.GetStatus(DateTime.UtcNow); Assert.AreEqual(SpStatus.NoHistory, testResult); testSubject.Terminus = DateTime.UtcNow.AddDays(-1).Date; testSubject.Closure = ClosedCondition.ClosedWithZeroBalance; testResult = testSubject.GetStatus(DateTime.UtcNow); Assert.AreEqual(SpStatus.Closed, testResult); testSubject.Terminus = DateTime.UtcNow.AddDays(1).Date; testSubject.Closure = ClosedCondition.ClosedWithZeroBalance; testResult = testSubject.GetStatus(DateTime.UtcNow); Assert.AreNotEqual(SpStatus.Closed, testResult); testSubject = new FixedRateLoan(DateTime.UtcNow.AddYears(-3).Date, 0.0125F); testSubject.DueFrequency = new TimeSpan(28, 0, 0, 0); AddTransactionsOld(testSubject); AddRecentPayments(testSubject); testResult = testSubject.GetStatus(DateTime.UtcNow); Assert.AreEqual(SpStatus.Late, testResult); testSubject.DueFrequency = new TimeSpan(45, 0, 0, 0); testResult = testSubject.GetStatus(DateTime.UtcNow); Assert.AreEqual(SpStatus.Current, testResult); //account opened then over paid off - better be current testSubject = new FixedRateLoan(DateTime.UtcNow.AddYears(-3).Date, 0.0125F); testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-365), new Pecuniam(8000.0M)); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-360), new Pecuniam(-9000.0M)); testResult = testSubject.GetStatus(DateTime.UtcNow); Assert.AreEqual(SpStatus.Current, testResult); //immediate payment didn't cover it cause of per diem interest testSubject = new FixedRateLoan(DateTime.UtcNow.AddYears(-3).Date, 0.0125F) { Rate = 0.0825f }; testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-40), new Pecuniam(8000.0M)); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-35), new Pecuniam(-8000.0M)); testResult = testSubject.GetStatus(DateTime.UtcNow); Assert.AreEqual(SpStatus.Late, testResult); }
public void TestGetDelinquency() { var testSubject = new FixedRateLoan(DateTime.UtcNow.AddYears(-3).Date, 0.0125F); AddTransactionsOld(testSubject); AddRecentPayments(testSubject); var testResult = testSubject.GetDelinquency(DateTime.UtcNow); Assert.IsNull(testResult); testSubject = new FixedRateLoan(DateTime.UtcNow.AddYears(-3).Date, 0.0125F); testSubject.AddPositiveValue(DateTime.UtcNow.AddDays(-365), new Pecuniam(8000.0M)); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-180 - testSubject.DueFrequency.Value.TotalDays), new Pecuniam(-461.0M)); var dt = DateTime.UtcNow; testResult = testSubject.GetDelinquency(dt); Assert.AreEqual(PastDue.HundredAndEighty, testResult); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-179 - testSubject.DueFrequency.Value.TotalDays), new Pecuniam(-461.0M)); testResult = testSubject.GetDelinquency(dt); Assert.AreEqual(PastDue.Ninety, testResult); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-90 - testSubject.DueFrequency.Value.TotalDays), new Pecuniam(-461.0M)); testResult = testSubject.GetDelinquency(dt); Assert.AreEqual(PastDue.Ninety, testResult); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-89 - testSubject.DueFrequency.Value.TotalDays), new Pecuniam(-461.0M)); testResult = testSubject.GetDelinquency(dt); Assert.AreEqual(PastDue.Sixty, testResult); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-60 - testSubject.DueFrequency.Value.TotalDays), new Pecuniam(-461.0M)); testResult = testSubject.GetDelinquency(dt); Assert.AreEqual(PastDue.Sixty, testResult); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-59 - testSubject.DueFrequency.Value.TotalDays), new Pecuniam(-461.0M)); testResult = testSubject.GetDelinquency(dt); Assert.AreEqual(PastDue.Thirty, testResult); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-30 - testSubject.DueFrequency.Value.TotalDays), new Pecuniam(-461.0M)); testResult = testSubject.GetDelinquency(dt); Assert.AreEqual(PastDue.Thirty, testResult); testSubject.AddNegativeValue(DateTime.UtcNow.AddDays(-29 - testSubject.DueFrequency.Value.TotalDays), new Pecuniam(-461.0M)); testResult = testSubject.GetDelinquency(dt); Assert.IsNull(testResult); }