Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#

Hi

I am writing automation testing.But I have a problem that to test Message Box.

I want to test a MessageBox in C#.

Confused | :confused: Confused | :confused: Confused | :confused:
Posted 14-Dec-10 17:01pm
Comments
Toli Cuturicu at 15-Dec-10 15:43pm
   
No question!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You could try using PowerShell[^] - the author discusses message box testing - not in detail but still, it may help.
  Permalink  
Comments
Espen Harlinn at 29-Dec-12 9:48am
   
5'ed!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Here is how, for example:
$null = [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
 
function Message-Box(
	[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
	[string] $message, [string] $header=$null,
 	[switch][bool]$error = $false) {
    $icon = [System.Windows.Forms.MessageBoxIcon]::Information
    if ($error) { $icon = [System.Windows.Forms.MessageBoxIcon]::Error }
    $null = [System.Windows.Forms.MessageBox]::Show($message, $header, [System.Windows.Forms.MessageBoxButtons]::OK, $icon)
} # Message-Box
 
# use it:
<pre lang="text">message-box "Some message" -header " Some (optional) header"
or
"Some message" | message-box -header " Some (optional) header"
or, for error icon (see implementation of the function):
message-box "Some error message" -header " Some (optional) header" -error
# [switch] attribute shows that the value is not used in command line
Enjoy,
—SA
  Permalink  
v2
Comments
Espen Harlinn at 29-Dec-12 9:49am
   
5'ed!
Sergey Alexandrovich Kryukov at 29-Dec-12 20:07pm
   
Thank you, Espen. Have you done PowerShell? Interesting thing. —SA
Espen Harlinn at 30-Dec-12 5:42am
   
I've tried it, but so far I've had little use for it professionally so my experience is limited :-D
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 460
1 Sergey Alexandrovich Kryukov 336
2 Shai Vashdi 294
3 OriginalGriff 280
4 Abhinav S 160
0 Sergey Alexandrovich Kryukov 9,185
1 OriginalGriff 5,315
2 Peter Leow 4,040
3 Maciej Los 3,535
4 Abhinav S 3,308


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid