Exemple #1
0
        public void TC3_VerifyBuyMarketOrder()
        {
            try
            {
                instrument           = TestData.GetData("Instrument");
                buyTab               = TestData.GetData("BuyTab");
                sellTab              = TestData.GetData("SellTab");
                marketOrderBuyAmount = TestData.GetData("TC3_MarketOrderBuyAmount");
                feeComponent         = TestData.GetData("FeeComponent");
                sellOrderSize        = TestData.GetData("TC3_SellOrderSize");
                limitPrice           = TestData.GetData("TC3_LimitPrice");
                timeInForce          = TestData.GetData("TC3_TimeInForce");
                string feeValue;
                Dictionary <string, string> placeMarketBuyOrder;

                // Get fee based on buy amount and fee component
                feeValue = GenericUtils.FeeAmount(marketOrderBuyAmount, feeComponent);
                UserFunctions       userFunctions      = new UserFunctions(TestProgressLogger);
                UserCommonFunctions userCommonFunction = new UserCommonFunctions(TestProgressLogger);
                VerifyOrdersTab     objVerifyOrdersTab = new VerifyOrdersTab(driver, TestProgressLogger);
                OrderEntryPage      orderEntryPage     = new OrderEntryPage(driver, TestProgressLogger);

                TestProgressLogger.StartTest();
                // Place buy and sell order to set the last price
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.PlaceOrderToSetMarketBegin, limitPrice));
                userCommonFunction.PlaceOrdersToSetLastPrice(driver, instrument, buyTab, sellTab, sellOrderSize, limitPrice, timeInForce, Const.USER10, Const.USER11);
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.PlaceOrderToSetMarketEnd, limitPrice));

                // Place Limit sell order to set the market
                userFunctions.LogIn(TestProgressLogger, Const.USER8);
                userCommonFunction.CancelAndPlaceLimitSellOrder(driver, instrument, sellTab, sellOrderSize, limitPrice, timeInForce);
                userFunctions.LogOut();
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.MarketSetupEnd, sellTab, sellOrderSize, limitPrice));

                userFunctions.LogIn(TestProgressLogger, Const.USER11);
                // Place Market buy order with the same quantity as that of sell limit order placed
                placeMarketBuyOrder = orderEntryPage.PlaceMarketBuyOrder(instrument, buyTab, Double.Parse(marketOrderBuyAmount));
                // Verify order is present in Filled Orders tab
                Assert.True(objVerifyOrdersTab.VerifyFilledOrdersTab(placeMarketBuyOrder["Instrument"], placeMarketBuyOrder["Side"], Double.Parse(placeMarketBuyOrder["BuyAmount"]), feeValue, placeMarketBuyOrder["PlaceOrderTime"], placeMarketBuyOrder["PlaceOrderTimePlusOneMin"]), Const.MarketOrderVerifiedInFilledOrders);
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.MarketOrderTestPassed, buyTab));
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(ex.Message + ex.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.MarketOrderTestFailed, buyTab), ex);
                throw ex;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(e.Message + e.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.MarketOrderTestFailed, buyTab), e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
            }
        }
Exemple #2
0
        //This method will verify the order placed in Filled orders tab through Order Entry
        public bool VerifyFilledOrdersTab(string instrument, string side, double size)
        {
            var    flag            = false;
            string marketOrderTime = null;

            UserCommonFunctions.DashBoardMenuButton(driver);
            Thread.Sleep(2000);
            UserCommonFunctions.SelectAnExchange(driver);

            OrderEntryPage boe = new OrderEntryPage(driver, output);

            if (side.Equals("Buy"))
            {
                marketOrderTime = boe.PlaceMarketBuyOrder(size);
            }

            else if (side.Equals("Sell"))
            {
                marketOrderTime = boe.PlaceMarketSellOrder(size);
            }

            string buyAmountValue        = GenericUtils.ConvertToDoubleFormat(size);
            string lastPrice             = boe.GetLastPrice();
            double doubleLastPrice       = Convert.ToDouble(lastPrice);
            string totalAmountCalculated = GenericUtils.FilledOrdersTotalAmount(size, doubleLastPrice);

            Thread.Sleep(2000);
            UserCommonFunctions.FilledOrderTab(driver);

            string expectedRow = instrument + " || " + side + " || " + size + " || " + lastPrice + " || " + totalAmountCalculated + " || " + marketOrderTime;

            if (GetListOfFilledOrders().Contains(expectedRow))
            {
                logger.Info(side + "Order Successfully verifed in Filled orders tab");
                flag = true;
            }
            return(flag);
        }