I
ink
Hi all,
I am relatively new to C# and the CF, as a whole I have about 8 months
experience with then so not a great deal. I come from a VB6 back ground so
my OOP and Threading are also new to me. I am having a problem with an
application I am trying to write and you seem to be some what of a guru on
the topic of CF development, so I would be very great full for any help or
advice you could give me.
What I am trying to do is write an application that will automat UAT tests
for my company. We tend to develop high volume user applications for
warehouses and proof of delivery systems. These are all running on Windows
Mobile devices from Symbol.
The problem is trying to run suitable load and regression tests on 800 units
at a time is virtually imposable. So what I am trying to write is a small
application that can drive the main application from a simple text file,
like a test script.
I found what I thought was a fantastic solution to my problem at this
website.
http://msdn.microsoft.com/msdnmag/issues/03/01/UITestAutomation/default.aspx
I ported the 2 Applications in the article to CF2 applications.
However I seem to have come up against a few hurdles to do with the loading
of the the application I am trying to test. In CF7 applications there is a
Static Program class that is the entry point with a private method Main.
I have tried a number of different ways of invoke this method to get the
application to load up but I keep getting errors. I have even tried exposing
a public method in the application I am trying to test and calling the main
method from with in that but still no luck.
Any help would be fantastic.
Thanks,
Ink
PS below is some of the code I have tried.
private void button1_Click(object sender, EventArgs e)
{
//First load the application
testAssembly = Assembly.LoadFrom("\\Program
Files\\WM_Automation_Test\\WM_Automation_Test.exe");
//Type t = testAssembly.GetType("Mnetics.CEApp.Splash");
//testForm = (Form)testAssembly.CreateInstance(t.FullName);
//Mnetics.CEApp.Forms.Splash
//ChangeForm("Mnetics.CEApp.Forms.Splash");
//Type t = testAssembly.GetType("WM_Automation_Test.Program");
//t.GetMethod("AutomationEntry").Invoke(null, new object[] { });
Type t = testAssembly.GetType("WM_Automation_Test.Program");
t.GetMethod("AutomationEntry").Invoke(null, new object[] { });
//object x = (object)testAssembly.CreateInstance(t.FullName);
//InvokeMethod(x, "Main");
//ThreadPool.QueueUserWorkItem(new WaitCallback(RunApp),
testForm);
}
private void ChangeForm(string NewForm)
{
Type t = testAssembly.GetType(NewForm);
testForm = (Form)testAssembly.CreateInstance(t.FullName);
}
//private delegate void RunAppDelegate(object state);
static void RunApp(object state) // Need this function to pass into
WaitCallback().
{
//if (this.InvokeRequired)
//{
// // we were called on a worker thread
// // marshal the call to the user interface thread
// this.Invoke(new RunAppDelegate(RunApp), new object[] {
state });
// return;
//}
// this code can only be reached
// by the user interface thread
//Start the application
Application.Run((Form)state);
}
I am relatively new to C# and the CF, as a whole I have about 8 months
experience with then so not a great deal. I come from a VB6 back ground so
my OOP and Threading are also new to me. I am having a problem with an
application I am trying to write and you seem to be some what of a guru on
the topic of CF development, so I would be very great full for any help or
advice you could give me.
What I am trying to do is write an application that will automat UAT tests
for my company. We tend to develop high volume user applications for
warehouses and proof of delivery systems. These are all running on Windows
Mobile devices from Symbol.
The problem is trying to run suitable load and regression tests on 800 units
at a time is virtually imposable. So what I am trying to write is a small
application that can drive the main application from a simple text file,
like a test script.
I found what I thought was a fantastic solution to my problem at this
website.
http://msdn.microsoft.com/msdnmag/issues/03/01/UITestAutomation/default.aspx
I ported the 2 Applications in the article to CF2 applications.
However I seem to have come up against a few hurdles to do with the loading
of the the application I am trying to test. In CF7 applications there is a
Static Program class that is the entry point with a private method Main.
I have tried a number of different ways of invoke this method to get the
application to load up but I keep getting errors. I have even tried exposing
a public method in the application I am trying to test and calling the main
method from with in that but still no luck.
Any help would be fantastic.
Thanks,
Ink
PS below is some of the code I have tried.
private void button1_Click(object sender, EventArgs e)
{
//First load the application
testAssembly = Assembly.LoadFrom("\\Program
Files\\WM_Automation_Test\\WM_Automation_Test.exe");
//Type t = testAssembly.GetType("Mnetics.CEApp.Splash");
//testForm = (Form)testAssembly.CreateInstance(t.FullName);
//Mnetics.CEApp.Forms.Splash
//ChangeForm("Mnetics.CEApp.Forms.Splash");
//Type t = testAssembly.GetType("WM_Automation_Test.Program");
//t.GetMethod("AutomationEntry").Invoke(null, new object[] { });
Type t = testAssembly.GetType("WM_Automation_Test.Program");
t.GetMethod("AutomationEntry").Invoke(null, new object[] { });
//object x = (object)testAssembly.CreateInstance(t.FullName);
//InvokeMethod(x, "Main");
//ThreadPool.QueueUserWorkItem(new WaitCallback(RunApp),
testForm);
}
private void ChangeForm(string NewForm)
{
Type t = testAssembly.GetType(NewForm);
testForm = (Form)testAssembly.CreateInstance(t.FullName);
}
//private delegate void RunAppDelegate(object state);
static void RunApp(object state) // Need this function to pass into
WaitCallback().
{
//if (this.InvokeRequired)
//{
// // we were called on a worker thread
// // marshal the call to the user interface thread
// this.Invoke(new RunAppDelegate(RunApp), new object[] {
state });
// return;
//}
// this code can only be reached
// by the user interface thread
//Start the application
Application.Run((Form)state);
}