コード例 #1
0
        public void CreateMindmap_Test()
        {
            var folderPath = Test_Config.TestFolder() + @"text/mm/"; //@"D:\Dev\GitHub\LamedalCore\tests\TestData\Text\mm";

            // Create the map xml doc
            var map    = CreateMindmap();
            var mapStr = map.mm.ToString();
            var result =
                @"<map version=""1.0.1"">
  <!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
</map>";

            Assert.Equal(result, mapStr);

            // Create the root element
            var result2 =
                @"<map version=""1.0.1"">
  <!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
  <node ID=""ID_1"" TEXT=""MindMapEdit"" STYLE=""bubble"">
    <font NAME=""SansSerif"" BOLD=""true"" SIZE=""20"" />
    <icon BUILTIN=""gohome"" />
  </node>
</map>";

            CreateRoot(map, "MindMapEdit");
            var mapStr2 = map.mm.ToString();

            Assert.Equal(result2, mapStr2);

            _lamed.lib.IO.RW.File_Write(folderPath + "simple1.mm", mapStr2, true);
        }
コード例 #2
0
ファイル: ClassNT_Test.cs プロジェクト: LouwrensP/LamedalCore
        public void String_Test()
        {
            #region String_.cs
            var  folderPath = Test_Config.TestFolder(@"Text/cSharp/");
            bool error;
            ClassNTBlueprintRule_ blueprintRule;
            var Class = ClassNT_.Create(folderPath + "String_.cs", out error, out blueprintRule);
            Assert.Equal(enBlueprint_ClassNetworkType.Node_Link, Class.BlueprintRule.ClassType);
            Assert.Equal(7, Class.Properties.Count);
            Assert.Equal(0, Class.Methods.Count);
            Assert.Equal("String_", Class.ClassName);
            Assert.Equal("String_", Class.Header.ClassName);
            Assert.Equal("LamedalCore.Types.String", Class.Header.NameSpace_Name);
            Assert.Equal(115, Class.Statistics.ClassTotalLines);
            Assert.Equal(1, Class.Statistics.ClassTotalBlankLines);
            Assert.Equal(12, Class.Statistics.ClassTotalCodeLines);
            Assert.Equal(3, Class.Statistics.ClassTotalCommentLines);
            Assert.Equal(0, Class.Statistics.TotalMethods);
            Assert.Equal(0, Class.Statistics.TotalFields);
            Assert.Equal(0, Class.Statistics.CodeComplexity);
            Assert.Equal(0, Class.Statistics.CodeMaintainability);
            Assert.Equal(0, Class.Statistics.TotalProperties);
            #endregion

            #region InvalidFile.cs
            Assert.Throws <ArgumentException>(() => ClassNT_.Create(folderPath + "InvalidFile.cs", out error, out blueprintRule));
            #endregion
        }
コード例 #3
0
        public void Execute_Notepad_Test()
        {
            string            folderTest = Test_Config.TestFolder();
            string            folderApplication;
            string            folderTestCases;
            pcTest_ConfigData config;
            string            configFile;
            bool result = _lamed.lib.Test.ConfigSettings(out folderApplication, out folderTestCases, out config, out configFile);

            if (result == false)
            {
                // This code will not be tested
                _lamed.lib.Command.Sleep(1000);  // Sleep 1 more seconds and try again
                result = _lamed.lib.Test.ConfigSettings(out folderApplication, out folderTestCases, out config, out configFile);
                if (result == false)
                {
                    return;                  //<======================================[ Lets give up
                }
            }

            // Lets do the tests
            Assert.Equal(folderTest, folderTestCases);
            Assert.True(_lamed.lib.IO.File.Exists(configFile));

            if (Test_Config.Test_ShowConfigFiles)
            {
                _lamed.lib.Command.Execute_Notepad(configFile);                                     // Hide / show config files
            }
            // Todo
            // Test if notepad is running
            // Kill notepad
            // Test if notepad is running
        }
コード例 #4
0
        public void Drive_Test()
        {
            // Drive & FileInfo
            var dataFolder = Test_Config.TestFolder();
            var appFolder  = _lamed.lib.IO.Folder.Path_Application();

            Assert.True(Test_Config.Test_Drive == _lamed.lib.IO.Parts.Drive(appFolder), $"App Folder: '{appFolder}'".NL() + $"Data Folder: '{dataFolder}'");
        }
コード例 #5
0
ファイル: ClassNT_Test.cs プロジェクト: LouwrensP/LamedalCore
        public void String_Edit_Test()
        {
            var  folderPath = Test_Config.TestFolder(@"Text/cSharp/");
            bool error;
            ClassNTBlueprintRule_ blueprintRule;
            var Class = ClassNT_.Create(folderPath + "String_Edit.cs", out error, out blueprintRule);

            Assert.Equal(0, Class.Properties.Count);
            Assert.Equal(13, Class.Methods.Count);
            Assert.Equal("String_Edit", Class.ClassName);
            Assert.Equal("String_Edit", Class.Header.ClassName);
            Assert.Equal("String", Class.Header.ClassName1);
            Assert.Equal("Edit", Class.Header.ClassName2);
            Assert.Equal("LamedalCore.Types.String", Class.Header.NameSpace_Name);
            Assert.Equal(218, Class.Statistics.ClassTotalLines);
            Assert.Equal(1, Class.Statistics.ClassTotalBlankLines);
            Assert.Equal(12, Class.Statistics.ClassTotalCodeLines);
            Assert.Equal(49, Class.Statistics.ClassTotalCommentLines);
            Assert.Equal(13, Class.Statistics.TotalMethods);
            Assert.Equal(0, Class.Statistics.TotalFields);
            Assert.Equal(32, Class.Statistics.CodeComplexity);
            Assert.Equal(17, Class.Statistics.CodeMaintainability);
            Assert.Equal(0, Class.Statistics.TotalProperties);
        }
コード例 #6
0
ファイル: ClassNT_Test.cs プロジェクト: LouwrensP/LamedalCore
        public void ClassHeaderReadWrite_Test()
        {
            #region Test1: public sealed class Types_Money

            //      ===========================================
            var source = new List <string>
            {
                "using System;",
                "",
                "namespace Blueprint.lib.Rules.Types",
                "{",
                "    /// <summary>",
                "    /// Money convertions",
                "    /// </summary>",
                "    [BlueprintRule_Class(enBlueprintClassNetworkType.Node_Action)]",
                "    [BlueprintCodeInjection_(typeof(Controller_BlueprintLogger), true)]",
                "    public sealed class Types_Money",
                "    {",
                "        /// <summary>",
                "        ///     A Double extension method that converts the @this to a money.",
                "        /// </summary>",
                "        /// <param name=\"this\">The @this to act on.</param>",
                "        /// <returns>@this as a Double.</returns>",
                "        public Double ToMoney(Double @this)",
                "        {",
                "            return Math.Round(@this, 2);",
                "        }",
                "    }",
                "}"
            };

            // Write the lines
            var folderPath = Test_Config.TestFolder() + @"Text/ClassNT/"; //@"C:\test\stream\header.txt";
            _lamed.lib.IO.Folder.Create(folderPath);
            var file = folderPath + "Types_Money.txt";
            _lamed.lib.IO.RW.File_Write(file, source.ToArray(), true);

            // Reading the lines back
            var sourceRead = _lamed.lib.IO.RW.File_Read2StrArray(file).ToList();
            Assert.Equal(source, sourceRead);

            #endregion

            #region Test3: Create header class

            int           ii;
            ClassNTStats_ stats   = ClassNTStats_.Create();
            var           header1 = ClassNTHeader_.Create(source, out ii, stats);
            Assert.Equal("System", header1.NameSpace_UsingLines[0]);
            Assert.Equal("Blueprint.lib.Rules.Types", header1.NameSpace_Name);
            Assert.Equal("Money convertions", header1.Header_Comment);
            Assert.Equal("[BlueprintRule_Class(enBlueprintClassNetworkType.Node_Action)]", header1.NameSpace_AttributeLines[0]);
            Assert.Equal("[BlueprintCodeInjection_(typeof(Controller_BlueprintLogger), true)]",
                         header1.NameSpace_AttributeLines[1]);
            Assert.Equal("Types_Money", header1.ClassName);
            Assert.Equal("Types", header1.ClassName1);
            Assert.Equal("Money", header1.ClassName2);

            #endregion

            #region Test4: Write, Read and re-Create the header class
            file = folderPath + "ClassNTHeader.txt";

            string json1 = _lamed.lib.Test.Object_2JsonStr(header1);
            1f.zIO().RW.File_Write(file, json1, overwrite: true);

            // Read the object and test it
            string json2   = 1f.zIO().RW.File_Read2Str(file);
            var    header2 = _lamed.lib.Test.Object_FromJsonStr <ClassNTHeader_>(json2);
            // Testing
            Assert.Equal(json1, json2);
            Assert.Equal("System", header2.NameSpace_UsingLines[0]);
            Assert.Equal("Blueprint.lib.Rules.Types", header2.NameSpace_Name);
            Assert.Equal("Money convertions", header2.Header_Comment);
            Assert.Equal("[BlueprintRule_Class(enBlueprintClassNetworkType.Node_Action)]", header2.NameSpace_AttributeLines[0]);
            Assert.Equal("[BlueprintCodeInjection_(typeof(Controller_BlueprintLogger), true)]",
                         header2.NameSpace_AttributeLines[1]);
            Assert.Equal("Types_Money", header2.ClassName);
            Assert.Equal("Types", header2.ClassName1);
            Assert.Equal("Money", header2.ClassName2);

            #endregion
        }
コード例 #7
0
ファイル: ClassNT_Test.cs プロジェクト: LouwrensP/LamedalCore
        public void ClassNT_ReadWrite_Test()
        {
            List <string>         source;
            ClassNTBlueprintRule_ blueprintRule;

            #region Test1: public sealed class Types_Money

            //      ===========================================
            source = new List <string>
            {
                "using System;",
                "",
                "namespace Blueprint.lib.Rules.Types",
                "{",
                "    /// <summary>",
                "    /// Money convertions",
                "    /// </summary>",
                "    [BlueprintRule_Class(enBlueprint_ClassNetworkType.Node_Action)]",
                "    public sealed class Types_Money",
                "    {",
                "        /// <summary>",
                "        ///     A Double extension method that converts the @this to a money.",
                "        /// </summary>",
                "        /// <param name=\"this\">The @this to act on.</param>",
                "        /// <returns>@this as a Double.</returns>",
                "        public Double ToMoney(Double @this)",
                "        {",
                "            return Math.Round(@this, 2);",
                "        }",
                "    }",
                "}",
                ""
            };
            bool error;
            var  Class = ClassNT_.Create(source, out error, out blueprintRule);
            Assert.Equal(1, Class.Header.NameSpace_UsingLines.Count);
            Assert.Equal("Blueprint.lib.Rules.Types", Class.Header.NameSpace_Name);
            Assert.Equal("Money convertions", Class.Header.Header_Comment);
            Assert.Equal(1, Class.Header.Namespace_Attributes.Items.Count);
            Assert.Equal(enBlueprint_ClassNetworkType.Node_Action, blueprintRule.ClassType);

            #endregion

            #region Test2: Write & Read the class object

            var folderPath = Test_Config.TestFolder() + @"Text/ClassNT/"; //@"C:\test\stream\header.txt";
            _lamed.lib.IO.Folder.Create(folderPath);
            var file = folderPath + "classTest.txt";

            // Writing
            string json1 = _lamed.lib.Test.Object_2JsonStr(Class);
            1f.zIO().RW.File_Write(file, json1, true);

            // Reading
            string json2  = 1f.zIO().RW.File_Read2Str(file);
            var    Class2 = _lamed.lib.Test.Object_FromJsonStr <ClassNT_>(json2);

            // Testing
            Assert.Equal(json1, json2);
            Assert.Equal(1, Class2.Header.NameSpace_UsingLines.Count);
            Assert.Equal("Blueprint.lib.Rules.Types", Class2.Header.NameSpace_Name);
            Assert.Equal("Money convertions", Class2.Header.Header_Comment);
            Assert.Equal(1, Class2.Header.Namespace_Attributes.Items.Count);

            #endregion
        }
コード例 #8
0
ファイル: ClassNT_Test.cs プロジェクト: LouwrensP/LamedalCore
        public void ClassWriteRead_Test()
        {
            #region Create the test data
            //      ===========================================
            var source = new List <string>
            {
                "using System;",
                "",
                "namespace Blueprint.lib.Rules.Types",
                "{",
                "    /// <summary>",
                "    /// Money convertions",
                "    /// </summary>",
                "    [BlueprintRule_Class(enBlueprint_ClassNetworkType.Node_Action)]",
                "    [BlueprintCodeInjection_(typeof(Controller_BlueprintLogger), true)]",
                "    public sealed class Types_Money",
                "    {",
                "        public string Method1()",
                "        {",
                "            return \"Test\";",
                "        }",
                "        ",
                "        /// <summary>",
                "        ///     A Double extension method that converts the @this to a money.",
                "        /// </summary>",
                "        /// <param name=\"this\">The @this to act on.</param>",
                "        /// <returns>@this as a Double.</returns>",
                "        public Double ToMoney(Double @this)",
                "        {",
                "            return Math.Round(@this, 2);",
                "        }",
                "    }",
                "}"
            };

            // Write the lines
            var folderPath = Test_Config.TestFolder(@"Text/cSharp/"); //@"C:\test\stream\header.txt";
            var file       = folderPath + "Types_Money.cs";
            _lamed.lib.IO.RW.File_Write(file, source.ToArray(), true);


            #endregion

            bool error;
            ClassNTBlueprintRule_ methodRule;
            var       Class1 = ClassNT_.Create(source, out error, out methodRule, file);
            var       Class2 = ClassNT_.Create(file, out error, out methodRule);
            MethodNT_ method = Class1.Method_Find("public Double ToMoney(Double @this)");

            string errorMsg;
            Assert.True(_lamed.Types.Object.IsEqual(Class1, Class2, out errorMsg), errorMsg);
            //Assert.Equal(Class1, Class2);
            Assert.NotNull(method);
            Assert.Equal("public Double ToMoney(Double @this)", method.Header.Method_HeaderLine);

            // Test exceptions
            var method1 = Class1.Method_Find("public Double ToMoney(Double @this)", true);
            var method2 = Class1.Method_Find("public Double ToMoney(Double @this)");
            Assert.Equal(method, method1);
            Assert.Equal(null, method2);
        }