假设我有一个类EmployeeService
,看起来像这样:
public class EmployeeService
{
private readonly IRepository<Employee> _employeeRepository;
public EmployeeService(IRepository<Employee> employeeRepository)
{
_employeeRepository = employeeRepository;
}
...
// Relevant methods that deal with operations on employees.
...
_employeeRepository
有DbContext
并启用CRUD
操作。 DbContext
连接到MySQL
数据库。
我的集成测试类定义为:
[TestFixture]
public class EmployeeServiceTests
{
// System under test.
private EmployeeService _sut;
[SetUp]
public void SetUp()
{
_sut = new EmployeeService(
new Repository<Employee,TestDatabaseContext>(
new TestDatabaseContext()));
}
...
// Tests.
...
TestDatabaseContext
初始化为DropCreateDatabaseAlways
和一些种子数据。
我有两个问题(第二个与第一个问题相关联):
MySQL
&amp; MSSQL
)。