Beispiel #1
0
        public void PostingInterests_OnePosting()
        {
            SavingsBookProduct product = new SavingsBookProduct
            {
                Id = 1,
                InterestBase = OSavingInterestBase.Daily,
                InterestFrequency = OSavingInterestFrequency.EndOfWeek,
                Periodicity = new InstallmentType("Weekly", 7, 0)

            };
            User user = new User(){Id=1};

            SavingBookContract saving = new SavingBookContract(
                                                                ApplicationSettings.GetInstance(""),
                                                                user,
                                                                new DateTime(2009, 01, 01),
                                                                null)
                                                                {
                                                                    Product = product, InterestRate = 0.1
                                                                };
            saving.NextMaturity = saving.GetNextMaturity(saving.CreationDate, saving.Periodicity);
            saving.FirstDeposit(1000, saving.CreationDate, 0, user, new Teller());
            List<SavingInterestsPostingEvent> list = new List<SavingInterestsPostingEvent>();
            List<SavingInterestsPostingEvent> postingEvents = new List<SavingInterestsPostingEvent>();
            DateTime closureDate = new DateTime(2009, 01, 05);
            List<SavingInterestsAccrualEvent> accrualEvents = saving.CalculateInterest(closureDate, user);
            foreach (var accrualEvent in accrualEvents)
            {
                saving.Events.Add(accrualEvent);
            }

            list = saving.PostingInterests(saving.NextMaturity.Value, user);
            postingEvents.AddRange(list);
            foreach (var postingEvent in list)
            {
                saving.Events.Add(postingEvent);
            }

            Assert.AreEqual( 1, postingEvents.Count);
        }