Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using log4net TestContextAppender
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
You can’t perform that action at this time.