From de28595f96bc960042d95489000a2c1fce4f842d Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 15 Dec 2024 21:34:12 +0100 Subject: [PATCH 01/11] refactor: move and rename old generator.cs to MSTestGenerator.cs Signed-off-by: Amir --- .../CS/MSTestGenerator.cs | 56 +++---------------- 1 file changed, 9 insertions(+), 47 deletions(-) rename Generator.cs => Generators/CS/MSTestGenerator.cs (62%) diff --git a/Generator.cs b/Generators/CS/MSTestGenerator.cs similarity index 62% rename from Generator.cs rename to Generators/CS/MSTestGenerator.cs index a2500cc..a3c6b49 100644 --- a/Generator.cs +++ b/Generators/CS/MSTestGenerator.cs @@ -6,28 +6,12 @@ using System.Text; using Tenrec.Components; -namespace Tenrec +namespace Tenrec.Generators.CS { - /// - /// Produces code files automatically, generating test code based on Grasshopper files. - /// - /// - /// This must be called once to produce the test files automatically, or every time you add or remove a or add or remove a file from the test folder. - /// - public class Generator + public class MSTestGenerator : IGenerator { - /// - /// Generate a code file containing all the -based tests present in Grasshopper files. - /// - /// The folder containing the Grasshopper files. - /// The folder where to save the source code file. - /// The name of the resulting code file. - /// Language of the code file. Currently only supports "cs"(C#). - /// Testing framework. Currently only supports MSTest. - /// A log of the process. - public static string CreateAutoTestSourceFile(string[] ghTestFolders, - string outputFolder, string outputName = "TenrecGeneratedTests", - string language = "cs", string testFramework = "mstest") + public string CreateAutoTestSourceFile + (string[] ghTestFolders, string outputFolder, string outputName) { var log = new StringBuilder(); var sb = new StringBuilder(); @@ -35,14 +19,10 @@ public static string CreateAutoTestSourceFile(string[] ghTestFolders, var fileName = string.Empty; try { - if (ghTestFolders == null && ghTestFolders.Length == 0) + if (ghTestFolders == null || ghTestFolders.Length == 0) throw new ArgumentNullException(nameof(outputFolder)); if (string.IsNullOrEmpty(outputFolder)) throw new ArgumentNullException(nameof(outputFolder)); - if (!language.Equals("cs")) - throw new NotImplementedException(nameof(language)); - if (!testFramework.Equals("mstest")) - throw new NotImplementedException(nameof(testFramework)); sb.AppendLine("using Microsoft.VisualStudio.TestTools.UnitTesting;"); sb.AppendLine(); @@ -55,7 +35,7 @@ public static string CreateAutoTestSourceFile(string[] ghTestFolders, { foreach (var file in files) { - if (OpenDocument(file, out GH_Document doc)) + if (Utils.IOHelper.OpenDocument(file, out GH_Document doc)) { var groups = new List(); foreach (var obj in doc.Objects) @@ -65,10 +45,10 @@ public static string CreateAutoTestSourceFile(string[] ghTestFolders, groups.Add(obj); } } - if (groups != null && groups.Any()) + if (groups.Any()) { sb.AppendLine(" [TestClass]"); - sb.AppendLine($" public class AutoTest_{CodeableNickname(doc.DisplayName)}"); + sb.AppendLine($" public class AutoTest_{Utils.StringHelper.CodeableNickname(doc.DisplayName)}"); sb.AppendLine(" {"); sb.AppendLine($" public string FilePath => @\"{doc.FilePath}\";"); sb.AppendLine(" private TestContext testContextInstance;"); @@ -76,7 +56,7 @@ public static string CreateAutoTestSourceFile(string[] ghTestFolders, foreach (var group in groups) { sb.AppendLine(" [TestMethod]"); - sb.AppendLine($" public void {CodeableNickname(group.NickName)}()"); + sb.AppendLine($" public void {Utils.StringHelper.CodeableNickname(group.NickName)}()"); sb.AppendLine(" {"); sb.AppendLine($" Tenrec.Runner.Initialize(TestContext);"); sb.AppendLine($" Tenrec.Runner.RunTenrecGroup(FilePath, new System.Guid(\"{group.InstanceGuid}\"), TestContext);"); @@ -111,23 +91,5 @@ public static string CreateAutoTestSourceFile(string[] ghTestFolders, return log.ToString(); } - - private static string CodeableNickname(string nickname) - { - return nickname.Replace(" ", "_"); - } - - private static bool OpenDocument(string filePath, out GH_Document doc) - { - var io = new GH_DocumentIO(); - if (!io.Open(filePath)) - { - doc = null; - throw new Exception($"Failed to open file: {filePath}"); - } - doc = io.Document; - doc.Enabled = true; - return true; - } } } From 1c5d57b7297b070164c100c04829950c476230bd Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 15 Dec 2024 21:35:01 +0100 Subject: [PATCH 02/11] refactor: move OpenDocument function to IOHelper class Signed-off-by: Amir --- Utils/IOHelper.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Utils/IOHelper.cs diff --git a/Utils/IOHelper.cs b/Utils/IOHelper.cs new file mode 100644 index 0000000..547755c --- /dev/null +++ b/Utils/IOHelper.cs @@ -0,0 +1,21 @@ +using Grasshopper.Kernel; +using System; + +namespace Tenrec.Utils +{ + public static class IOHelper + { + public static bool OpenDocument(string filePath, out GH_Document doc) + { + var io = new GH_DocumentIO(); + if (!io.Open(filePath)) + { + doc = null; + throw new Exception($"Failed to open file: {filePath}"); + } + doc = io.Document; + doc.Enabled = true; + return true; + } + } +} From 758fa145d1572ee6f2bc46f728a11870cb70ee5c Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 15 Dec 2024 21:35:46 +0100 Subject: [PATCH 03/11] refactor: move CodeableNickName function to StringHelper Signed-off-by: Amir --- Utils/StringHelper.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Utils/StringHelper.cs diff --git a/Utils/StringHelper.cs b/Utils/StringHelper.cs new file mode 100644 index 0000000..a759cec --- /dev/null +++ b/Utils/StringHelper.cs @@ -0,0 +1,14 @@ +namespace Tenrec.Utils +{ + public static class StringHelper + { + public static string CodeableNickname(string nickname) + { + return nickname.Replace(" ", "_"); + } + public static string IndexedString(string str, int index) + { + return string.Concat(System.Linq.Enumerable.Repeat(" ", index)) + str; + } + } +} From 71db4f253c9dcff3fbcafd4a63a00578f2f9addb Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 15 Dec 2024 21:36:42 +0100 Subject: [PATCH 04/11] feature: Add XUnit Generator class Signed-off-by: Amir --- Generators/CS/XUnitGenerator.cs | 105 ++++++++++++++++++++++++++++++++ Generators/IGenerator.cs | 8 +++ 2 files changed, 113 insertions(+) create mode 100644 Generators/CS/XUnitGenerator.cs create mode 100644 Generators/IGenerator.cs diff --git a/Generators/CS/XUnitGenerator.cs b/Generators/CS/XUnitGenerator.cs new file mode 100644 index 0000000..42d0e56 --- /dev/null +++ b/Generators/CS/XUnitGenerator.cs @@ -0,0 +1,105 @@ +using Grasshopper.Kernel; +using System; +using System.IO; +using System.Linq; +using System.Text; +using Tenrec.Components; +using Tenrec.Utils; + +namespace Tenrec.Generators.CS +{ + public class XUnitGenerator : IGenerator + { + public string CreateAutoTestSourceFile + (string[] ghTestFolders, string outputFolder, string outputName) + { + var log = new StringBuilder(); + var sb = new StringBuilder(); + var exits = false; + var fileName = string.Empty; + try + { + if (ghTestFolders == null || ghTestFolders.Length == 0) + throw new ArgumentNullException(nameof(outputFolder)); + if (string.IsNullOrEmpty(outputFolder)) + throw new ArgumentNullException(nameof(outputFolder)); + + sb.AppendLine("using Xunit;"); + sb.AppendLine("using Xunit.Abstractions;"); + sb.AppendLine(); + sb.AppendLine("namespace TenrecGeneratedTests"); + sb.AppendLine("{"); + foreach (var folder in ghTestFolders) + { + var files = Directory.EnumerateFiles(folder, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".gh") || s.EndsWith(".ghx")); + if (!files.Any()) + { + log.Append($"{folder} does not contain any readable format (.gh|.ghx)"); + continue; + } + foreach (var file in files) + { + if (!IOHelper.OpenDocument(file, out GH_Document doc)) + { + log.Append($"Failed to open {file}."); + continue; + } + var groups = doc.Objects.Where(o => o.ComponentGuid == Group_UnitTest.ID).ToList(); + if (groups.Count == 0) + continue; + sb.AppendLine(StringHelper.IndexedString($"public class AutoTest_{StringHelper.CodeableNickname(doc.DisplayName)}_Fixture : GHFileFixture", 1)); + sb.AppendLine(StringHelper.IndexedString("{", 1)); + sb.AppendLine(StringHelper.IndexedString($"public AutoTest_{StringHelper.CodeableNickname(doc.DisplayName)}_Fixture()", 2)); + sb.AppendLine(StringHelper.IndexedString($" : base(@\"{file}\")", 3)); + sb.AppendLine(StringHelper.IndexedString("{", 2)); + sb.AppendLine(StringHelper.IndexedString("}", 2)); + sb.AppendLine(StringHelper.IndexedString("}", 1)); + + sb.AppendLine(StringHelper.IndexedString($"public class AutoTest_{StringHelper.CodeableNickname(doc.DisplayName)}" + + $" : IClassFixture", 1)); + sb.AppendLine(StringHelper.IndexedString("{", 1)); + + sb.AppendLine(StringHelper.IndexedString($"private readonly AutoTest_{StringHelper.CodeableNickname(doc.DisplayName)}_Fixture fixture;", 2)); + sb.AppendLine(StringHelper.IndexedString("private readonly ITestOutputHelper context;", 2)); + + sb.AppendLine(StringHelper.IndexedString($"public AutoTest_{StringHelper.CodeableNickname(doc.DisplayName)}" + + $" (AutoTest_{StringHelper.CodeableNickname(doc.DisplayName)}_Fixture fixture, " + + $"ITestOutputHelper context)", 2)); + sb.AppendLine(StringHelper.IndexedString("{", 2)); + sb.AppendLine(StringHelper.IndexedString("this.fixture = fixture;", 3)); + sb.AppendLine(StringHelper.IndexedString("this.context = context;", 3)); + sb.AppendLine(StringHelper.IndexedString("}", 2)); + + foreach (var group in groups) + { + sb.AppendLine(StringHelper.IndexedString("[Fact]", 2)); + sb.AppendLine(StringHelper.IndexedString($"public void {StringHelper.CodeableNickname(group.NickName)}()", 2)); + sb.AppendLine(StringHelper.IndexedString("{", 2)); + sb.AppendLine(StringHelper.IndexedString($"fixture.RunGroup(fixture.Doc, new System.Guid(\"{group.InstanceGuid}\"), context);", 3)); + sb.AppendLine(StringHelper.IndexedString("}", 2)); + } + sb.AppendLine(StringHelper.IndexedString("}", 1)); + sb.AppendLine(); + doc.Dispose(); + } + } + sb.AppendLine("}"); + + fileName = Path.Combine(outputFolder, outputName + ".cs"); + exits = File.Exists(fileName); + File.WriteAllText(fileName, sb.ToString()); + } + catch (Exception e) + { + log.AppendLine($"EXCEPTION: {e}."); + } + + if (exits) + log.AppendLine($"File successfully overwritten."); + else + log.AppendLine($"File successfully created."); + + return log.ToString(); + } + } +} diff --git a/Generators/IGenerator.cs b/Generators/IGenerator.cs new file mode 100644 index 0000000..8d9a086 --- /dev/null +++ b/Generators/IGenerator.cs @@ -0,0 +1,8 @@ +namespace Tenrec.Generators +{ + public interface IGenerator + { + string CreateAutoTestSourceFile + (string[] ghTestFolders, string outputFolder, string outputName); + } +} From 8ac61d59c5f4a674918847a5834fa357360dfbb6 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 15 Dec 2024 21:37:14 +0100 Subject: [PATCH 05/11] Add XUnit to the available frameworks Signed-off-by: Amir --- UI/UnitTestsSourceCodeGeneratorForm.Designer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UI/UnitTestsSourceCodeGeneratorForm.Designer.cs b/UI/UnitTestsSourceCodeGeneratorForm.Designer.cs index dd14374..eae5147 100644 --- a/UI/UnitTestsSourceCodeGeneratorForm.Designer.cs +++ b/UI/UnitTestsSourceCodeGeneratorForm.Designer.cs @@ -199,7 +199,7 @@ private void InitializeComponent() this.comboBoxFramework.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxFramework.FormattingEnabled = true; this.comboBoxFramework.Items.AddRange(new object[] { - "MSTest"}); + "MSTest", "XUnit"}); this.comboBoxFramework.Location = new System.Drawing.Point(3, 16); this.comboBoxFramework.Name = "comboBoxFramework"; this.comboBoxFramework.Size = new System.Drawing.Size(192, 21); From d8d295998111837eafa2efab20af23434a3f9078 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 15 Dec 2024 21:38:02 +0100 Subject: [PATCH 06/11] refactor: Add checks for framework Signed-off-by: Amir --- UI/UnitTestsSourceCodeGeneratorForm.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/UI/UnitTestsSourceCodeGeneratorForm.cs b/UI/UnitTestsSourceCodeGeneratorForm.cs index 8b5dc17..149a07b 100644 --- a/UI/UnitTestsSourceCodeGeneratorForm.cs +++ b/UI/UnitTestsSourceCodeGeneratorForm.cs @@ -1,6 +1,8 @@ using System; using System.Drawing; using System.Windows.Forms; +using Tenrec.Generators; +using Tenrec.Generators.CS; namespace Tenrec.UI { @@ -51,7 +53,7 @@ private bool CanGenerate(out string message) } else { - foreach(var folder in folders) + foreach (var folder in folders) { if (!System.IO.Directory.Exists(folder)) { @@ -59,7 +61,7 @@ private bool CanGenerate(out string message) return false; } } - } + } var outputFolder = GetOutputFolder(); if (string.IsNullOrEmpty(outputFolder)) { @@ -101,7 +103,7 @@ private void UpdateState() private void UnitTestsSourceCodeGeneratorForm_Load(object sender, EventArgs e) { var activeDoc = Grasshopper.Instances.ActiveCanvas?.Document; - if(activeDoc != null && !string.IsNullOrEmpty(activeDoc.FilePath)) + if (activeDoc != null && !string.IsNullOrEmpty(activeDoc.FilePath)) { textBoxFiles.Text = System.IO.Path.GetDirectoryName(activeDoc.FilePath); } @@ -122,8 +124,16 @@ private void buttonGenerate_Click(object sender, EventArgs e) var outputFolder = GetOutputFolder(); var outputName = GetOutputName(); var language = GetLanguage(); - var framework = GetFramework(); - textBoxLog.Text = Generator.CreateAutoTestSourceFile(folderFiles, outputFolder, outputName, language, framework); + var framework = GetFramework(); + IGenerator generator = null; + if (language == "cs") + { + if (framework == "mstest") + generator = new MSTestGenerator(); + else if (framework == "xunit") + generator = new XUnitGenerator(); + } + textBoxLog.Text = generator.CreateAutoTestSourceFile(folderFiles, outputFolder, outputName); if (textBoxLog.Text.Contains("successfully")) textBoxLog.ForeColor = Grasshopper.GUI.GH_GraphicsUtil.BlendColour(Color.Green, Color.Black, 0.5); else From 0510f4b3d85e4cdd388974d9c43de840192c92b9 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 15 Dec 2024 21:38:41 +0100 Subject: [PATCH 07/11] Update list of files in project Signed-off-by: Amir --- Tenrec.csproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tenrec.csproj b/Tenrec.csproj index 3817348..9d8bc47 100644 --- a/Tenrec.csproj +++ b/Tenrec.csproj @@ -71,6 +71,9 @@ + + + True @@ -79,7 +82,6 @@ - @@ -90,6 +92,8 @@ UnitTestsSourceCodeGeneratorForm.cs + + From d611b77bea451a2191c13d79aee3c6c92482e845 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 15 Dec 2024 21:39:28 +0100 Subject: [PATCH 08/11] remove SampleTestProjectTenrec project from solution as it is not present in the original repo. Signed-off-by: Amir --- Tenrec.sln | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Tenrec.sln b/Tenrec.sln index 46c3631..dee81bf 100644 --- a/Tenrec.sln +++ b/Tenrec.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 16.0.31229.75 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tenrec", "Tenrec.csproj", "{C0E5FFFB-45D6-41A1-9E5A-342E01327EB3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleTestProjectTenrec", "..\SampleTestProjectTenrec\SampleTestProjectTenrec.csproj", "{C8CF27BE-2BBE-4AD2-A62A-BC55DC3A3C31}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -17,10 +15,6 @@ Global {C0E5FFFB-45D6-41A1-9E5A-342E01327EB3}.Debug|Any CPU.Build.0 = Debug|Any CPU {C0E5FFFB-45D6-41A1-9E5A-342E01327EB3}.Release|Any CPU.ActiveCfg = Release|Any CPU {C0E5FFFB-45D6-41A1-9E5A-342E01327EB3}.Release|Any CPU.Build.0 = Release|Any CPU - {C8CF27BE-2BBE-4AD2-A62A-BC55DC3A3C31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C8CF27BE-2BBE-4AD2-A62A-BC55DC3A3C31}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C8CF27BE-2BBE-4AD2-A62A-BC55DC3A3C31}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C8CF27BE-2BBE-4AD2-A62A-BC55DC3A3C31}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From b9dbd15030180c108e56f7d3f9729435891a2b57 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 15 Dec 2024 21:57:29 +0100 Subject: [PATCH 09/11] Add documentation Signed-off-by: Amir --- Generators/CS/XUnitGenerator.cs | 8 ++++++++ Utils/IOHelper.cs | 3 +++ Utils/StringHelper.cs | 14 ++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/Generators/CS/XUnitGenerator.cs b/Generators/CS/XUnitGenerator.cs index 42d0e56..4983799 100644 --- a/Generators/CS/XUnitGenerator.cs +++ b/Generators/CS/XUnitGenerator.cs @@ -8,6 +8,9 @@ namespace Tenrec.Generators.CS { + /// + /// Creates unit-tests in XUnit framework for selected grasshopper script files containing Tenrec groups. + /// public class XUnitGenerator : IGenerator { public string CreateAutoTestSourceFile @@ -47,6 +50,8 @@ public string CreateAutoTestSourceFile var groups = doc.Objects.Where(o => o.ComponentGuid == Group_UnitTest.ID).ToList(); if (groups.Count == 0) continue; + + #region Crearte_Fixture_Class sb.AppendLine(StringHelper.IndexedString($"public class AutoTest_{StringHelper.CodeableNickname(doc.DisplayName)}_Fixture : GHFileFixture", 1)); sb.AppendLine(StringHelper.IndexedString("{", 1)); sb.AppendLine(StringHelper.IndexedString($"public AutoTest_{StringHelper.CodeableNickname(doc.DisplayName)}_Fixture()", 2)); @@ -54,6 +59,7 @@ public string CreateAutoTestSourceFile sb.AppendLine(StringHelper.IndexedString("{", 2)); sb.AppendLine(StringHelper.IndexedString("}", 2)); sb.AppendLine(StringHelper.IndexedString("}", 1)); + #endregion sb.AppendLine(StringHelper.IndexedString($"public class AutoTest_{StringHelper.CodeableNickname(doc.DisplayName)}" + $" : IClassFixture", 1)); @@ -62,6 +68,7 @@ public string CreateAutoTestSourceFile sb.AppendLine(StringHelper.IndexedString($"private readonly AutoTest_{StringHelper.CodeableNickname(doc.DisplayName)}_Fixture fixture;", 2)); sb.AppendLine(StringHelper.IndexedString("private readonly ITestOutputHelper context;", 2)); + #region Test_Class_Constructor sb.AppendLine(StringHelper.IndexedString($"public AutoTest_{StringHelper.CodeableNickname(doc.DisplayName)}" + $" (AutoTest_{StringHelper.CodeableNickname(doc.DisplayName)}_Fixture fixture, " + $"ITestOutputHelper context)", 2)); @@ -69,6 +76,7 @@ public string CreateAutoTestSourceFile sb.AppendLine(StringHelper.IndexedString("this.fixture = fixture;", 3)); sb.AppendLine(StringHelper.IndexedString("this.context = context;", 3)); sb.AppendLine(StringHelper.IndexedString("}", 2)); + #endregion foreach (var group in groups) { diff --git a/Utils/IOHelper.cs b/Utils/IOHelper.cs index 547755c..2e87db8 100644 --- a/Utils/IOHelper.cs +++ b/Utils/IOHelper.cs @@ -3,6 +3,9 @@ namespace Tenrec.Utils { + /// + /// Contains helper classes for input/output operations used in Tenrec project. + /// public static class IOHelper { public static bool OpenDocument(string filePath, out GH_Document doc) diff --git a/Utils/StringHelper.cs b/Utils/StringHelper.cs index a759cec..bbc877c 100644 --- a/Utils/StringHelper.cs +++ b/Utils/StringHelper.cs @@ -1,11 +1,25 @@ namespace Tenrec.Utils { + /// + /// Contains helper classes for string manipulation required in Tenrec project. + /// public static class StringHelper { + /// + /// Replaces all spaces in the string with '_' + /// + /// source string + /// source string without any spaces (all spaces replaced with '_') public static string CodeableNickname(string nickname) { return nickname.Replace(" ", "_"); } + /// + /// Adds identation based on provided index. index can start from 0 (no identation). + /// + /// source string + /// level of identation desired. + /// An identated string public static string IndexedString(string str, int index) { return string.Concat(System.Linq.Enumerable.Repeat(" ", index)) + str; From d3a54e29812258625e68cdf9f7b6e16a5332f7e1 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 15 Dec 2024 22:50:03 +0100 Subject: [PATCH 10/11] doc: Update doc Signed-off-by: Amir --- Generators/CS/MSTestGenerator.cs | 13 +++++++++++++ Generators/CS/XUnitGenerator.cs | 12 +++++++++++- Generators/IGenerator.cs | 13 +++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Generators/CS/MSTestGenerator.cs b/Generators/CS/MSTestGenerator.cs index a3c6b49..2cd6d32 100644 --- a/Generators/CS/MSTestGenerator.cs +++ b/Generators/CS/MSTestGenerator.cs @@ -8,8 +8,21 @@ namespace Tenrec.Generators.CS { + /// + /// Produces code files automatically, generating test code based on Grasshopper files. + /// + /// + /// This must be called once to produce the test files automatically, or every time you add or remove a or add or remove a file from the test folder. + /// public class MSTestGenerator : IGenerator { + /// + /// Generate a code file containing all the -based tests present in Grasshopper files. + /// + /// The folder containing the Grasshopper files. + /// The folder where to save the source code file. + /// The name of the resulting code file. + /// A log of the process. public string CreateAutoTestSourceFile (string[] ghTestFolders, string outputFolder, string outputName) { diff --git a/Generators/CS/XUnitGenerator.cs b/Generators/CS/XUnitGenerator.cs index 4983799..efb3237 100644 --- a/Generators/CS/XUnitGenerator.cs +++ b/Generators/CS/XUnitGenerator.cs @@ -9,10 +9,20 @@ namespace Tenrec.Generators.CS { /// - /// Creates unit-tests in XUnit framework for selected grasshopper script files containing Tenrec groups. + /// Produces code files automatically, generating test code based on Grasshopper files. /// + /// + /// This must be called once to produce the test files automatically, or every time you add or remove a or add or remove a file from the test folder. + /// public class XUnitGenerator : IGenerator { + /// + /// Generate a code file containing all the -based tests present in Grasshopper files. + /// + /// The folder containing the Grasshopper files. + /// The folder where to save the source code file. + /// The name of the resulting code file. + /// A log of the process. public string CreateAutoTestSourceFile (string[] ghTestFolders, string outputFolder, string outputName) { diff --git a/Generators/IGenerator.cs b/Generators/IGenerator.cs index 8d9a086..819d14c 100644 --- a/Generators/IGenerator.cs +++ b/Generators/IGenerator.cs @@ -1,7 +1,20 @@ namespace Tenrec.Generators { + /// + /// Produces code files automatically, generating test code based on Grasshopper files. + /// + /// + /// This must be called once to produce the test files automatically, or every time you add or remove a or add or remove a file from the test folder. + /// public interface IGenerator { + /// + /// Generate a code file containing all the -based tests present in Grasshopper files. + /// + /// The folder containing the Grasshopper files. + /// The folder where to save the source code file. + /// The name of the resulting code file. + /// A log of the process. string CreateAutoTestSourceFile (string[] ghTestFolders, string outputFolder, string outputName); } From e5b69def2317471a20ce00773e8518a5ff2fe2e6 Mon Sep 17 00:00:00 2001 From: Amir Date: Sun, 15 Dec 2024 22:53:21 +0100 Subject: [PATCH 11/11] doc: remove duplicate documentation Signed-off-by: Amir --- Generators/CS/MSTestGenerator.cs | 15 ++------------- Generators/CS/XUnitGenerator.cs | 15 ++------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/Generators/CS/MSTestGenerator.cs b/Generators/CS/MSTestGenerator.cs index 2cd6d32..81d0084 100644 --- a/Generators/CS/MSTestGenerator.cs +++ b/Generators/CS/MSTestGenerator.cs @@ -8,21 +8,10 @@ namespace Tenrec.Generators.CS { - /// - /// Produces code files automatically, generating test code based on Grasshopper files. - /// - /// - /// This must be called once to produce the test files automatically, or every time you add or remove a or add or remove a file from the test folder. - /// + /// public class MSTestGenerator : IGenerator { - /// - /// Generate a code file containing all the -based tests present in Grasshopper files. - /// - /// The folder containing the Grasshopper files. - /// The folder where to save the source code file. - /// The name of the resulting code file. - /// A log of the process. + /// public string CreateAutoTestSourceFile (string[] ghTestFolders, string outputFolder, string outputName) { diff --git a/Generators/CS/XUnitGenerator.cs b/Generators/CS/XUnitGenerator.cs index efb3237..80e3a3e 100644 --- a/Generators/CS/XUnitGenerator.cs +++ b/Generators/CS/XUnitGenerator.cs @@ -8,21 +8,10 @@ namespace Tenrec.Generators.CS { - /// - /// Produces code files automatically, generating test code based on Grasshopper files. - /// - /// - /// This must be called once to produce the test files automatically, or every time you add or remove a or add or remove a file from the test folder. - /// + /// public class XUnitGenerator : IGenerator { - /// - /// Generate a code file containing all the -based tests present in Grasshopper files. - /// - /// The folder containing the Grasshopper files. - /// The folder where to save the source code file. - /// The name of the resulting code file. - /// A log of the process. + /// public string CreateAutoTestSourceFile (string[] ghTestFolders, string outputFolder, string outputName) {