Exemplo n.º 1
0
        public void Click_WithParameter()
        {
            // Arrange
            var mock   = new Mock();
            var button = new Button();

            button.DataContext = mock;

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

            ButtonHelper.SetMethodName(button, "DoStuffWithParameter");
            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.AreEqual(expectedParameter, mock.Parameter, "Parameter");
        }