From 12c93c6c588fa6c41dbd56cd2d094fb26265ec85 Mon Sep 17 00:00:00 2001 From: David Khourshid Date: Tue, 17 Nov 2020 08:52:07 -0500 Subject: [PATCH 1/2] Add test-framework --- .gitmodules | 6 +++++ .vscode/settings.json | 3 +++ ConsoleRunner/Program.cs | 50 +++++++++++++++++++++++++++++++++++++++- test-framework | 1 + 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .gitmodules create mode 100644 .vscode/settings.json create mode 160000 test-framework diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..deeaab6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "core-test-framework"] + path = core-test-framework + url = https://gitlab.com/scion-scxml/core-test-framework.git +[submodule "test-framework"] + path = test-framework + url = https://gitlab.com/scion-scxml/test-framework.git diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..78218b7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.tabSize": 4 +} diff --git a/ConsoleRunner/Program.cs b/ConsoleRunner/Program.cs index 8ebb610..70c4d47 100644 --- a/ConsoleRunner/Program.cs +++ b/ConsoleRunner/Program.cs @@ -6,6 +6,8 @@ using StateChartsDotNet.CoreEngine.ModelProvider.Xml; using StateChartsDotNet.CoreEngine.Abstractions; using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; namespace ConsoleRunner { @@ -14,6 +16,30 @@ public class Foo public dynamic data; } + public class ScxmlTestEventObject + { + [JsonPropertyName("name")] + public string Name { get; set; } + } + + public class ScxmlTestEvent + { + [JsonPropertyName("event")] + public ScxmlTestEventObject Event { get; set; } + + [JsonPropertyName("nextConfiguration")] + public List NextConfiguration { get; set; } + } + + public class ScxmlTest + { + [JsonPropertyName("initialConfiguration")] + public List InitialConfiguration { get; set; } + + [JsonPropertyName("events")] + public List Events { get; set; } + } + class Program { static void Main(string[] args) @@ -30,7 +56,9 @@ static void Main(string[] args) { //task = RunMicrowave(logger); - task = RunForeach(logger); + // task = RunForeach(logger); + + task = RunScxmlTests(logger); } Task.WaitAll(Task.Delay(5000), task); @@ -59,6 +87,26 @@ static Task RunMicrowave(ILogger logger) }); } + static Task RunScxmlTests(ILogger logger) + { + var jsonPath = "../test-framework/test/basic/basic1.json"; + var testJson = System.IO.File.ReadAllText(jsonPath); + + var scxmlTest = JsonSerializer.Deserialize(testJson); + return Run("../test-framework/test/basic/basic1.scxml", logger, async queue => + { + foreach (var item in scxmlTest.Events) + { + Console.WriteLine(item.Event.Name); + queue.Enqueue(new Message(item.Event.Name)); + + + // TODO: verify that the interpreter's state configuration + // contains item.nextConfiguration (sets are equal) + } + }); + } + static Task Run(string xmldoc, ILogger logger, Func, Task> action = null) { var metadata = new XmlModelMetadata(XDocument.Load(xmldoc)); diff --git a/test-framework b/test-framework new file mode 160000 index 0000000..b46a10a --- /dev/null +++ b/test-framework @@ -0,0 +1 @@ +Subproject commit b46a10a1c3a3b1ca5c5cb4bb44ddb5c785611f41 From d810f051be713fde1fe1d382eaf190966f04cbd5 Mon Sep 17 00:00:00 2001 From: David Khourshid Date: Tue, 17 Nov 2020 08:54:25 -0500 Subject: [PATCH 2/2] Remove core-test-framework (wrong one) --- .gitmodules | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index deeaab6..7995797 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "core-test-framework"] - path = core-test-framework - url = https://gitlab.com/scion-scxml/core-test-framework.git [submodule "test-framework"] path = test-framework url = https://gitlab.com/scion-scxml/test-framework.git