static int Main(string[] args) { UndockedRegFreeWinrt.Initialize(); Console.WriteLine("Undocked RegFree WinRT Managed Test - Starting"); if (!RunTest(new System.Threading.ThreadStart(() => TestClassBoth(3)), System.Threading.ApartmentState.STA)) { Console.WriteLine("Both to STA test failed"); testsFailed++; } if (!RunTest(new System.Threading.ThreadStart(() => TestClassBoth(1)), System.Threading.ApartmentState.MTA)) { Console.WriteLine("Both to MTA test failed"); testsFailed++; } if (!RunTest(new System.Threading.ThreadStart(() => TestClassMta(1)), System.Threading.ApartmentState.STA)) { Console.WriteLine("MTA to STA test failed"); testsFailed++; } if (RunTest(new System.Threading.ThreadStart(() => TestClassSta(1)), System.Threading.ApartmentState.MTA)) { Console.WriteLine("STA to MTA should failed"); testsFailed++; } Console.WriteLine("Undocked RegFree WinRT Managed Test - " + (testsRan - testsFailed) + " out of " + testsRan + " tests passed"); return(testsFailed == 0 ? 0 : 1); }
static int Main(string[] args) { UndockedRegFreeWinrt.Initialize(); Console.WriteLine("Undocked RegFree WinRT Managed Test - Starting"); System.Threading.Thread testThread; succeeded = false; testThread = new System.Threading.Thread(new System.Threading.ThreadStart(() => TestClassBoth(3))); testThread.SetApartmentState(System.Threading.ApartmentState.STA); testThread.Start(); testThread.Join(); if (!succeeded) { Console.WriteLine("Both to STA test failed"); return(1); } succeeded = false; testThread = new System.Threading.Thread(new System.Threading.ThreadStart(() => TestClassBoth(1))); testThread.SetApartmentState(System.Threading.ApartmentState.MTA); testThread.Start(); testThread.Join(); if (!succeeded) { Console.WriteLine("Both to MTA test failed"); return(1); } succeeded = false; testThread = new System.Threading.Thread(new System.Threading.ThreadStart(() => TestClassMta(1))); testThread.SetApartmentState(System.Threading.ApartmentState.STA); testThread.Start(); testThread.Join(); if (!succeeded) { Console.WriteLine("MTA to STA test failed"); return(1); } succeeded = false; testThread = new System.Threading.Thread(new System.Threading.ThreadStart(() => TestClassSta(1))); testThread.SetApartmentState(System.Threading.ApartmentState.MTA); testThread.Start(); testThread.Join(); if (succeeded) { Console.WriteLine("STA to MTA should failed"); return(1); } Console.WriteLine("Undocked RegFree WinRT Managed Test - All tests passed"); return(0); }