Address PR comments to improve test readability and reliability

This commit is contained in:
Justin Goshi 2016-10-31 20:50:52 -07:00
parent 45ccc74ace
commit f9493545dc
2 changed files with 26 additions and 16 deletions

View file

@ -104,30 +104,36 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
break;
case ProjectType.Test:
_transformApplicator.Execute(
PackageDependencyInfoTransform.Transform(
PackageDependencyInfoTransform().Transform(
new PackageDependencyInfo
{
Name = PackageConstants.TestSdkPackageName,
Version = PackageConstants.TestSdkPackageVersion
}), noFrameworkPackageReferenceItemGroup, mergeExisting: false);
}),
noFrameworkPackageReferenceItemGroup,
mergeExisting: false);
if (project.TestRunner.Equals("xunit", StringComparison.OrdinalIgnoreCase))
{
_transformApplicator.Execute(
PackageDependencyInfoTransform.Transform(
PackageDependencyInfoTransform().Transform(
new PackageDependencyInfo
{
Name = PackageConstants.XUnitPackageName,
Version = PackageConstants.XUnitPackageVersion
}), noFrameworkPackageReferenceItemGroup, mergeExisting: false);
}),
noFrameworkPackageReferenceItemGroup,
mergeExisting: false);
_transformApplicator.Execute(
PackageDependencyInfoTransform.Transform(
PackageDependencyInfoTransform().Transform(
new PackageDependencyInfo
{
Name = PackageConstants.XUnitRunnerPackageName,
Version = PackageConstants.XUnitRunnerPackageVersion
}), noFrameworkPackageReferenceItemGroup, mergeExisting: false);
}),
noFrameworkPackageReferenceItemGroup,
mergeExisting: false);
}
break;
default:

View file

@ -272,12 +272,14 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
""testRunner"": ""mstest""
}");
var items = mockProj.Items
.Where(i => (i.Include == "Microsoft.NET.Test.Sdk" && i.ItemType == "PackageReference") ||
(i.Include == "xunit" && i.ItemType == "PackageReference") ||
(i.Include == "xunit.runner.visualstudio" && i.ItemType == "PackageReference"));
mockProj.Items.Should().ContainSingle(
i => (i.Include == "Microsoft.NET.Test.Sdk" && 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]
@ -294,12 +296,14 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
""testRunner"": ""xunit""
}");
var items = mockProj.Items
.Where(i => (i.Include == "Microsoft.NET.Test.Sdk" && i.ItemType == "PackageReference") ||
(i.Include == "xunit" && i.ItemType == "PackageReference") ||
(i.Include == "xunit.runner.visualstudio" && i.ItemType == "PackageReference"));
mockProj.Items.Should().ContainSingle(
i => (i.Include == "Microsoft.NET.Test.Sdk" && 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)