2016-03-02 01:42:44 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
|
using Xunit;
|
2016-03-29 23:06:10 +00:00
|
|
|
|
using Microsoft.DotNet.TestFramework;
|
2016-03-31 23:25:52 +00:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using FluentAssertions;
|
2016-03-02 01:42:44 +00:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tools.Builder.Tests
|
|
|
|
|
{
|
|
|
|
|
public class BuildPortableTests : TestBase
|
|
|
|
|
{
|
2016-03-29 23:06:10 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void BuildingAPortableProjectProducesDepsJsonFile()
|
|
|
|
|
{
|
|
|
|
|
var testInstance = TestAssetsManager.CreateTestInstance("PortableTests").WithLockFiles();
|
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
var netcoreAppOutput = Build(testInstance);
|
2016-03-29 23:06:10 +00:00
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
netcoreAppOutput.Should().Exist().And.HaveFile("PortableApp.deps.json");
|
2016-03-29 23:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void BuildingAPortableProjectProducesADllFile()
|
|
|
|
|
{
|
|
|
|
|
var testInstance = TestAssetsManager.CreateTestInstance("PortableTests").WithLockFiles();
|
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
var netcoreAppOutput = Build(testInstance);
|
2016-03-29 23:06:10 +00:00
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
netcoreAppOutput.Should().Exist().And.HaveFile("PortableApp.dll");
|
2016-03-29 23:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void BuildingAPortableProjectProducesAPdbFile()
|
|
|
|
|
{
|
|
|
|
|
var testInstance = TestAssetsManager.CreateTestInstance("PortableTests").WithLockFiles();
|
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
var netcoreAppOutput = Build(testInstance);
|
2016-03-29 23:06:10 +00:00
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
netcoreAppOutput.Should().Exist().And.HaveFile("PortableApp.pdb");
|
2016-03-29 23:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void BuildingAPortableProjectProducesARuntimeConfigJsonFile()
|
|
|
|
|
{
|
|
|
|
|
var testInstance = TestAssetsManager.CreateTestInstance("PortableTests").WithLockFiles();
|
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
var netcoreAppOutput = Build(testInstance);
|
2016-03-29 23:06:10 +00:00
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
netcoreAppOutput.Should().Exist().And.HaveFile("PortableApp.runtimeconfig.json");
|
2016-03-29 23:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-31 23:25:52 +00:00
|
|
|
|
[Fact]
|
2016-04-05 19:06:30 +00:00
|
|
|
|
public void RuntimeOptionsGetsCopiedToRuntimeConfigJsonForAPortableApp()
|
2016-03-31 23:25:52 +00:00
|
|
|
|
{
|
|
|
|
|
var testInstance = TestAssetsManager.CreateTestInstance("PortableTests")
|
|
|
|
|
.WithLockFiles();
|
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
var netcoreAppOutput = Build(testInstance);
|
2016-03-31 23:25:52 +00:00
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
var runtimeConfigJsonPath = Path.Combine(netcoreAppOutput.FullName, "PortableApp.runtimeconfig.json");
|
2016-03-31 23:25:52 +00:00
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-29 23:06:10 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void BuildingAPortableProjectProducesARuntimeConfigDevJsonFile()
|
|
|
|
|
{
|
|
|
|
|
var testInstance = TestAssetsManager.CreateTestInstance("PortableTests").WithLockFiles();
|
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
var netcoreAppOutput = Build(testInstance);
|
2016-03-29 23:06:10 +00:00
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
netcoreAppOutput.Should().Exist().And.HaveFile("PortableApp.runtimeconfig.dev.json");
|
2016-03-29 23:06:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DirectoryInfo Build(TestInstance testInstance)
|
|
|
|
|
{
|
2016-03-02 01:42:44 +00:00
|
|
|
|
var result = new BuildCommand(
|
2016-03-09 19:36:16 +00:00
|
|
|
|
projectPath: Path.Combine(testInstance.TestRoot, "PortableApp"))
|
2016-03-02 01:42:44 +00:00
|
|
|
|
.ExecuteWithCapturedOutput();
|
|
|
|
|
|
|
|
|
|
result.Should().Pass();
|
|
|
|
|
|
2016-03-09 19:36:16 +00:00
|
|
|
|
var outputBase = new DirectoryInfo(Path.Combine(testInstance.TestRoot, "PortableApp", "bin", "Debug"));
|
2016-03-02 01:42:44 +00:00
|
|
|
|
|
2016-04-13 00:29:07 +00:00
|
|
|
|
return outputBase.Sub("netcoreapp1.0");
|
2016-03-02 01:42:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|