<i id='hnWpW'><tr id='hnWpW'><dt id='hnWpW'><q id='hnWpW'><span id='hnWpW'><b id='hnWpW'><form id='hnWpW'><ins id='hnWpW'></ins><ul id='hnWpW'></ul><sub id='hnWpW'></sub></form><legend id='hnWpW'></legend><bdo id='hnWpW'><pre id='hnWpW'><center id='hnWpW'></center></pre></bdo></b><th id='hnWpW'></th></span></q></dt></tr></i><div id='hnWpW'><tfoot id='hnWpW'></tfoot><dl id='hnWpW'><fieldset id='hnWpW'></fieldset></dl></div>

      <bdo id='hnWpW'></bdo><ul id='hnWpW'></ul>

    <tfoot id='hnWpW'></tfoot>

    <legend id='hnWpW'><style id='hnWpW'><dir id='hnWpW'><q id='hnWpW'></q></dir></style></legend>

    1. <small id='hnWpW'></small><noframes id='hnWpW'>

    2. 如何在 NUnit 中初始化 ConnectionStrings 集合

      How to initialize ConnectionStrings collection in NUnit(如何在 NUnit 中初始化 ConnectionStrings 集合)
    3. <i id='C5h6o'><tr id='C5h6o'><dt id='C5h6o'><q id='C5h6o'><span id='C5h6o'><b id='C5h6o'><form id='C5h6o'><ins id='C5h6o'></ins><ul id='C5h6o'></ul><sub id='C5h6o'></sub></form><legend id='C5h6o'></legend><bdo id='C5h6o'><pre id='C5h6o'><center id='C5h6o'></center></pre></bdo></b><th id='C5h6o'></th></span></q></dt></tr></i><div id='C5h6o'><tfoot id='C5h6o'></tfoot><dl id='C5h6o'><fieldset id='C5h6o'></fieldset></dl></div>

      1. <legend id='C5h6o'><style id='C5h6o'><dir id='C5h6o'><q id='C5h6o'></q></dir></style></legend>

        <small id='C5h6o'></small><noframes id='C5h6o'>

          <bdo id='C5h6o'></bdo><ul id='C5h6o'></ul>
            <tfoot id='C5h6o'></tfoot>

                <tbody id='C5h6o'></tbody>

                本文介绍了如何在 NUnit 中初始化 ConnectionStrings 集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想使用 NUnit 测试 ASP.NET 应用程序,但是从 NUnit GUI 运行时,WebConfigurationManager.ConnectionStrings 集合似乎是空的.

                I want to test ASP.NET application using NUnit, but it seems WebConfigurationManager.ConnectionStrings collection is empty when running from NUnit GUI.

                你能告诉我如何初始化这个集合吗(可能在 [TestFixture] 的 [SetUp] 函数中)?我应该在那里复制 Web.config 吗?

                Could you tell me how to initialize this collection (probably in [SetUp] function of [TestFixture])? Should I copy Web.config somethere?

                谢谢!

                推荐答案

                如果您的单元测试程序集名为 Company.Component.Tests.dll,那么只需确保 Company.Component.Tests.dll.config 存在使用正确的连接字符串.

                If you have your unit-test assembly named Company.Component.Tests.dll, then just make sure that Company.Component.Tests.dll.config is there with the proper connection string.

                此外,将连接提供程序类与配置分离可能是个好主意,这样您就可以灵活地进行持久性(即:从 *.config 切换到其他内容)并更轻松地进行测试.

                Additionally, it might be a good idea to decouple your connection provider class from the configuration, so that you will have flexibility in persistence (i.e.: switching from *.config to something else) and easier testing.

                还可以查看NUnit 如何查找配置文件"

                这篇关于如何在 NUnit 中初始化 ConnectionStrings 集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Using entity Framework with .NET Core and DB2(将实体框架与 .NET Core 和 DB2 结合使用)
                SQL1159 Initialization error with DB2 .NET Data Provider, reason code 10, tokens 0.0.0, 9.7.3(SQL1159 DB2 .NET 数据提供程序的初始化错误,原因代码 10,令牌 0.0.0、9.7.3)
                Geolocation error with IP address 127.0.0.1(IP 地址为 127.0.0.1 的地理定位错误)
                Geolocation web service recommendations(地理位置 Web 服务建议)
                Finding clients location in an ASP.NET page(在 ASP.NET 页面中查找客户端位置)
                Fetch Latitude Longitude by passing postcodes to maps.google.com using Javascript(通过使用 Javascript 将邮政编码传递给 maps.google.com 来获取纬度经度)

                <small id='klqyj'></small><noframes id='klqyj'>

                  <tbody id='klqyj'></tbody>
                  <bdo id='klqyj'></bdo><ul id='klqyj'></ul>
                  <i id='klqyj'><tr id='klqyj'><dt id='klqyj'><q id='klqyj'><span id='klqyj'><b id='klqyj'><form id='klqyj'><ins id='klqyj'></ins><ul id='klqyj'></ul><sub id='klqyj'></sub></form><legend id='klqyj'></legend><bdo id='klqyj'><pre id='klqyj'><center id='klqyj'></center></pre></bdo></b><th id='klqyj'></th></span></q></dt></tr></i><div id='klqyj'><tfoot id='klqyj'></tfoot><dl id='klqyj'><fieldset id='klqyj'></fieldset></dl></div>
                    <tfoot id='klqyj'></tfoot>
                  • <legend id='klqyj'><style id='klqyj'><dir id='klqyj'><q id='klqyj'></q></dir></style></legend>