我有一个Test类,其设置如下
public Test()
{
ClientFactory.AddHost("Api", options =>
{
options.HostUri = "https://localhost:44300";
});
}
以及如下运行单元测试的功能
var result = await ClientFactory.For<IConfigurationService>()
.ExecuteAsync(e => e.GetList());
Assert.Greater(result.Data?.Count, 0);
上面的代码是一个URI并通过HTTP调用Web API。
问题是,当我在“测试资源管理器”中选择“运行所有单元测试”时,它可以工作,而在选择“运行选定的测试”时,它会失败。它总是抛出以下错误,表示访问被拒绝。我对此错误一无所知。我做了一些尝试,但没有成功,如下所示:
错误是
Message: System.Exception : <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link href="http://10.84.0.50/media/css/error.css" type="text/css" rel="StyleSheet" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title>ERROR: The requested URL could not be retrieved</title>
<style type="text/css">
<!-- /*
* Copyright (C) 1996-2019 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
* Please see the COPYING and CONTRIBUTORS files for details.
*/
/*
Stylesheet for Squid Error pages
Adapted from design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
*/
/* Page basics */
* {
font-family: verdana, sans-serif;
}
html body {
margin: 0;
padding: 0;
background: #efefef;
font-size: 12px;
color: #1e1e1e;
}
/* Page displayed title area */
#titles {
margin-left: 15px;
padding: 10px;
padding-left: 100px;
background: url('/squid-internal-static/icons/SN.png') no-repeat left;
}
/* initial title */
#titles h1 {
color: #000000;
}
#titles h2 {
color: #000000;
}
/* special event: FTP success page titles */
#titles ftpsuccess {
background-color:#00ff00;
width:100%;
}
/* Page displayed body content area */
#content {
padding: 10px;
background: #ffffff;
}
/* General text */
p {
}
/* error brief description */
#error p {
}
/* some data which may have caused the problem */
#data {
}
/* the error message received from the system or other software */
#sysmsg {
}
pre {
}
/* special event: FTP / Gopher directory listing */
#dirmsg {
font-family: courier, monospace;
color: black;
font-size: 10pt;
}
#dirlisting {
margin-left: 2%;
margin-right: 2%;
}
#dirlisting tr.entry td.icon,td.filename,td.size,td.date {
border-bottom: groove;
}
#dirlisting td.size {
width: 50px;
text-align: right;
padding-right: 5px;
}
/* horizontal lines */
hr {
margin: 0;
}
/* page displayed footer area */
#footer {
font-size: 9px;
padding-left: 10px;
}
body :lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; } :lang(he) { direction: rtl; } -->
</style>
</head>
<body id="ERR_ACCESS_DENIED">
<div id="titles">
<h1>ERROR</h1>
<h2>The requested URL could not be retrieved</h2>
</div>
<hr>
<div id="content">
<p>The following error was encountered while trying to retrieve the
URL: <a href="localhost:44300">localhost:44300</a></p>
<blockquote id="error">
<p><b>Access Denied.</b></p>
</blockquote>
<p>Access control configuration prevents your request from being
allowed at this time. Please contact your service provider if you
feel this is incorrect.</p>
<p>Your cache administrator is <a href="mailto:servicedesk@mail.com?subject=CacheErrorInfo%20-%20ERR_ACCESS_DENIED&body=CacheHost%3A%20proxy01.mail.com%0D%0AErrPage%3A%20ERR_ACCESS_DENIED%0D%0AErr%3A%20%5Bnone%5D%0D%0ATimeStamp%3A%20Fri,%2028%20Jun%202019%2008%3A33%3A19%20GMT%0D%0A%0D%0AClientIP%3A%2010.0.1.10%0D%0A%0D%0AHTTP%20Request%3A%0D%0ACONNECT%20%20HTTP%2F1.1%0AHost%3A%20localhost%3A44300%0D%0A%0D%0A%0D%0A">servicedesk@mail.com</a>.</p>
<br></div>
<hr>
<div id="footer">
<p>Generated Fri, 28 Jun 2019 08:33:19 GMT by proxy01.mail.com (squid/4.6)</p>
<!-- ERR_ACCESS_DENIED --></div>
</body>
</html>
您能帮我吗?我正在使用VS 2017、2019
谢谢