Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 118 additions & 57 deletions docs/visualizer-msagl-layout-migration/plan.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class VisualGraphUpdateTests
public TestContext? TestContext { get; set; }

[TestMethod]
public async Task Initial_request_with_null_current_returns_a_full_add_delta()
public async Task VisualGraphUpdate_ForNullCurrent_ReturnsFullAddDelta()
{
using var helper = await StartServerAndOpenAsync();
var client = helper.Helper.Client;
Expand Down Expand Up @@ -60,11 +60,12 @@ public async Task Initial_request_with_null_current_returns_a_full_add_delta()
result.Patches.OfType<GraphPatch.RemoveNode>().Should().BeEmpty();
result.Patches.OfType<GraphPatch.RemoveEdge>().Should().BeEmpty();
result.Patches.OfType<GraphPatch.UpdateNode>().Should().BeEmpty();
result.Patches.OfType<GraphPatch.SetNodeLayout>().Should().BeEmpty();
result.Patches.OfType<GraphPatch.SetErrorCount>().Single().ErrorCount.Should().Be(0);
}

[TestMethod]
public async Task Request_with_matching_current_returns_only_metadata_refresh()
public async Task VisualGraphUpdate_ForMatchingCurrent_ReturnsOnlyMetadataRefresh()
{
using var helper = await StartServerAndOpenAsync();
var client = helper.Helper.Client;
Expand Down Expand Up @@ -92,11 +93,61 @@ public async Task Request_with_matching_current_returns_only_metadata_refresh()
result.Patches.OfType<GraphPatch.RemoveNode>().Should().BeEmpty();
result.Patches.OfType<GraphPatch.AddEdge>().Should().BeEmpty();
result.Patches.OfType<GraphPatch.RemoveEdge>().Should().BeEmpty();
result.Patches.OfType<GraphPatch.SetNodeLayout>().Should().BeEmpty();
result.Patches.OfType<GraphPatch.UpdateNode>().Select(patch => patch.NodeId)
.Should().BeEquivalentTo("res1", "res2", "mod1", "mod1::res3");
result.Patches.OfType<GraphPatch.SetErrorCount>().Single().ErrorCount.Should().Be(0);
}

[TestMethod]
public async Task VisualGraphLayout_ForMeasuredMatchingCurrent_ReturnsLayoutPatches()
{
using var helper = await StartServerAndOpenAsync();
var client = helper.Helper.Client;

var initial = await client.SendRequest(
new VisualGraphUpdateParams(new TextDocumentIdentifier(helper.MainUri), Current: null),
default);

var renderedNodes = initial.Patches.OfType<GraphPatch.AddNode>()
.Select(patch => new RenderedGraphNode(patch.Node.Id, patch.Node.Kind, patch.Node.ParentId, 180, 72))
.ToList();
var renderedEdges = initial.Patches.OfType<GraphPatch.AddEdge>()
.Select(patch => new RenderedGraphEdge(patch.Edge.Id, patch.Edge.SourceId, patch.Edge.TargetId))
.ToList();

var result = await client.SendRequest(
new VisualGraphLayoutParams(
new TextDocumentIdentifier(helper.MainUri),
new RenderedGraph(renderedNodes, renderedEdges),
Options: null),
default);

result.Status.Should().Be(VisualGraphLayoutStatus.Ok);
result.Patches.Should().AllBeOfType<GraphPatch.SetNodeLayout>();
result.Patches.OfType<GraphPatch.SetNodeLayout>().Select(patch => patch.NodeId)
.Should().BeEquivalentTo("res1", "res2", "mod1", "mod1::res3");
result.Patches.OfType<GraphPatch.SetNodeLayout>().Select(patch => patch.Layout)
.Should().OnlyContain(layout => double.IsFinite(layout.X) && double.IsFinite(layout.Y));
}

[TestMethod]
public async Task VisualGraphLayout_ForStaleMeasuredCurrent_ReturnsGraphChanged()
{
using var helper = await StartServerAndOpenAsync();
var client = helper.Helper.Client;
var stale = new RenderedGraph(
Nodes: [new RenderedGraphNode("missing", GraphNodeKind.Resource, ParentId: null, Width: 180, Height: 72)],
Edges: []);

var result = await client.SendRequest(
new VisualGraphLayoutParams(new TextDocumentIdentifier(helper.MainUri), stale, Options: null),
default);

result.Status.Should().Be(VisualGraphLayoutStatus.GraphChanged);
result.Patches.Should().BeEmpty();
}

private async Task<TestServer> StartServerAndOpenAsync()
{
var diagnosticsListener = new MultipleMessageListener<PublishDiagnosticsParams>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private static GraphPatch Deserialize(JToken token) =>
token.ToObject<GraphPatch>(Serializer) ?? throw new InvalidOperationException("Deserialization returned null.");

[TestMethod]
public void ClearGraph_round_trips_and_emits_camelCase_op()
public void ClearGraph_WhenSerialized_RoundTripsWithCamelCaseOp()
{
var patch = new GraphPatch.ClearGraph();

Expand All @@ -39,7 +39,7 @@ public void ClearGraph_round_trips_and_emits_camelCase_op()
}

[TestMethod]
public void AddNode_round_trips_with_camelCase_fields()
public void AddNode_WhenSerialized_RoundTripsWithCamelCaseFields()
{
var node = new GraphNode(
Id: "res:foo",
Expand All @@ -62,7 +62,7 @@ public void AddNode_round_trips_with_camelCase_fields()
}

[TestMethod]
public void RemoveNode_round_trips()
public void RemoveNode_WhenSerialized_RoundTrips()
{
var patch = new GraphPatch.RemoveNode("res:foo");

Expand All @@ -74,7 +74,7 @@ public void RemoveNode_round_trips()
}

[TestMethod]
public void UpdateNode_round_trips_with_partial_changes()
public void UpdateNode_WithPartialChanges_RoundTrips()
{
var patch = new GraphPatch.UpdateNode("res:foo", new GraphNodeChanges(HasError: true));

Expand All @@ -85,7 +85,7 @@ public void UpdateNode_round_trips_with_partial_changes()
}

[TestMethod]
public void AddEdge_round_trips()
public void AddEdge_WhenSerialized_RoundTrips()
{
var patch = new GraphPatch.AddEdge(new GraphEdge("e1", "res:a", "res:b"));

Expand All @@ -96,7 +96,7 @@ public void AddEdge_round_trips()
}

[TestMethod]
public void RemoveEdge_round_trips()
public void RemoveEdge_WhenSerialized_RoundTrips()
{
var patch = new GraphPatch.RemoveEdge("e1");

Expand All @@ -108,7 +108,7 @@ public void RemoveEdge_round_trips()
}

[TestMethod]
public void SetNodeLayout_round_trips()
public void SetNodeLayout_WhenSerialized_RoundTrips()
{
var patch = new GraphPatch.SetNodeLayout("res:foo", new NodeLayout(12.5, -3.25));

Expand All @@ -119,7 +119,7 @@ public void SetNodeLayout_round_trips()
}

[TestMethod]
public void SetErrorCount_round_trips_with_camelCase_op()
public void SetErrorCount_WhenSerialized_RoundTripsWithCamelCaseOp()
{
var patch = new GraphPatch.SetErrorCount(3);

Expand All @@ -131,7 +131,7 @@ public void SetErrorCount_round_trips_with_camelCase_op()
}

[TestMethod]
public void Unknown_op_throws()
public void Deserialize_WithUnknownOp_Throws()
{
var json = new JObject { ["op"] = "bogus" };

Expand Down
Loading
Loading