diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..7995797 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[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