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
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 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 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 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 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 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 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 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 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); |
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
public class MSTestExecutionSubject : ITestExecutionSubject | |
{ | |
private readonly List<ITestBehaviorObserver> testBehaviorObservers; | |
public MSTestExecutionSubject() | |
{ | |
this.testBehaviorObservers = new List<ITestBehaviorObserver>(); | |
} | |
public void Attach(ITestBehaviorObserver observer) |
OlderNewer