Add tests to capture issue 1568
This commit is contained in:
parent
ab5df03700
commit
78433197b3
6 changed files with 96 additions and 0 deletions
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"dependencies": {
|
||||
"
|
||||
},
|
||||
"frameworks": {
|
||||
[]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"projects": ["src"]]
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
|
||||
<clear />
|
||||
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
12
TestAssets/ProjectModelServer/IncorrectGlobalJson/src/Project1/Program.cs
Executable file
12
TestAssets/ProjectModelServer/IncorrectGlobalJson/src/Project1/Program.cs
Executable file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace ConsoleApplication
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
14
TestAssets/ProjectModelServer/IncorrectGlobalJson/src/Project1/project.json
Executable file
14
TestAssets/ProjectModelServer/IncorrectGlobalJson/src/Project1/project.json
Executable file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ 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;
|
||||
|
@ -286,5 +287,53 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvalidProjectJson()
|
||||
{
|
||||
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"));
|
||||
|
||||
// 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"));
|
||||
|
||||
// Successfully initialize the other project
|
||||
messages.Single(msg => msg.MessageType == MessageTypes.ProjectInformation)
|
||||
.Payload.AsJObject()
|
||||
.AssertProperty<string>("Name", v => string.Equals(v, "EmptyLibrary", StringComparison.Ordinal));
|
||||
|
||||
// Successfully initialize another project afterwards
|
||||
client.Initialize(Path.Combine(_testAssetsManager.AssetsRoot, "EmptyConsoleApp"));
|
||||
messages = client.DrainAllMessages();
|
||||
messages.Single(msg => msg.MessageType == MessageTypes.ProjectInformation)
|
||||
.Payload.AsJObject()
|
||||
.AssertProperty<string>("Name", v => string.Equals(v, "EmptyConsoleApp", StringComparison.Ordinal));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvalidGlobalJson()
|
||||
{
|
||||
var testAssetsPath = Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer");
|
||||
var assetsManager = new TestAssetsManager(testAssetsPath);
|
||||
var testSource = assetsManager.CreateTestInstance("IncorrectGlobalJson");
|
||||
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(Path.Combine(testSource.TestRoot, "src", "Project1"));
|
||||
|
||||
var messages = client.DrainAllMessages();
|
||||
messages.ContainsMessage(MessageTypes.Error)
|
||||
.Single().Payload.AsJObject()
|
||||
.AssertProperty<string>("Path", v => v.Contains("InvalidGlobalJson"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue