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

            button.DataContext = mock;

            ButtonHelper.SetMethodName(button, "DoStuffWithButtonParameter");

            // 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, "Parameter");
        }
Exemplo n.º 2
0
        public void Click_SetContext_WithButtonAndStringParameter()
        {
            // Arrange
            var mock   = new Mock();
            var button = new Button();

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

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

            // 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");
        }