Last active
October 2, 2016 16:26
-
-
Save angelovstanton/26f12047255741f59dfe5e44c446ed62 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 abstract class BaseTestExecutionEngine<TExecutionEngineAttribute> | |
| : ITestExecutionEngine | |
| where TExecutionEngineAttribute : ExecutionEngineAttribute | |
| { | |
| protected IDriver driver; | |
| protected readonly IUnityContainer container; | |
| private bool isDisposed; | |
| public BaseTestExecutionEngine(IUnityContainer container) | |
| { | |
| this.container = container; | |
| } | |
| public void Dispose() | |
| { | |
| if (!this.isDisposed && this.driver != null) | |
| { | |
| this.driver.Quit(); | |
| this.isDisposed = true; | |
| } | |
| } | |
| public bool IsSelected(MemberInfo memberInfo) | |
| { | |
| bool isSelectedOnMethodLevel = this.GetExecutionEngineTypeByMethodInfo(memberInfo); | |
| bool isSelectedOnClassLevel = this.GetExecutionEngineType(memberInfo.DeclaringType); | |
| return isSelectedOnMethodLevel || isSelectedOnClassLevel; | |
| } | |
| public abstract void RegisterDependencies(Browsers executionBrowserType); | |
| private bool GetExecutionEngineTypeByMethodInfo(MemberInfo memberInfo) | |
| { | |
| if (memberInfo == null) | |
| { | |
| throw new ArgumentNullException("The test method's info cannot be null."); | |
| } | |
| var executionEngineTypeMethodAttribute = | |
| memberInfo.GetCustomAttribute<ExecutionEngineAttribute>(); | |
| if (executionEngineTypeMethodAttribute != null) | |
| { | |
| return true; | |
| } | |
| return false; | |
| } | |
| private bool GetExecutionEngineType(Type currentType) | |
| { | |
| if (currentType == null) | |
| { | |
| throw new ArgumentNullException("The test method's type cannot be null."); | |
| } | |
| var executionEngineClassAttribute = | |
| currentType.GetCustomAttribute<ExecutionEngineAttribute>(true); | |
| if (executionEngineClassAttribute != null) | |
| { | |
| return true; | |
| } | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment