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": { "frameworks": {
"dnxcore50": { "dnxcore50": {
"dependencies":{ "dependencies":{
"System.Runtime": "4.0.21-beta-*", "NETStandard.Library": "1.0.0-rc2-23811",
"System.Console": "4.0.0-beta-*" "System.Console": "4.0.0-beta-*"
} }
} }

View file

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

View file

@ -2,7 +2,7 @@
"frameworks": { "frameworks": {
"dnxcore50": { "dnxcore50": {
"dependencies": { "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(); CleanNuGetTempCache();
var dotnet = DotNetCli.Stage2; var dotnet = DotNetCli.Stage2;
dotnet.Restore("--fallbacksource", Dirs.TestPackages) dotnet.Restore("--fallbacksource", Dirs.TestPackages)
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects")) .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects"))
.Execute().EnsureSuccessful(); .Execute().EnsureSuccessful();
// The 'ProjectModelServer' directory contains intentionally-unresolved dependencies, so don't check for success. Also, suppress the output // 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")) dotnet.Restore()
.CaptureStdErr() .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer", "DthTestProjects"))
.CaptureStdOut() .Execute();
dotnet.Restore()
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer", "DthUpdateSearchPathSample"))
.Execute(); .Execute();
return c.Success(); return c.Success();

View file

@ -24,7 +24,7 @@ namespace Microsoft.DotNet.ProjectModel
public override string ToString() 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) internal static FileFormatException Create(Exception exception, string filePath)

View file

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