示例#1
0
        private void PopulateBuySellPanelWithData(Order model)
        {
            SelectBuySellTabPage();

            ListBox  listBox            = Window.Get <ListBox>(TestDataInfrastructure.GetControlId("OrdersListBox"));
            int      listItemsCount     = listBox.Items.Count;
            GroupBox buySellSymbolGroup = null;

            //collapse all the CompositeExpander except the last one which is supposedly the latest
            if (listItemsCount > 1)
            {
                int groupboxTracker = 0;

                for (int i = 0; i < listItemsCount; i++)
                {
                    if (null != listBox.Items[i])
                    {
                        buySellSymbolGroup = Window.TryGet <GroupBox>(SearchCriteria.ByAutomationId(TestDataInfrastructure.GetControlId("CompositeExpander"))
                                                                      .AndControlType(typeof(GroupBox))
                                                                      .AndIndex(i));

                        if (null != buySellSymbolGroup)
                        {
                            groupboxTracker = i;
                            buySellSymbolGroup.DoubleClick();
                        }
                    }
                }

                buySellSymbolGroup = Window.Get <GroupBox>(SearchCriteria.ByAutomationId(TestDataInfrastructure.GetControlId("CompositeExpander"))
                                                           .AndControlType(typeof(GroupBox))
                                                           .AndIndex(groupboxTracker));
                buySellSymbolGroup.DoubleClick();
            }

            if (buySellSymbolGroup != null)
            {
                AutomationElement symbolTextBox = buySellSymbolGroup.AutomationElement.SearchInRawTreeByName(TestDataInfrastructure.GetControlId("BuySellSymbolTextBox"));
                SetTextBoxValue(symbolTextBox, model.Symbol);

                AutomationElement orderTypeComboBox = buySellSymbolGroup.AutomationElement.SearchInRawTreeByName(TestDataInfrastructure.GetControlId("BuySellOrderTypeCombo"));
                SelectItemInComboBox(orderTypeComboBox, model.OrderType);

                AutomationElement shareTextBox = buySellSymbolGroup.AutomationElement.SearchInRawTreeByName(TestDataInfrastructure.GetControlId("BuySellSharesTextBox"));
                SetTextBoxValue(shareTextBox, model.NumberOfShares.ToString(CultureInfo.InvariantCulture));

                AutomationElement limitStopPriceTextBox = buySellSymbolGroup.AutomationElement.SearchInRawTreeByName(TestDataInfrastructure.GetControlId("BuySellStopLimitPriceTextBox"));
                SetTextBoxValue(limitStopPriceTextBox, model.LimitStopPrice.ToString(CultureInfo.InvariantCulture));

                AutomationElement timeInForceComboBox = buySellSymbolGroup.AutomationElement.SearchInRawTreeByName(TestDataInfrastructure.GetControlId("BuySellTimeInForceCombo"));
                SelectItemInComboBox(timeInForceComboBox, model.FormattedTimeInForce);

                switch (model.TransactionType)
                {
                case "Buy":
                    string            buyRadioControlName   = TestDataInfrastructure.GetControlId("BuyRadio");
                    AutomationElement buyRadioButtonElement = buySellSymbolGroup.AutomationElement.SearchInRawTreeByName(buyRadioControlName);
                    SelectRadioButton(buyRadioButtonElement);
                    break;

                case "Sell":
                    string            sellRadioControlName   = TestDataInfrastructure.GetControlId("SellRadio");
                    AutomationElement sellRadioButtonElement = buySellSymbolGroup.AutomationElement.SearchInRawTreeByName(sellRadioControlName);
                    SelectRadioButton(sellRadioButtonElement);
                    break;
                }
            }
        }