예제 #1
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");
        }