Esempio n. 1
0
        public void PostingInterests_ThreePosting()
        {
//            Assert.Ignore();
            SavingsBookProduct product = new SavingsBookProduct
            {
                Id                = 1,
                InterestBase      = OSavingInterestBase.Daily,
                InterestFrequency = OSavingInterestFrequency.EndOfWeek,
                Periodicity       = new InstallmentType("Weekly", 7, 0)
            };
            User user = new User()
            {
                Id = 1
            };
            DateTime           creationDate = new DateTime(2009, 01, 01);
            DateTime           postingDate  = new DateTime(2009, 01, 26);
            SavingBookContract saving       = new SavingBookContract(
                ApplicationSettings.GetInstance(""),
                user,
                creationDate,
                null)
            {
                Product      = product,
                InterestRate = 0.1
            };

            saving.FirstDeposit(1000, saving.CreationDate, 0, user, new Teller());
            List <SavingInterestsAccrualEvent> accrualEvents = saving.CalculateInterest(postingDate, user);

            foreach (var accrualEvent in accrualEvents)
            {
                saving.Events.Add(accrualEvent);
            }
            List <SavingInterestsPostingEvent> list          = new List <SavingInterestsPostingEvent>();
            List <SavingInterestsPostingEvent> postingEvents = new List <SavingInterestsPostingEvent>();

            saving.NextMaturity = saving.GetNextMaturity(saving.CreationDate, saving.Periodicity);
            while (saving.NextMaturity <= postingDate)
            {
                list = saving.PostingInterests(saving.NextMaturity.Value, new User {
                    Id = 1
                });
                postingEvents.AddRange(list);
                foreach (var postingEvent in list)
                {
                    saving.Events.Add(postingEvent);
                }
                saving.NextMaturity = saving.GetNextMaturity(saving.NextMaturity.Value, saving.Periodicity);
            }

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