Exemple #1
0
        public void Schedule_Formatting()
        {
            var portfolio = new DebtPortfolio
            {
                new DebtInfo("A", 16345.44M, 3.25M, 225),
                new DebtInfo("B", 12000, 0, 125),
                new DebtInfo("C", 6000, 3.5M, 182),
                new DebtInfo("D", 4000, 12.25M, 50),
                new DebtInfo("E", 2000, 15.55M, 200),
                new DebtInfo("F", 1000, 22, 50),
                new DebtInfo("G", 500, 22, 50),
                new DebtInfo("H", 10, 50.3M, 250),
                new DebtInfo("I", 13000, 12, 100),
            };

            var schedule = portfolio.ToString();
            var summary  = portfolio.Summary;

            portfolio.ForEach(x => schedule.Should().Contain(x.Name));
            portfolio.ForEach(x => schedule.Should().Contain($"{x.Balance:C}"));
            portfolio.ForEach(x => schedule.Should().Contain($"{x.Rate:N}%"));
            portfolio.ForEach(x => schedule.Should().Contain($"{x.Minimum:C}"));
            portfolio.ForEach(x => schedule.Should().Contain($"{x.CurrentPayment:C}"));

            portfolio.ForEach(x => summary.Should().Contain(x.Name));
            portfolio.ForEach(x => summary.Should().Contain($"{x.Balance:C}"));
            portfolio.ForEach(x => summary.Should().Contain($"{x.Rate:N}%"));
            portfolio.ForEach(x => summary.Should().Contain($"{x.Minimum:C}"));
            portfolio.ForEach(x => summary.Should().Contain($"{x.CurrentPayment:C}"));
        }
Exemple #2
0
 private static void InitDebt()
 {
     // Use this to create initial debt file.
     portfolio = new DebtPortfolio {
         new DebtInfo("A", 12345, 3.25M, 225), new DebtInfo("B", 2180, 12M, 125),
     };
     Save();
 }
Exemple #3
0
        public void Empty()
        {
            var portfolio = new DebtPortfolio();

            portfolio.ToString().Should().Contain("No Payments");
            portfolio.Header.Should().BeEmpty();
            portfolio.Summary.Should().Contain("No Debt! Congratulations!");
            portfolio.Payments.Should().Contain("No Payments");
        }
Exemple #4
0
 private static void Main()
 {
     // Complete InitDebt and uncomment to create the initial data file.
     //InitDebt();
     portfolio = Load();
     Console.WriteLine(portfolio.Summary);
     Console.WriteLine("Schedule(s):");
     Console.WriteLine(portfolio);
 }
Exemple #5
0
        public void CreatedPortfolio()
        {
            var port = CreatePortfolio();

            port.Should().NotBeNull();
            var newPort = new DebtPortfolio(port.ToList());

            newPort.Should().NotBeNullOrEmpty();
            newPort.Should().Equals(port);
        }
Exemple #6
0
        public void Amortization_NeverChanges()
        {
            var p = new DebtPortfolio(CreatePortfolio().OrderBy(x => x.Name).ToList());
            var l = p.GetAmortization();

            p = new DebtPortfolio(CreatePortfolio().OrderByDescending(x => x.Name).ToList());
            var m = p.GetAmortization();

            l.ToList().ForEach(x => x.Value.Equals(m.First(y => y.Key.Name == x.Key.Name).Value));
        }
        /// <summary>
        /// Saves the specified portfolio.
        /// </summary>
        /// <param name="portfolio">The portfolio.</param>
        public void Save(DebtPortfolio portfolio)
        {
            var data = JsonConvert.SerializeObject(portfolio);

            var eData = AesEncryptamajig.Encrypt(data, Key.ToString());

            using (var sw = new StreamWriter(FilePath))
                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    writer.AutoCompleteOnClose = true;
                    writer.CloseOutput         = true;
                    writer.WriteRawValue(eData);
                    writer.Close();
                }
        }
        public void Test()
        {
            var portfolio = new DebtPortfolio
            {
                new DebtInfo("A", 16345.44M, 3.25M, 225),
                new DebtInfo("B", 12000, 0, 125),
                new DebtInfo("C", 6000, 3.5M, 182),
                new DebtInfo("D", 4000, 12.25M, 50),
                new DebtInfo("E", 2000, 15.55M, 200),
                new DebtInfo("F", 1000, 22, 50),
                new DebtInfo("G", 500, 22, 50),
                new DebtInfo("H", 10, 50.3M, 250),
                new DebtInfo("I", balance: 13000, 12, 100),
            };

            var schedule = portfolio.ToString();

            Console.WriteLine(schedule);
        }