Where and when should data be inserted into a database in the arrange phase in xunit framework?
By the arrange phase I mean the Arrange from the Arrange, Act, Assert pattern.
To prepare data for each test method I am using a separate class. E.g.:
class CasesRelationTypeTest
{
[Theory]
[MemberData(nameof(CasesRelationTypeTestData.DeleteAsyncTest), MemberType = typeof(CasesRelationTypeTestData))]
public void DeleteAsyncTest(CasesRelationTypeDto data)
{
//...
}
//...
}
class CasesRelationTypeTestData
{
public TheoryData<CasesRelationTypeDto> DeleteAsyncTest { get; private set; }
public CasesRelationTypeTestData()
{
InitDeleteAsync();
}
private void InitDeleteAsync()
{
//should I insert the data here? but then it will be inserted for all the tests in the CasesRelationTypeTest, which is not what I want
DeleteAsyncTest.Add(new CasesRelationTypeDto
{
//...
});
}
}
I am okay with changing the way in which data is provided to a theory if you propose something different (which would allow for a well devised arrange phase).