/// <summary>
        /// Log all transactions in the console. It allows the user to filter between approved,
        /// not approved (or canceled) or all transactions.
        /// Also, it's possible to draw a graphic relating approved and not approved transactions.
        /// </summary>
        /// <param name="transactions">All transactions in this execution of the program.</param>
        /// <param name="predicate">Filter.</param>
        /// <param name="showGraphic">If the graphic should be logged.</param>
        public static void ShowTransactionsOnScreen(this ICollection <TransactionTableEntry> transactions,
                                                    Func <TransactionTableEntry, int, bool> predicate = null, bool showGraphic = false)
        {
            List <TransactionTableEntry> entries = new List <TransactionTableEntry>();

            if (predicate != null)
            {
                entries.AddRange(transactions.Where(predicate));
            }
            else
            {
                entries.AddRange(transactions);
            }

            Console.Write(entries.ToMarkdownTable());

            if (showGraphic == true)
            {
                int approvedCount = transactions.Where(t => t.IsCaptured == true)
                                    .Count();
                int notApprovedCount = transactions.Where(t => t.IsCaptured == false)
                                       .Count();

                var graphic = new Dictionary <string, int>
                {
                    { "Total", transactions.Count },
                    { "Aprovadas", approvedCount },
                    { "Nao aprovadas", notApprovedCount },
                };

                Console.Write(graphic.ToMarkdownBarChart());
            }
        }
Esempio n. 2
0
        public void TestCanPlotBarChartFromDictionary()
        {
            var data = new Dictionary <string, double>
            {
                { "Russia", 17.1 },
                { "Antartica", 14.0 },
                { "Canada", 10.0 },
                { "China", 9.7 },
                { "United States", 9.6 }
            };

            data.ToMarkdownBarChart().WriteToTrace();
        }
Esempio n. 3
0
        public void TestCanPlotBarChartFromDictionary()
        {
            var data = new Dictionary<string, double>
            {

                {"Russia", 17.1},
                {"Antartica", 14.0},
                {"Canada", 10.0},
                {"China", 9.7},
                {"United States", 9.6}
            };

            data.ToMarkdownBarChart().WriteToTrace();
        }
Esempio n. 4
0
        public void BarChartExample()
        {
            var worldCup = new Dictionary <string, int>
            {
                { "Brazil", 5 },
                { "Italy", 4 },
                { "Germany", 4 },
                { "Argentina", 2 },
                { "Uruguay", 2 },
                { "France", 1 },
                { "Spain", 1 },
                { "England", 1 }
            };

            Console.Write(worldCup.ToMarkdownBarChart());
        }
        public void BarChartExample()
        {
            var worldCup = new Dictionary<string, int>
            {
                {"Brazil", 5},
                {"Italy", 4},
                {"Germany", 4},
                {"Argentina", 2},
                {"Uruguay", 2},
                {"France", 1},
                {"Spain", 1},
                {"England", 1}
            };

            Console.Write(worldCup.ToMarkdownBarChart());
        }