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 class BrowserLaunchTestBehaviorObserver : BaseTestBehaviorObserver | |
| { | |
| protected override void PreTestInit(object sender, TestExecutionEventArgs e) | |
| { | |
| var browserType = this.GetExecutionBrowser(e.MemberInfo); | |
| Driver.StartBrowser(browserType); | |
| } | |
| protected override void PostTestCleanup(object sender, TestExecutionEventArgs e) | |
| { |
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 interface IExecutionProvider | |
| { | |
| event EventHandler<TestExecutionEventArgs> TestInstantiatedEvent; | |
| event EventHandler<TestExecutionEventArgs> PreTestInitEvent; | |
| event EventHandler<TestExecutionEventArgs> PostTestInitEvent; | |
| event EventHandler<TestExecutionEventArgs> PreTestCleanupEvent; |
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 class MSTestExecutionProvider : IExecutionProvider | |
| { | |
| public event EventHandler<TestExecutionEventArgs> TestInstantiatedEvent; | |
| public event EventHandler<TestExecutionEventArgs> PreTestInitEvent; | |
| public event EventHandler<TestExecutionEventArgs> PostTestInitEvent; | |
| public event EventHandler<TestExecutionEventArgs> PreTestCleanupEvent; |
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 class TestExecutionEventArgs : EventArgs | |
| { | |
| private readonly TestContext testContext; | |
| private readonly MemberInfo memberInfo; | |
| public TestExecutionEventArgs(TestContext context, MemberInfo memberInfo) | |
| { | |
| this.testContext = context; | |
| this.memberInfo = memberInfo; | |
| } |
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 class BaseTestBehaviorObserver | |
| { | |
| public void Subscribe(IExecutionProvider provider) | |
| { | |
| provider.TestInstantiatedEvent += this.TestInstantiated; | |
| provider.PreTestInitEvent += this.PreTestInit; | |
| provider.PostTestInitEvent += this.PostTestInit; | |
| provider.PreTestCleanupEvent += this.PreTestCleanup; | |
| provider.PostTestCleanupEvent += this.PostTestCleanup; | |
| } |
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
| [TestClass] | |
| [ExecutionBrowser(BrowserTypes.Chrome)] | |
| public class SearchEngineTestsDotNetEvents : BaseTest | |
| { | |
| [TestMethod] | |
| [ExecutionBrowser(BrowserTypes.Firefox)] | |
| public void SearchTextInSearchEngine_First_Observer() | |
| { | |
| B.SearchEngineMainPage searchEngineMainPage = new B.SearchEngineMainPage(Driver.Browser); | |
| searchEngineMainPage.Navigate(); |
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 class BrowserLaunchTestBehaviorObserver : BaseTestBehaviorObserver | |
| { | |
| protected override void PreTestInit(object sender, TestExecutionEventArgs e) | |
| { | |
| var browserType = this.GetExecutionBrowser(e.MemberInfo); | |
| Driver.StartBrowser(browserType); | |
| } | |
| protected override void PostTestCleanup(object sender, TestExecutionEventArgs e) | |
| { |
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 class BaseTest | |
| { | |
| private readonly MSTestExecutionProvider currentTestExecutionProvider; | |
| private TestContext testContextInstance; | |
| public BaseTest() | |
| { | |
| this.currentTestExecutionProvider = new MSTestExecutionProvider(); | |
| this.InitializeTestExecutionBehaviorObservers(this.currentTestExecutionProvider); | |
| var memberInfo = MethodInfo.GetCurrentMethod(); |
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 interface ITestExecutionSubject | |
| { | |
| void Attach(ITestBehaviorObserver observer); | |
| void Detach(ITestBehaviorObserver observer); | |
| void PreTestInit(TestContext context, MemberInfo memberInfo); | |
| void PostTestInit(TestContext context, MemberInfo memberInfo); |
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 interface ITestBehaviorObserver | |
| { | |
| void PreTestInit(TestContext context, MemberInfo memberInfo); | |
| void PostTestInit(TestContext context, MemberInfo memberInfo); | |
| void PreTestCleanup(TestContext context, MemberInfo memberInfo); | |
| void PostTestCleanup(TestContext context, MemberInfo memberInfo); |
OlderNewer