Add test to ensure refresh dependencies' consistency
This commit is contained in:
parent
4c475002ec
commit
64c49d972a
3 changed files with 42 additions and 11 deletions
|
@ -200,15 +200,10 @@ namespace Microsoft.DotNet.ProjectModel.Server
|
|||
_configure.Value = message.Payload.GetValue("Configuration");
|
||||
break;
|
||||
case MessageTypes.RefreshDependencies:
|
||||
_refreshDependencies.Value = false;
|
||||
break;
|
||||
case MessageTypes.RestoreComplete:
|
||||
if (message.Payload.HasValues)
|
||||
{
|
||||
_refreshDependencies.Value = message.Payload.Value<bool>("Reset");
|
||||
}
|
||||
else
|
||||
{
|
||||
_refreshDependencies.Value = true;
|
||||
}
|
||||
_refreshDependencies.Value = message.Payload.HasValues ? message.Payload.Value<bool>("Reset") : true;
|
||||
break;
|
||||
case MessageTypes.FilesChanged:
|
||||
_filesChanged.Value = 0;
|
||||
|
|
|
@ -60,6 +60,11 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
}
|
||||
|
||||
public void SendPayload(string projectPath, string messageType)
|
||||
{
|
||||
SendPayload(projectPath, messageType, new { });
|
||||
}
|
||||
|
||||
public void SendPayload(string projectPath, string messageType, object payload)
|
||||
{
|
||||
int contextId;
|
||||
if (!_projectContexts.TryGetValue(projectPath, out contextId))
|
||||
|
@ -67,7 +72,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
Assert.True(false, $"Unable to resolve context for {projectPath}");
|
||||
}
|
||||
|
||||
SendPayload(contextId, messageType);
|
||||
SendPayload(contextId, messageType, payload);
|
||||
}
|
||||
|
||||
public void SendPayload(int contextId, string messageType)
|
||||
|
|
|
@ -8,7 +8,6 @@ using System.Linq;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
|
@ -58,6 +57,38 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(MessageTypes.RefreshDependencies, null)]
|
||||
[InlineData(MessageTypes.RestoreComplete, null)]
|
||||
[InlineData(MessageTypes.RestoreComplete, true)]
|
||||
[InlineData(MessageTypes.RestoreComplete, false)]
|
||||
public void RefreshDependenciesResultsAreConsistent(string messageType, bool? clearCache)
|
||||
{
|
||||
var projectPath = Path.Combine(_testAssetsManager.AssetsRoot, "EmptyNetCoreApp");
|
||||
Assert.True(Directory.Exists(projectPath));
|
||||
|
||||
using (var server = new DthTestServer())
|
||||
using (var client = new DthTestClient(server))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
var originalDependencies = client.DrainMessage(7).Single(m => m.MessageType == MessageTypes.Dependencies)
|
||||
.RetrievePayloadAs<JObject>();
|
||||
|
||||
if (clearCache.HasValue)
|
||||
{
|
||||
client.SendPayload(projectPath, messageType, new { Reset = clearCache.Value });
|
||||
}
|
||||
else
|
||||
{
|
||||
client.SendPayload(projectPath, messageType);
|
||||
}
|
||||
|
||||
var refreshedDependencies = client.DrainTillFirst(MessageTypes.Dependencies).Payload.ToString();
|
||||
|
||||
Assert.Equal(originalDependencies.ToString(), refreshedDependencies.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DependencyDiagnsoticsAfterDependencies()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue