Moved ProjectModel to json.net for GlobalSettings and Project.json. Kept LockFileReader using the old API as I don't have the cycles to add the tests for it at the moment.

Added unit tests covering parsing of Json for all the pieces of the project.json

Added a RawRuntimeOptions to Project and made Executable deserialize that into the runtimeOptions of runtimeconfig.json

Added tests to cover copying runtimeoptions during dotnet build.
This commit is contained in:
Livar Cunha 2016-03-31 16:25:52 -07:00
parent 60b23d5115
commit 7b209e5603
24 changed files with 1771 additions and 247 deletions

View file

@ -8,6 +8,8 @@ using Microsoft.Extensions.PlatformAbstractions;
using Xunit;
using System.Linq;
using Microsoft.DotNet.TestFramework;
using Newtonsoft.Json.Linq;
using FluentAssertions;
namespace Microsoft.DotNet.Tools.Builder.Tests
{
@ -24,6 +26,41 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
netstandardappOutput.Should().Exist().And.HaveFile("StandaloneApp.runtimeconfig.dev.json");
}
[Fact]
public void BuildingAStandAloneProjectProducesARuntimeConfigJsonFile()
{
var testInstance = TestAssetsManager.CreateTestInstance("PortableTests")
.WithLockFiles();
var netstandardappOutput = Build(testInstance);
netstandardappOutput.Should().Exist().And.HaveFile("StandaloneApp.runtimeconfig.json");
}
[Fact]
public void TheRuntimeOptionsGetsCopiedFromProjectJsonToRuntimeConfigJson()
{
var testInstance = TestAssetsManager.CreateTestInstance("PortableTests")
.WithLockFiles();
var netstandardappOutput = Build(testInstance);
var runtimeConfigJsonPath = Path.Combine(netstandardappOutput.FullName, "StandaloneApp.runtimeconfig.json");
using (var stream = new FileStream(runtimeConfigJsonPath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
var reader = new StreamReader(stream);
var rawProject = JObject.Parse(reader.ReadToEnd());
var runtimeOptions = rawProject["runtimeOptions"];
runtimeOptions["somethingString"].Value<string>().Should().Be("anything");
runtimeOptions["somethingBoolean"].Value<bool>().Should().BeTrue();
runtimeOptions["someArray"].ToObject<string[]>().Should().Contain("one", "two");
runtimeOptions["someObject"].Value<JObject>()["someProperty"].Value<string>().Should().Be("someValue");
}
}
public DirectoryInfo Build(TestInstance testInstance)
{
var projectPath = Path.Combine(testInstance.TestRoot, "StandaloneApp");