Created
October 16, 2012 13:20
-
-
Save mattanja/3899236 to your computer and use it in GitHub Desktop.
Using log4net TestContextAppender
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 MyTests | |
{ | |
[TestClass()] | |
public class IParameterServiceTest | |
{ | |
private TestContext testContextInstance; | |
/// <summary> | |
///Gets or sets the test context which provides | |
///information about and functionality for the current test run. | |
///</summary> | |
public TestContext TestContext | |
{ | |
get | |
{ | |
return testContextInstance; | |
} | |
set | |
{ | |
testContextInstance = value; | |
} | |
} | |
/// <summary> | |
/// Create logger configuration. | |
/// </summary> | |
[TestInitialize()] | |
public void MyTestInitialize() | |
{ | |
log4net.LogManager.ResetConfiguration(); | |
log4net.Config.BasicConfigurator.Configure(new TestContextAppender(this.TestContext)); | |
} | |
///<summary> | |
/// A test method testing some service method. | |
///</summary> | |
[TestMethod()] | |
public void AssignDepositaryBankTest() | |
{ | |
// [...] test the service that may be logging warnings or errors | |
// Make shure no warnings or errors occured | |
TestContextAppender.AssertDefaults(this.TestContext); | |
} | |
[...] Other tests [...] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment