Update dotnet projectmodel tests

This commit is contained in:
Troy Dai 2016-02-29 22:09:38 -08:00
parent bcd656daec
commit 9f8906fdac
7 changed files with 18 additions and 12 deletions

View file

@ -3,7 +3,7 @@
"frameworks": {
"dnxcore50": {
"dependencies":{
"System.Runtime": "4.0.21-beta-*",
"NETStandard.Library": "1.0.0-rc2-23811",
"System.Console": "4.0.0-beta-*"
}
}

View file

@ -4,7 +4,7 @@
"frameworks": {
"dnxcore50": {
"dependencies":{
"System.Runtime": "4.0.21-*"
"NETStandard.Library": "1.0.0-rc2-23811"
}
}
}

View file

@ -2,7 +2,7 @@
"frameworks": {
"dnxcore50": {
"dependencies": {
"System.Runtime": "4.0.21-*"
"NETStandard.Library": "1.0.0-rc2-23811"
}
}
},

View file

@ -73,14 +73,18 @@ namespace Microsoft.DotNet.Cli.Build
CleanNuGetTempCache();
var dotnet = DotNetCli.Stage2;
dotnet.Restore("--fallbacksource", Dirs.TestPackages)
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects"))
.Execute().EnsureSuccessful();
// The 'ProjectModelServer' directory contains intentionally-unresolved dependencies, so don't check for success. Also, suppress the output
dotnet.Restore().WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer"))
.CaptureStdErr()
.CaptureStdOut()
dotnet.Restore()
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer", "DthTestProjects"))
.Execute();
dotnet.Restore()
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer", "DthUpdateSearchPathSample"))
.Execute();
return c.Success();

View file

@ -24,7 +24,7 @@ namespace Microsoft.DotNet.ProjectModel
public override string ToString()
{
return $"{Path}({Line},{Column}): Error: {base.ToString()}";
return string.Format("{0}({1},{2}): {3}", Path, Line, Column, base.Message);
}
internal static FileFormatException Create(Exception exception, string filePath)

View file

@ -4,12 +4,10 @@
using System;
using System.IO;
using System.Linq;
using Microsoft.DotNet.ProjectModel.Graph;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.PlatformAbstractions;
using Microsoft.DotNet.TestFramework;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xunit;
@ -291,17 +289,21 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
[Fact]
public void InvalidProjectJson()
{
var testAssetsPath = Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer");
var assetsManager = new TestAssetsManager(testAssetsPath);
var testSource = assetsManager.CreateTestInstance("IncorrectProjectJson").TestRoot;
using (var server = new DthTestServer(_loggerFactory))
using (var client = new DthTestClient(server))
{
client.Initialize(Path.Combine(_testAssetsManager.AssetsRoot, "EmptyLibrary"));
client.Initialize(Path.Combine(_testAssetsManager.AssetsRoot, "BrokenProjectFileSample"));
client.Initialize(testSource);
// Error for invalid project.json
var messages = client.DrainAllMessages();
messages.Single(msg => msg.MessageType == MessageTypes.Error)
.Payload.AsJObject()
.AssertProperty<string>("Path", v => v.Contains("BrokenProjectFileSample"));
.AssertProperty<string>("Path", v => v.Contains("IncorrectProjectJson"));
// Successfully initialize the other project
messages.Single(msg => msg.MessageType == MessageTypes.ProjectInformation)