运行测试后,我在Resharper中看到此警告,所有测试均通过。
2018.08.09 11:11:58.524剩下警告元素Data.Tests.Infra.IntegrationTests.ResolvedIdentityTests 运行完成后等待中。 2018.08.09 11:11:58.524警告元素数据.Tests.Infra.IntegrationTests.ResolvedIdentityTests.Reso离开了 运行完成后将等待处理。
它们是集成测试,它们在测试数据库中设置了一些sql,然后针对该数据库运行测试。
这是完整的测试课程:
namespace Data.Tests.Infra.IntegrationTests
{
using System;
using System.Data.SqlClient;
using System.Threading.Tasks;
using Dapper;
using Infrastructure.Models;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public sealed class ResolvedIdentityTests
{
[ClassInitialize]
public static void Initialise(TestContext context)
{
const string sql = @"insert into infra.tblUnresolvedIdentities
(DeviceId, Fqdn, TimeConflictOccured)
values
('85E33FB5-C321-4EF2-994C-C835F136BA0C', 'unr.test.foo', '2018-08-06 12:16:24.183'),
('D3F32F97-2375-47CC-86E7-37C50ABAC85F', 'unr2.test.foo', '2018-08-06 12:16:24.183')
insert into infra.tblOrg ([Name]) values ('rito')
declare @orgId int = (select OrgId from infra.tblOrg where [Name] = 'rito');
insert into infra.tblSite ([SiteName], [OrgId]) values ('rito.site', @OrgId);
declare @siteId int = (select SiteId from infra.tblSite where [SiteName] = 'rito.site');
insert into infra.tblDevice
(DeviceId, [Name], SiteId)
values
('CE810507-C614-4C65-9675-569EEFFDBC9F', 'unr.test.foo', @siteId),
('94FF1C23-0B7E-41CB-A0F8-058CED0465B3', 'blacklisted.test.foo', @siteId)
insert into infra.tblBlacklistedAgents
(DeviceId, Fqdn)
values
('94FF1C23-0B7E-41CB-A0F8-058CED0465B3', 'rit.test.com')";
RunSql(sql);
}
[ClassCleanup]
public static void Cleanup()
{
const string sql = @"delete from infra.tblBlacklistedAgents where DeviceId = '94FF1C23-0B7E-41CB-A0F8-058CED0465B3'
delete from infra.tblUnresolvedIdentities where DeviceId in ('85E33FB5-C321-4EF2-994C-C835F136BA0C', 'D3F32F97-2375-47CC-86E7-37C50ABAC85F')
delete from infra.tblDevice where DeviceID in( 'CE810507-C614-4C65-9675-569EEFFDBC9F', '94FF1C23-0B7E-41CB-A0F8-058CED0465B3')
delete from infra.tblsite where SiteName = 'rito.site'
delete from infra.tblorg where Name = 'rito'
delete from infra.tblResolvedIdentities where ActualDeviceId = 'CE810507-C614-4C65-9675-569EEFFDBC9F'";
RunSql(sql);
}
private static void RunSql(string sql)
{
using (var sqlConnection = new SqlConnection(Configuration.InitConfiguration()["ConnectionString"]))
sqlConnection.Execute(sql);
}
[TestMethod]
public async Task ResolvedIdentityTests_ShouldResolveAnIdentityAndAddRowToResolvedIdentityTable()
{
var infra = new Infrastructure.Identities(Configuration.InitConfiguration()["ConnectionString"]);
await infra.ResolveIdentity(erroneousDeviceId: new Guid("85E33FB5-C321-4EF2-994C-C835F136BA0C"), actualDeviceId: new Guid("CE810507-C614-4C65-9675-569EEFFDBC9F"));
// now call GetResolvedIdentity so we can verify it was resolved.
var resolvedIdentity = await infra.GetResolvedIdentity(new Guid("85E33FB5-C321-4EF2-994C-C835F136BA0C"));
Assert.AreEqual(actual: resolvedIdentity.ResolvedIdentity.ActualDeviceId, expected: new Guid("CE810507-C614-4C65-9675-569EEFFDBC9F"));
Assert.AreEqual(actual: resolvedIdentity.ResolvedIdentity.SiteName, expected: "rito.site");
Assert.IsFalse(resolvedIdentity.ResolvedIdentity.Id == -1);
Assert.AreEqual(actual: resolvedIdentity.ResolutionStatus, expected: IdentityResolutionState.Resolved);
}
[TestMethod]
public async Task GetResolvedIdenity_ShouldResolveToBlacklisted()
{
var infra = new Infrastructure.Identities(Configuration.InitConfiguration()["ConnectionString"]);
var resolvedIdentity = await infra.GetResolvedIdentity(new Guid("94FF1C23-0B7E-41CB-A0F8-058CED0465B3"));
Assert.AreEqual(actual: resolvedIdentity.ResolutionStatus, expected: IdentityResolutionState.Blacklisted);
Assert.AreEqual(actual: resolvedIdentity.ResolvedIdentity, expected: null);
}
[TestMethod]
public async Task GetResolvedIdenity_ShouldResolveToStillPending()
{
var infra = new Infrastructure.Identities(Configuration.InitConfiguration()["ConnectionString"]);
var resolvedIdentity = await infra.GetResolvedIdentity(new Guid("D3F32F97-2375-47CC-86E7-37C50ABAC85F"));
Assert.AreEqual(actual: resolvedIdentity.ResolutionStatus, expected: IdentityResolutionState.Pending);
Assert.AreEqual(actual: resolvedIdentity.ResolvedIdentity, expected: null);
}
}
}
我不知道为什么这些测试中的任何一个仍将挂起,或者警告甚至是我应该关心的东西。
这是在Resharper测试运行程序中,在MS测试运行程序中运行时未显示警告(但也许它不显示警告?)
答案 0 :(得分:2)
它看起来像是ReSharper中的错误:
答案 1 :(得分:1)
因为这是第一个答案,所以当我在网上搜索时,以上答案都无法解决,这是我的解决方法:
更新Resharper为我解决了这个问题。
即使启用了自动更新,防火墙也会阻止我进行更新。解决方法只是从https://www.jetbrains.com/resharper/download/#section=offline-installer下载脱机安装程序,然后手动更新版本。
版本> 2020.2应该没有这些问题。
答案 2 :(得分:0)
将我的解决方案平台从任何CPU更改为x64都能为我解决此问题。
编辑:由于显然此响应过于模糊,因此我将尝试扩展答案。
我也遇到了此错误,在此错误中,Visual Studio应用程序在完成后将使测试处于待处理状态。尝试在此Stack Overflow帖子及其链接页面上找到解决方案后,我尝试将解决方案平台(位于顶部工具栏中,与保存按钮对齐)更改为x64,而不是任何CPU。这项艰巨的任务显然使一些堆栈溢出用户感到困惑,因此对我的帖子进行了编辑。 Here is a visual of the Visual Studio UI, with the dropdown furthest to the right.
我希望此编辑至少可以减轻我对非常复杂的答案的困惑。对于无法解释您遇到此问题的确切原因,我深感抱歉,因为我不是Microsoft / Resharper员工。为了方便用户,我重申一下,我建议尝试将解决方案平台从任何CPU更改为x64,并观察这是否可以解决Resharper当前遇到的问题。