依赖于文件的.net核心asp.net单元测试 – appsettings.json –
发布时间:2020-12-15 20:46:51 所属栏目:asp.Net 来源:网络整理
导读:我创建了一个asp.net点网核心rtm(1.0.0-preview2-003121). 它使用ConfigurationBuilder从appsettings.json生成配置: public Startup(IHostingEnvironment env){ var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile(
我创建了一个asp.net点网核心rtm(1.0.0-preview2-003121).
它使用ConfigurationBuilder从appsettings.json生成配置: public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json",optional: false,reloadOnChange: true); Configuration = builder.Build(); } 我也试过’.SetBasePath(Directory.GetCurrentDirectory())` 现在我的单元测试(在另一个项目中)我正在构建一个内存主机: _server = new TestServer(new WebHostBuilder().UseStartup<Startup>()); _client = _server.CreateClient(); 我试过了: _server = new TestServer( new WebHostBuilder() .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup<Startup>()); _client = _server.CreateClient(); 我的Travis.yml文件很标准: install: # Install .net using linux CLI commands - sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' - sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893 - sudo apt-get update - sudo apt-get -qq install dotnet-dev-1.0.0-preview2-003121 - sudo apt-get install dotnet-hostfxr-1.0.2 script: - dotnet restore - dotnet build src/Speakr.WebApp.Site - dotnet build tests/Speakr.WebApp.Site.Tests - dotnet test tests/Speakr.WebApp.Site.Tests -f netcoreapp1.0 在本地,所有工作和建设.在Windows和Ubuntu上. 有没有人见过这个? 纳达! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Safari和Asp.net中的cookie存在奇怪的问题
- asp.net-mvc – 我的ASP.NET MVC应用程序是否正确构建?
- ASP.NET成员提供程序 – 单一登录
- asp.net-mvc – 在2015年的MVC 5 Razor视图中减少VS 2017 I
- asp.net渲染折线图
- asp.net – 如何使用IdentityServer v3保护IdentityManager
- asp.net – 如何绑定一个MemoryStream到asp:图像控件?
- asp.net-mvc – 如何在ASP.NET MVC中围绕AreaRegistration.
- asp.net-mvc-4 – 如何在MVC4中删除必需的属性,尽管模型中已
- ASP.NET MVC对DateTime有什么格式,以便模型绑定能够正常工作
推荐文章
站长推荐
- asp.net-core – 如何将IHttpContextAccessor注入
- asp.net – 尝试通过IP地址保护文件夹中的所有as
- asp.net – Crystal Report Viewer按钮在Google
- asp.net-mvc – 如何利用Resharper的“导航到控制
- asp.net – MvcTextTemplateHost未找到
- asp.net – 如何使用&在web.config文件
- asp.net – 无法使用URL重写出站规则来更改IIS响
- asp.net-core – 通过JWT Token授权
- 禁用并选择asp.net mvc Html.RadioButtonFor
- 禁用ASP.NET HttpHandler响应缓存
热点阅读