我正在尝试使用 NDbUnit。我为每个表创建了单独的 XSD,而不是为完整的数据库创建了一个大型 XSD。
当我只使用单个 XSD 和单个 xml 读取时,我的测试运行良好。但是,对于特定测试,我需要在两个或三个不同(但相关)表中保存数据。如果我尝试读取多个 xsd 和 xml,则会引发异常。
这是我的代码
[ClassInitialize()]
public static void MyClassInitialize(TestContext testContext)
{
IDbConnection connection = DbConnection.GetCurrentDbConnection();
_mySqlDatabase = new NDbUnit.Core.SqlClient.SqlDbUnitTest(connection);
_mySqlDatabase.ReadXmlSchema(@"Data\CompanyMaster.xsd");
_mySqlDatabase.ReadXml(@"Data\CompanyMaster.xml");
_mySqlDatabase.ReadXmlSchema(@"Data\License.xsd");
_mySqlDatabase.ReadXml(@"Data\License.xml");
_mySqlDatabase.ReadXmlSchema(@"Data\LicenseDetails.xsd");
_mySqlDatabase.ReadXml(@"Data\LicenseDetails.xml");
_mySqlDatabase.ReadXmlSchema(@"RelatedLicense.xsd");
_mySqlDatabase.ReadXml(@"Data\RelatedLicense.xml");
}
这是我在尝试读取 License.XSD 时遇到的异常,如上所示
类初始化方法 ESMS.UnitTest.CompanyManagerTest.MyClassInitialize 抛出异常。System.ArgumentException:System.ArgumentException:已添加项目。字典中的键:“EnableTableAdapterManager” 正在添加的键:“EnableTableAdapterManager”。
我不确定这是否是使用 NDbUnit 读取多个 XML、XSD 的正确方法。我用谷歌搜索并溢出(即搜索堆栈溢出),但找不到任何明智的方向。有人可以解释出了什么问题以及如何纠正吗?