Return standalone configuration objects through the editor pipe
This commit is contained in:
parent
534dee0427
commit
c8e14cb5af
@ -19,7 +19,7 @@ public static class ProjectInspection
|
||||
if (operation == "get")
|
||||
{
|
||||
var id = Guid.Parse((string)args["id"]);
|
||||
return rows.SingleOrDefault(row => Guid.Parse((string)row["ID"]) == id)
|
||||
return rows.SingleOrDefault(row => Guid.Parse((string)row["ID"]) == id)?.DeepClone()
|
||||
?? throw new ArgumentException("Object not found.");
|
||||
}
|
||||
if (operation != "list") throw new ArgumentException("Unknown operation.");
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using PLCSharp.Models;
|
||||
using PLCSharp.VVMs.GlobalVariables;
|
||||
using PLCSharp.VVMs.MotionController;
|
||||
using System.IO;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
@ -17,6 +18,8 @@ public class ProjectMcpTests
|
||||
var recipe = project.Recipes.Single();
|
||||
var variable = new Variable { RecipeID = recipe.ID, Name = "Counter", Comment = "old" };
|
||||
project.Data.Add(variable);
|
||||
var point = new AxisPoint { RecipeID = recipe.ID, Name = "定位" };
|
||||
project.Data.Add(point);
|
||||
project.Save(folder.FullName);
|
||||
recipe.Name = "unsaved";
|
||||
var changes = new ProjectChanges();
|
||||
@ -32,6 +35,8 @@ public class ProjectMcpTests
|
||||
new() { ["operation"] = operation, ["arguments"] = args }, () => throw new Exception("Unexpected offline access"));
|
||||
var live = Call("get", new() { ["kind"] = "Recipes", ["id"] = recipe.ID.ToString() });
|
||||
Assert.Equal("unsaved", (string?)live["Name"]);
|
||||
var livePoint = Call("get", new() { ["kind"] = "AxisPoints", ["id"] = point.ID.ToString() });
|
||||
Assert.Equal(point.Name, (string?)livePoint["Name"]);
|
||||
JsonNode Preview() => Call("preview", new() { ["kind"] = "Variables", ["id"] = variable.ID.ToString(), ["comment"] = "new" });
|
||||
JsonNode Apply(JsonNode draft) => Call("apply", new() { ["draftId"] = (string?)draft["DraftId"] });
|
||||
Assert.Equal("rejected", (string?)Apply(Preview())["Status"]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user