惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
T
Tailwind CSS Blog
Google DeepMind News
Google DeepMind News
D
DataBreaches.Net
P
Proofpoint News Feed
Simon Willison's Weblog
Simon Willison's Weblog
Microsoft Azure Blog
Microsoft Azure Blog
MongoDB | Blog
MongoDB | Blog
腾讯CDC
月光博客
月光博客
A
Arctic Wolf
T
Threatpost
Jina AI
Jina AI
博客园 - 聂微东
美团技术团队
V
V2EX
云风的 BLOG
云风的 BLOG
宝玉的分享
宝玉的分享
Recent Commits to openclaw:main
Recent Commits to openclaw:main
M
MIT News - Artificial intelligence
S
Secure Thoughts
Martin Fowler
Martin Fowler
Webroot Blog
Webroot Blog
V
Vulnerabilities – Threatpost
爱范儿
爱范儿
人人都是产品经理
人人都是产品经理
Help Net Security
Help Net Security
Google Online Security Blog
Google Online Security Blog
博客园 - Franky
The Last Watchdog
The Last Watchdog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
博客园 - 【当耐特】
S
Schneier on Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Know Your Adversary
Know Your Adversary
Latest news
Latest news
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Y
Y Combinator Blog
G
Google Developers Blog
NISL@THU
NISL@THU
H
Heimdal Security Blog
L
LangChain Blog
T
Troy Hunt's Blog
I
InfoQ
U
Unit 42
C
Check Point Blog
Engineering at Meta
Engineering at Meta

博客园 - 阿修罗一平

IIS部署WCF出现的各种问题汇总 Infragistics控件的工具栏注册 Linq备忘 Nihibernate的重要知识点 Devexpress使用记录 使用List数据集合,利用DevExpress.XtraReports开发Master-Detail报表 PDA访问WCF PDA(WinCE)项目开发中遇到的问题及解决方法总结 Grid控件绑定bindingSource后在新增行时设置Cell的初始值 “BindingSource绑定单个实体对象后在代码中赋值无效和无法显示”的解决方法 sqlservier2005转成sqlserver2000中出现的问题(WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) 项目考虑因素及解决方案(.net) 设计模式在工作中的应用(三) 设计模式在工作中的应用(二) 设计模式在工作中的应用(一) NHibernate示例 Remoting服务集成到IIS的简单总结 关于Remoting服务启动和停止的简单总结 将公司系统从SqlServer 2K移植到Oracle 10g中的简要总结
NUnit的使用中可能遇到的问题
阿修罗一平 · 2011-05-06 · via 博客园 - 阿修罗一平

1、需要使用配置文件

我们在使用NUnit做单元测试的时候,逻辑代码中可能会使用到应用的配置文件里的数据,比如常见的App.config的数据库连接字符串。解决方法就是将配置文件(如App.config)放在测试项目中,偷懒的话就设置为“始终复制”,编译并测试项目,就可访问配置文件中的数据了。

<configuration>
 <appSettings>
  <add key="DALTYPE" value="VLP2011.SQLServerDAL"/>
  <add key="CONNECTIONSTRING" value="server=YIPING\SQLSERVER2005;database=VPL2011_BaseDB;uid=sa;pwd=sa"/>
 </appSettings>
</configuration>

string ConnectionString = ConfigurationManager.AppSettings["CONNECTIONSTRING"];
Console.WriteLine("连接字符串:" + path);