dotnet-installer/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateRuntimes.cs
Justin Goshi 6d57ca7e14 Migrating all test projects (#4668)
* WIP migrate tests

* WIP fixing more tests

* WIP fix test build break

* Test results files are now trx

* Get CI to pass until we get an xunit xml logger

* Added DotNetTestPJ since that was needed for one test

* Fix build break

* Forgot to add DotNetTestPJ as a build task

* Need to restore project.json for the project used in ubuntu test

* Restore PJ for ubuntu test

* Switch the Ubuntu test to csproj based
2016-11-11 21:46:29 -10:00

78 lines
2.4 KiB
C#

using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectJsonMigration;
using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.Frameworks;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using FluentAssertions;
using Microsoft.DotNet.ProjectJsonMigration.Rules;
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
{
public class GivenThatIWantToMigrateRuntimes : TestBase
{
[Fact]
public void It_migrates_runtimes()
{
var projectJson = @"
{
""runtimes"": {
""win7-x64"": { },
""win7-x86"": { },
""osx.10.10-x64"": { }
}
}
";
var testDirectory = Temp.CreateDirectory().Path;
var migratedProj = TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
{
new MigrateRuntimesRule()
}, projectJson, testDirectory);
migratedProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(1);
migratedProj.Properties.First(p => p.Name == "RuntimeIdentifiers").Value
.Should().Be("win7-x64;win7-x86;osx.10.10-x64");
}
[Fact]
public void It_has_an_empty_runtime_node_to_migrate()
{
var projectJson = @"
{
""runtimes"": {
}
}
";
var testDirectory = Temp.CreateDirectory().Path;
var migratedProj = TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
{
new MigrateRuntimesRule()
}, projectJson, testDirectory);
migratedProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(0);
}
[Fact]
public void It_has_no_runtimes_to_migrate()
{
var projectJson = @"
{
}
";
var testDirectory = Temp.CreateDirectory().Path;
var migratedProj = TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
{
new MigrateRuntimesRule()
}, projectJson, testDirectory);
migratedProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(0);
}
}
}