public void ShowDialog_TestDialog_CancelButtonSet() { // Setup var mocks = new MockRepository(); var window = mocks.StrictMock <IWin32Window>(); window.Expect(w => w.Handle).Repeat.AtLeastOnce().Return(default(IntPtr)); mocks.ReplayAll(); Icon icon = IconStub(); DialogBoxHandler = (name, wnd) => { var openedDialog = new FormTester(name); openedDialog.Close(); }; using (var dialog = new TestDialog(window, icon, 1, 2)) { // Call dialog.ShowDialog(); // Assert Assert.IsNotNull(dialog.CancelButton); Assert.AreSame("Test button", ((Button)dialog.CancelButton).Name); } mocks.VerifyAll(); }
public void ShowDialog_TestDialog_MinimumSizeSet() { // Setup var mocks = new MockRepository(); var window = mocks.StrictMock <IWin32Window>(); window.Expect(w => w.Handle).Repeat.AtLeastOnce().Return(default(IntPtr)); mocks.ReplayAll(); Icon icon = IconStub(); DialogBoxHandler = (name, wnd) => { var openedDialog = new FormTester(name); openedDialog.Close(); }; using (var dialog = new TestDialog(window, icon, 1, 2)) { // Call dialog.ShowDialog(); // Assert Assert.AreEqual(1, dialog.MinimumSize.Width); Assert.AreEqual(2, dialog.MinimumSize.Height); } mocks.VerifyAll(); }
private void Button_Click(object sender, RoutedEventArgs e) { string inputParam = "some value"; string outputValue; TestDialog dlg = new TestDialog(inputParam); if (dlg.ShowDialog() == true) { outputValue = dlg.OutputParam; } }