This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Main(string[] args) | |
{ | |
ApplicationArgs appArgs = ApplicationArgs.Parse(args); | |
SetExceptionHandlers(appArgs.IsTestingMode); | |
} | |
public void SetExceptionHandlers(bool bIsTestingMode) | |
{ | |
if (!bIsTestingMode) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Main(string[] args) | |
{ | |
// Initialization code | |
Application.ThreadException += ThreadExceptionHandler; | |
AppDomain.CurrentDomain.UnhandledException += AppDomainExceptionHandler; | |
} | |
static void ThreadExceptionHandler(object sender, ThreadExceptionEventArgs e) | |
{ | |
// Some logging of the exception |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ITestableInputDialog() | |
{ | |
void SendInput(string text); | |
void CancelAction(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* (...) */ | |
testableDialog.ChangeEntryText(“Sergio”); | |
testableDialog.ClickOkButton(); | |
Assert.IsFalse(testableDialog.IsOkButtonEnabled()); | |
Assert.IsFalse(testableDialog.IsCancelButtonEnabled()); | |
Assert.IsFalse(testableDialog.IsEntryEnabled()); | |
WaitingAssert.IsNullOrWhitespace( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*(...)*/ | |
testableDialog.ChangeEntryText(“Sergio”); | |
testableDialog.ClickOkButton(); | |
WaitingAssert.IsNullOrWhitespace( | |
testableDialog.GetEntryText, | |
“The entry text was not cleared in a reasonable time.”); | |
Assert.IsTrue(testableDialog.IsOkButtonEnabled()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*(...)*/ | |
public static void IsNullOrWhitespace(Func<string> stringFunc, string message) | |
{ | |
int waitTime = 0; | |
while (waitTime <= MAX_WAIT_TIME) | |
{ | |
if (string.IsNullOrWhitespace(stringFunc())) | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testebleAppWindow.ClickInputButton(); | |
WaitingAssert.IsNotNull( | |
testableWindow.GetInputDialog, | |
"The InputDialog was not ready in a reasonable time."); | |
ITestableInputDialog testableDialog = | |
testableWindow.GetInputDialog(); | |
testableDialog.ChangeEntryText(“Sergio”); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ITestableInputDialog | |
{ | |
// Other methods | |
bool IsOkButtonEnabled(); | |
bool IsCancelButtonEnabled(); | |
bool IsEntryEnabled(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* (...) */ | |
public bool IsEnabled(Control control) | |
{ | |
bool result = false; | |
mControl.Invoke((MethodInvoker)delegate | |
{ result = control.Enabled; } | |
return result; | |
} | |
/* (...) */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class WaitingAssert | |
{ | |
public static void IsTrue(Func<bool> boolFunc, string message) | |
{ | |
int waitTime = 0; | |
while (waitTime <= MAX_WAIT_TIME) | |
{ | |
if (boolFunc()) | |
break; |