예제 #1
0
        public void TestHighlyUnusualStake()
        {
            Int32  stake        = 1000;
            double averageStake = 10;

            Assert.AreEqual(true, Evalulator.IsStakeUnusual(stake, averageStake), "Highly Unsual stake not determined correctly");
        }
예제 #2
0
        public void TestNormalStake()
        {
            Int32  stake        = 100;
            double averageStake = 50;

            Assert.AreEqual(false, Evalulator.IsStakeUnusual(stake, averageStake), "Normal stake not determined correctly");
        }
예제 #3
0
        public void TestNormalCustomer()
        {
            Int32        customer       = 2;
            List <Int32> riskyCustomers = new List <Int32> {
                1
            };

            Assert.AreEqual(false, Evalulator.IsCustomerRisky(customer, riskyCustomers), "Normal customer not determined correctly");
        }
예제 #4
0
        public void TestRiskyCustomer()
        {
            Int32        customer       = 1;
            List <Int32> riskyCustomers = new List <Int32> {
                1
            };

            Assert.AreEqual(true, Evalulator.IsCustomerRisky(customer, riskyCustomers), "Risky customer not determined correctly");
        }
예제 #5
0
        private static void Main(string[] args)
        {
            var showTree = false;

            while (true)
            {
                Console.Write("> ");
                var line = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(line))
                {
                    return;
                }

                switch (line)
                {
                case "#showTree":
                    showTree = !showTree;
                    Console.WriteLine(showTree ? "Now showing tree." : "Tree is now hidden.");
                    continue;

                case "#cls":
                    Console.Clear();
                    continue;
                }

                var syntaxTree      = SyntaxTree.Parse(line);
                var binder          = new Binder();
                var boundExpression = binder.BindExpression(syntaxTree.Root);

                var diagnostics = syntaxTree.Diagnostics.Concat(binder.Diagnostics).ToArray();

                if (showTree)
                {
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    PrettyPrint(syntaxTree.Root);
                    Console.ResetColor();
                }

                if (!diagnostics.Any())
                {
                    var evalulator = new Evalulator(boundExpression);
                    var result     = evalulator.Evalulate();
                    Console.WriteLine(result);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed;

                    foreach (var diagnostic in diagnostics)
                    {
                        Console.WriteLine(diagnostic);
                    }

                    Console.ResetColor();
                }
            }
        }
예제 #6
0
        public void TestHighPayout()
        {
            Int32 payout = 2000;

            Assert.AreEqual(true, Evalulator.IsHighPayoutBet(payout), "High payout not determined correctly");
        }
예제 #7
0
        public void TestNormalPayout()
        {
            Int32 payout = 100;

            Assert.AreEqual(false, Evalulator.IsHighPayoutBet(payout), "Normal payout not determined correctly");
        }