目前我需要我的单元测试项目连接到数据库,但基于环境的一部分。所以,如果我通过服务器A上的mstest.exe运行测试,那么我希望数据库连接字符串指向" DatabaseA",如果我在服务器B上运行它,我希望指向&#34 ; DatabaseB&#34 ;.注意:" DatabaseA"可以是dev evn和"数据库C"可以是生产环境。
我在MS Test项目中进行了ConfigurationSettings调用:
final int batchSize = 1000;
int count = 0;
for (final MyClass object: myList) {
ps.setString(1, object.getOne());
ps.setString(2, object.getTwo());
ps.setString(3, object.getThree());
ps.setString(4, object.getFour());
ps.setString(5, object.getFive());
ps.setString(6, object.getSix());
ps.setString(7, object.getSeven());
ps.setString(8, object.getEight());
ps.setString(9, object.getNine());
ps.setString(10, object.get10());
ps.addBatch();
if(++count % batchSize == 0) {
ps.executeBatch();
}
}
ps.executeBatch(); // insert remaining records
但不确定如何获得我可以通过mstest.exe传递的论据
即。
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;
namespace WF.ZTDD
{
[TestClass()]
public class ConfigurationSettings
{
/// <summary>
/// set application default data directory
/// </summary>
/// <param name="context">TestContext</param>
/// <returns></returns>
[AssemblyInitialize]
public static void AssemblyInit(TestContext context)
{
}
}
}