Example #1
0
        public void GetBestPrice_Buying_UnsuitableBalanceException()
        {
            decimal buyAmount = 4M;
            Order   buyOrder  = new BuyingOrder(buyAmount);

            Assert.Throws <Exception>(() => _marketHandler.ProcessOrder(buyOrder));
        }
Example #2
0
        public void GetBestPrice_Buying_NegativeAmountFalse()
        {
            decimal buyAmount = -.74M;
            Order   buyOrder  = new BuyingOrder(buyAmount);

            Assert.Throws <Exception>(() => _marketHandler.ProcessOrder(buyOrder));
        }
Example #3
0
        public void GetBestPrice_Buying_EqualTrue()
        {
            decimal   buyAmount = 2.5M;
            Order     buyOrder  = new BuyingOrder(buyAmount);
            BestPrice bestBuy   = _marketHandler.ProcessOrder(buyOrder);

            Assert.Equal(bestBuy.price, 870M);
        }
Example #4
0
        static void Main(string[] args)
        {
            MetaMarketHandler marketHandler = new MetaMarketHandler();

            decimal   amount   = 4.25M;
            Order     buyOrder = new BuyingOrder(amount);
            BestPrice bestBuy  = marketHandler.ProcessOrder(buyOrder);

            Console.WriteLine(bestBuy);

            // without data resetting, previous sell/buy will impact on future results
            marketHandler.ResetData(); // if we wanna re-gather data and reset existing balances

            decimal   sellAmount = 1.67M;
            Order     sellOrder  = new SellingOrder(sellAmount);
            BestPrice bestSell   = marketHandler.ProcessOrder(sellOrder);

            Console.WriteLine(bestSell);
        }