public void Click()
        {
            // Arrange
            var mock = new Mock();
            var button = new Button();
            button.DataContext = mock;

            ButtonHelper.SetMethodName(button, "DoStuff");

            // Act
            var peer = new ButtonAutomationPeer(button);
            var invokeProvider = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
            invokeProvider.Invoke();

            // Assert
            Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.IsTrue(mock.WasButtonClicked);
        }
        private void InvokeCommand(Button button)
        {
            try
            {
                ButtonAutomationPeer peer = new ButtonAutomationPeer(button);
                IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                invokeProv.Invoke();

                //To get UI to flash update
                Task.Factory.StartFromCurrentUIContext(async () =>
                {
                    VisualStateManager.GoToState(button, "Pressed", true);
                    await Task.Delay(75);
                    VisualStateManager.GoToState(button, "Normal", true);
                });
            }
            catch { }
        }
        public void Click_WithButtonAndStringParameter()
        {
            // Arrange
            var mock = new Mock();
            var button = new Button();
            button.DataContext = mock;

            var expectedParameter = Guid.NewGuid().ToString();

            ButtonHelper.SetMethodName(button, "DoStuffWithButtonAndStringParameter");
            ButtonHelper.SetParameter(button, expectedParameter);

            // Act
            var peer = new ButtonAutomationPeer(button);
            var invokeProvider = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
            invokeProvider.Invoke();

            // Assert
            Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.AreSame(button, mock.ButtonParameter, "Button Parameter");
            Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert.AreEqual(expectedParameter, mock.Parameter, "Parameter");
        }
 /// <summary>
 /// Process key presses for the input textbox
 /// </summary>
 static void textboxInput_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
 {
     // Did the user press a significant control key?
     switch (e.Key)
     {
         case Windows.System.VirtualKey.Enter:
             // Simulate clicking the OK button
             e.Handled = true;
             ButtonAutomationPeer peer = new ButtonAutomationPeer(_buttonOK);
             IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
             invokeProv.Invoke();
             break;
         case Windows.System.VirtualKey.Escape:
             // Simulate clicking the Cancel button
             e.Handled = true;
             peer = new ButtonAutomationPeer(_buttonCancel);
             invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
             invokeProv.Invoke();
             break;
     }
 }
 public void PeerCheckBoxClick()
 {
     ButtonAutomationPeer peer = new ButtonAutomationPeer(Next);
     IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
     invokeProv.Invoke();
 }
        //Set up AI
        private void computerTurn()
        {
            // My Priority Logic

            // Priority 1: Get Tic Tac Toe
            // Priority 2: Block Tic Tac Toe
            // Priority 3: Corner Space
            // Priority 4: Open Space

            Button move = null;

            //Try Tic Tac Toe
            move = winOrBlockTry("O");
            if (move == null)
            {
                move = winOrBlockTry("X");
                if (move == null)
                {
                    move = cornertry();
                    if (move == null)
                    {
                        move = openSpaceTry();
                    }//end if
                }// end if
            }// end if

           // move.Tag = move.GetType();
           // string play = move.Tag.ToString();

            if (thereIsAWinner == false)
            {
                if (move == null)
                { }
                else
                {
                    ButtonAutomationPeer peer =
               new ButtonAutomationPeer(move);
                    IInvokeProvider invokeProv =
                      peer.GetPattern(PatternInterface.Invoke)
                      as IInvokeProvider;
                    invokeProv.Invoke();
                }
            }

            else
            {
               
            }


        }
        private void TxtPassword_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == VirtualKey.Enter)
            {
                e.Handled = true;

                btnLogin.Focus(FocusState.Programmatic);
                ButtonAutomationPeer buttonPeer = new ButtonAutomationPeer(btnLogin);
                IInvokeProvider invokeProvider = (IInvokeProvider)buttonPeer.GetPattern(PatternInterface.Invoke);
                Debug.Assert(invokeProvider != null);
                invokeProvider.Invoke();
            }
        }