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");
|
_configure.Value = message.Payload.GetValue("Configuration");
|
||||||
break;
|
break;
|
||||||
case MessageTypes.RefreshDependencies:
|
case MessageTypes.RefreshDependencies:
|
||||||
|
_refreshDependencies.Value = false;
|
||||||
|
break;
|
||||||
case MessageTypes.RestoreComplete:
|
case MessageTypes.RestoreComplete:
|
||||||
if (message.Payload.HasValues)
|
_refreshDependencies.Value = message.Payload.HasValues ? message.Payload.Value<bool>("Reset") : true;
|
||||||
{
|
|
||||||
_refreshDependencies.Value = message.Payload.Value<bool>("Reset");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_refreshDependencies.Value = true;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MessageTypes.FilesChanged:
|
case MessageTypes.FilesChanged:
|
||||||
_filesChanged.Value = 0;
|
_filesChanged.Value = 0;
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||||
{
|
{
|
||||||
// Avoid Socket exception 10006 on Linux
|
// Avoid Socket exception 10006 on Linux
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
|
|
||||||
_socket = new Socket(AddressFamily.InterNetwork,
|
_socket = new Socket(AddressFamily.InterNetwork,
|
||||||
SocketType.Stream,
|
SocketType.Stream,
|
||||||
ProtocolType.Tcp);
|
ProtocolType.Tcp);
|
||||||
|
@ -60,6 +60,11 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendPayload(string projectPath, string messageType)
|
public void SendPayload(string projectPath, string messageType)
|
||||||
|
{
|
||||||
|
SendPayload(projectPath, messageType, new { });
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendPayload(string projectPath, string messageType, object payload)
|
||||||
{
|
{
|
||||||
int contextId;
|
int contextId;
|
||||||
if (!_projectContexts.TryGetValue(projectPath, out 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}");
|
Assert.True(false, $"Unable to resolve context for {projectPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
SendPayload(contextId, messageType);
|
SendPayload(contextId, messageType, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendPayload(int contextId, string messageType)
|
public void SendPayload(int contextId, string messageType)
|
||||||
|
|
|
@ -8,7 +8,6 @@ using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.DotNet.Cli.Utils;
|
|
||||||
using Microsoft.DotNet.ProjectModel.Graph;
|
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;
|
||||||
|
@ -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]
|
[Fact]
|
||||||
public void DependencyDiagnsoticsAfterDependencies()
|
public void DependencyDiagnsoticsAfterDependencies()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue