Currently a sql unit test consists of 5 sections:
- Pre-Initialise
- Pre-Test
- Test
- Post-Test
- Post-Cleanup
For some of my tests the "pre-test" section is the same, and I have to copy-paste the Pre-Test code multiple times, code duplication is a bad idea... So my question is if there any way to write the pre-test somewhere only once and run it by calling a function within the unit-test Project?
Example of my current C# file behind one my my testcases:
[TestClass()]
public class SqlServerUnitTestAssignUserToAssignment : SqlDatabaseTestClass
{
private TransactionScope trans;
public SqlServerUnitTestAssignUserToAssignment()
{
InitializeComponent();
}
[TestInitialize()]
public void TestInitialize()
{
trans = new TransactionScope();
base.InitializeTest();
}
[TestCleanup()]
public void TestCleanup()
{
base.CleanupTest();
trans.Dispose();
}
// generated code below:
Designer support code
Additional test attributes
[TestMethod()]
public void core_AssignUserToAssignmentTest()...
private Sql DatabaseTestActions core_AssignUserToAssignmentTestData
}