Address PR comments to improve test readability and reliability
This commit is contained in:
parent
45ccc74ace
commit
f9493545dc
2 changed files with 26 additions and 16 deletions
|
@ -104,30 +104,36 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
break;
|
break;
|
||||||
case ProjectType.Test:
|
case ProjectType.Test:
|
||||||
_transformApplicator.Execute(
|
_transformApplicator.Execute(
|
||||||
PackageDependencyInfoTransform.Transform(
|
PackageDependencyInfoTransform().Transform(
|
||||||
new PackageDependencyInfo
|
new PackageDependencyInfo
|
||||||
{
|
{
|
||||||
Name = PackageConstants.TestSdkPackageName,
|
Name = PackageConstants.TestSdkPackageName,
|
||||||
Version = PackageConstants.TestSdkPackageVersion
|
Version = PackageConstants.TestSdkPackageVersion
|
||||||
}), noFrameworkPackageReferenceItemGroup, mergeExisting: false);
|
}),
|
||||||
|
noFrameworkPackageReferenceItemGroup,
|
||||||
|
mergeExisting: false);
|
||||||
|
|
||||||
if (project.TestRunner.Equals("xunit", StringComparison.OrdinalIgnoreCase))
|
if (project.TestRunner.Equals("xunit", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
_transformApplicator.Execute(
|
_transformApplicator.Execute(
|
||||||
PackageDependencyInfoTransform.Transform(
|
PackageDependencyInfoTransform().Transform(
|
||||||
new PackageDependencyInfo
|
new PackageDependencyInfo
|
||||||
{
|
{
|
||||||
Name = PackageConstants.XUnitPackageName,
|
Name = PackageConstants.XUnitPackageName,
|
||||||
Version = PackageConstants.XUnitPackageVersion
|
Version = PackageConstants.XUnitPackageVersion
|
||||||
}), noFrameworkPackageReferenceItemGroup, mergeExisting: false);
|
}),
|
||||||
|
noFrameworkPackageReferenceItemGroup,
|
||||||
|
mergeExisting: false);
|
||||||
|
|
||||||
_transformApplicator.Execute(
|
_transformApplicator.Execute(
|
||||||
PackageDependencyInfoTransform.Transform(
|
PackageDependencyInfoTransform().Transform(
|
||||||
new PackageDependencyInfo
|
new PackageDependencyInfo
|
||||||
{
|
{
|
||||||
Name = PackageConstants.XUnitRunnerPackageName,
|
Name = PackageConstants.XUnitRunnerPackageName,
|
||||||
Version = PackageConstants.XUnitRunnerPackageVersion
|
Version = PackageConstants.XUnitRunnerPackageVersion
|
||||||
}), noFrameworkPackageReferenceItemGroup, mergeExisting: false);
|
}),
|
||||||
|
noFrameworkPackageReferenceItemGroup,
|
||||||
|
mergeExisting: false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -272,12 +272,14 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
""testRunner"": ""mstest""
|
""testRunner"": ""mstest""
|
||||||
}");
|
}");
|
||||||
|
|
||||||
var items = mockProj.Items
|
mockProj.Items.Should().ContainSingle(
|
||||||
.Where(i => (i.Include == "Microsoft.NET.Test.Sdk" && i.ItemType == "PackageReference") ||
|
i => (i.Include == "Microsoft.NET.Test.Sdk" && i.ItemType == "PackageReference"));
|
||||||
(i.Include == "xunit" && i.ItemType == "PackageReference") ||
|
|
||||||
(i.Include == "xunit.runner.visualstudio" && i.ItemType == "PackageReference"));
|
|
||||||
|
|
||||||
items.Should().HaveCount(1);
|
mockProj.Items.Should().NotContain(
|
||||||
|
i => (i.Include == "xunit" && i.ItemType == "PackageReference"));
|
||||||
|
|
||||||
|
mockProj.Items.Should().NotContain(
|
||||||
|
i => (i.Include == "xunit.runner.visualstudio" && i.ItemType == "PackageReference"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -294,12 +296,14 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
""testRunner"": ""xunit""
|
""testRunner"": ""xunit""
|
||||||
}");
|
}");
|
||||||
|
|
||||||
var items = mockProj.Items
|
mockProj.Items.Should().ContainSingle(
|
||||||
.Where(i => (i.Include == "Microsoft.NET.Test.Sdk" && i.ItemType == "PackageReference") ||
|
i => (i.Include == "Microsoft.NET.Test.Sdk" && i.ItemType == "PackageReference"));
|
||||||
(i.Include == "xunit" && i.ItemType == "PackageReference") ||
|
|
||||||
(i.Include == "xunit.runner.visualstudio" && i.ItemType == "PackageReference"));
|
|
||||||
|
|
||||||
items.Should().HaveCount(3);
|
mockProj.Items.Should().ContainSingle(
|
||||||
|
i => (i.Include == "xunit" && i.ItemType == "PackageReference"));
|
||||||
|
|
||||||
|
mockProj.Items.Should().ContainSingle(
|
||||||
|
i => (i.Include == "xunit.runner.visualstudio" && i.ItemType == "PackageReference"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EmitsPackageReferences(ProjectRootElement mockProj, params Tuple<string, string, string>[] packageSpecs)
|
private void EmitsPackageReferences(ProjectRootElement mockProj, params Tuple<string, string, string>[] packageSpecs)
|
||||||
|
|
Loading…
Reference in a new issue