Created
April 10, 2016 14:37
-
-
Save AddressXception/25f39872e9ae95556e61bbee417105d2 to your computer and use it in GitHub Desktop.
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
namespace TipCalc.UITest.Windows | |
{ | |
[TestClass] | |
public abstract class WindowsFeatureBase : FeatureBase | |
{ | |
protected static string AppId; | |
protected static string Device; | |
protected static bool ResetDevice; | |
/// <summary> | |
/// static constructor acts as [ClassInitialize] | |
/// </summary> | |
static WindowsFeatureBase() | |
{ | |
Device = Local.Machine; | |
AppId = Constants.WIN_APPID; | |
ResetDevice = true; | |
} | |
protected override void CreateApp(bool reset = true) | |
{ | |
IApp value; | |
if (FeatureContext.Current.TryGetValue(ScreenNames.App, out value)) | |
{ | |
Console.WriteLine( | |
"The IApp context was not properly cleared " + | |
"or the FeatureContext was not disposed. " + | |
"Removing IApp from current Context"); | |
value = null; | |
FeatureContext.Current.Remove(ScreenNames.App); | |
} | |
App = AppInitializer | |
.StartApp(AppId, Device, ResetDevice); | |
FeatureContext.Current.Add(ScreenNames.App, App); | |
} | |
protected override void RegisterScreens() | |
{ | |
try | |
{ | |
FeatureContext.Current.Get<ITipCalcScreen>(ScreenNames.TipCalc); | |
return; | |
} | |
catch (KeyNotFoundException) | |
{ | |
//Keys don't exist so continue | |
} | |
FeatureContext.Current.Add(ScreenNames.TipCalc, new TipCalcScreen()); | |
} | |
[TestInitialize] | |
public void BeforeEachTest() | |
{ | |
Debug.WriteLine("WindowsFeatureBase BeforeEachTest() Called"); | |
RegisterScreens(); | |
CreateApp(); | |
} | |
[TestCleanup] | |
public void AfterEachTest() | |
{ | |
Debug.WriteLine("WindowsFeatureBase AfterEachTest() Called"); | |
AppInitializer.ShutDown(Device); | |
} | |
[ClassCleanup] | |
public void TearDown() | |
{ | |
Debug.WriteLine("WindowsFeatureBase TearDown() Called"); | |
AppInitializer.ShutDown(Device); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment