Add tests to capture issue 1568
This commit is contained in:
parent
ab5df03700
commit
78433197b3
6 changed files with 96 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue