Exemple #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);
        }
Exemple #2
0
        public void Time_Test()
        {
            var appFolder  = _lamed.lib.IO.Folder.Path_Application();
            var testFolder = appFolder + "TestTime/";

            Test_Config.Folder_Cleanup(testFolder);
            Test_Config.Folder_Create(testFolder);
            _lamed.lib.IO.RW.File_Write(testFolder + "testFile.txt", "This is a test", true);

            #region time
            var time1 = _lamed.lib.IO.File.Time(testFolder + "testFile.txt", enIO_FileActionTime.Creation);
            var time2 = _lamed.lib.IO.File.Time(testFolder + "testFile.txt", enIO_FileActionTime.LastAccess);
            var time3 = _lamed.lib.IO.File.Time(testFolder + "testFile.txt", enIO_FileActionTime.LastWrite);
            Assert.Equal(time1, time2);
            Assert.Equal(time2, time3);

            _lamed.lib.Command.Sleep(2100);
            _lamed.lib.IO.RW.File_Write(testFolder + "testFile.txt", "This is a new line", enIO_WriteAction.AppendFile);
            var time4 = _lamed.lib.IO.File.Time(testFolder + "testFile.txt", enIO_FileActionTime.Creation);
            var time5 = _lamed.lib.IO.File.Time(testFolder + "testFile.txt", enIO_FileActionTime.LastAccess);
            var time6 = _lamed.lib.IO.File.Time(testFolder + "testFile.txt", enIO_FileActionTime.LastWrite);
            Assert.Equal(time1, time4);
            Assert.Equal(time2, time5);
            Assert.NotEqual(time1, time6);
            #endregion

            // IsFile
            Assert.True(_lamed.lib.IO.File.IsFile(testFolder + "testFile.txt"));
            var info = _lamed.lib.IO.File.FileInfo(testFolder + "testFile.txt");
            Assert.NotEqual(testFolder, info.DirectoryName);
            var folder = _lamed.lib.IO.Parts._Format2Slash(info.DirectoryName);
            Assert.Equal(testFolder, folder);

            Test_Config.Folder_Cleanup(testFolder);
        }
        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
        }
Exemple #4
0
        public void FilePath_Temporary_Test()
        {
            var    file = _lamed.lib.IO.File.FilePath_Temporary();
            string error;

            Assert.True(Test_Config.IsGoodFolderOrFileFormat(file, out error), error);
        }
        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
        }
Exemple #6
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}'");
        }
        public void Folder_Test()
        {
            #region Setup ] --------------------------------------------------------------------------------
            var appFolder  = _lamed.lib.IO.Folder.Path_Application();
            var testFolder = appFolder + "TestFolder/";
            Test_Config.Folder_Create(testFolder);
            #endregion

            // Test
            string error;
            Assert.True(Test_Config.IsGoodFolderOrFileFormat(appFolder, out error), error);
            Assert.True(Test_Config.IsGoodFolderOrFileFormat(testFolder, out error), error);

            Assert.True(_lamed.lib.IO.Folder.Exists(testFolder + "test1/"));
            Assert.True(_lamed.lib.IO.Folder.Exists(testFolder + "test2/"));
            Assert.True(_lamed.lib.IO.Folder.Exists(testFolder + "test3/"));
            Assert.True(_lamed.lib.IO.Folder.Exists(testFolder + "test4/Sub1/"));
            Assert.True(_lamed.lib.IO.Folder.Exists(testFolder + "test4/Sub1/Sub2/"));
            Assert.True(_lamed.lib.IO.Folder.Exists(testFolder + "test4/"));

            // Is Folder
            Assert.True(_lamed.lib.IO.Folder.IsFolder(testFolder));
            Assert.True(_lamed.lib.IO.Folder.IsFolder(testFolder + "test1/"));

            // Search
            IList <string> folders1 = _lamed.lib.IO.Search.Folders(testFolder);
            IList <string> folders2 = _lamed.lib.IO.Search.Folders(testFolder, searchOption: SearchOption.AllDirectories);
            Assert.Equal(5, folders1.Count());
            Assert.Equal(testFolder + "test3/", folders1[3]);
            Assert.Equal(8, folders2.Count());
            Assert.Equal(testFolder + "test4/Sub1/Sub2/", folders2[7]);

            // Move & test
            _lamed.lib.IO.Folder.Move(testFolder + "test1/", testFolder + "test5/");
            Assert.False(_lamed.lib.IO.Folder.Exists(testFolder + "test1/"));
            Assert.True(_lamed.lib.IO.Folder.IsFolder(testFolder + "test5/"));

            // Absolute path
            string relativePath  = @"../bling.txt";
            string baseDirectory = @"C:/blah1/blah2/";
            string absolutePath  = _lamed.lib.IO.Folder.Path_Absolute(baseDirectory, relativePath);
            Assert.Equal("C:/blah1/bling.txt", absolutePath);

            #region Cleanup -------------------------------------------------------------------------------

            Test_Config.Folder_Cleanup(testFolder);
            Assert.False(_lamed.lib.IO.Folder.Exists(testFolder));
            Assert.False(_lamed.lib.IO.Folder.Exists(testFolder + "test1/"));
            #endregion
        }
        public void Folder_test()
        {
            // Just execute methods that can not be tested
            #region Path_Assembly
            var    assembly       = _lamed.lib.About.Assembly();
            var    assemblyFolder = _lamed.Types.Assembly.To_FilePath(assembly);
            string error;
            Assert.True(Test_Config.IsGoodFolderOrFileFormat(assemblyFolder, out error), error);
            Assert.True(_lamed.lib.IO.Folder.Exists(assemblyFolder), assemblyFolder);
            #endregion

            #region Path_Temporary
            var tempFolder = _lamed.lib.IO.Folder.Path_Temporary();
            Assert.True(Test_Config.IsGoodFolderOrFileFormat(tempFolder, out error), error);
            Assert.True(_lamed.lib.IO.Folder.Exists(tempFolder), tempFolder);
            #endregion
        }
Exemple #9
0
        public void Exists_GetNextNo_Test()
        {
            var showTestFolder = false;   // If true, the folder where the files were created will be shown; else it will be removed after test.

            // Create testcases
            var appFolder  = _lamed.lib.IO.Folder.Path_Application();
            var testFolder = appFolder + "TestFolderIO2/";

            Test_Config.Folder_Cleanup(testFolder);
            Test_Config.Folder_Create(testFolder);

            Assert.Equal(testFolder + "testFileThatIsTotallyUnuque.txt", _lamed.lib.IO.File.Exists_GetNextNo(testFolder + "testFileThatIsTotallyUnuque.txt"));
            _lamed.lib.IO.RW.File_Write(testFolder + "testFile.txt", "This is a test", true);
            _lamed.lib.IO.RW.File_Write(testFolder + "testFile_0001.txt", "This is a test", true);
            _lamed.lib.IO.RW.File_Write(testFolder + "testFile_0002.txt", "This is a test", true);
            _lamed.lib.IO.RW.File_Write(testFolder + "testFile_0003.txt", "This is a test", true);
            _lamed.lib.IO.RW.File_Write(testFolder + "testFile_0005.txt", "This is a test", true);
            _lamed.lib.IO.RW.File_Write(testFolder + "testFile_0007.txt", "This is a test", true);
            _lamed.lib.IO.RW.File_Write(testFolder + "testFile_0009.txt", "This is a test", true);

            Assert.Equal(testFolder + "testFile_0004.txt", _lamed.lib.IO.File.Exists_GetNextNo(testFolder + "testFile.txt"));
            _lamed.lib.IO.RW.File_Write(testFolder + "testFile_0004.txt", "This is a test", true);
            Assert.Equal(testFolder + "testFile_0006.txt", _lamed.lib.IO.File.Exists_GetNextNo(testFolder + "testFile.txt"));
            _lamed.lib.IO.RW.File_Write(testFolder + "testFile_0006.txt", "This is a test", true);
            Assert.Equal(testFolder + "testFile_0008.txt", _lamed.lib.IO.File.Exists_GetNextNo(testFolder + "testFile.txt"));
            _lamed.lib.IO.RW.File_Write(testFolder + "testFile_0008.txt", "This is a test", true);
            for (int ii = 0; ii < 100; ii++)
            {
                var file = _lamed.lib.IO.File.Exists_GetNextNo(testFolder + "testFile.txt");
                _lamed.lib.IO.RW.File_Write(file, "This is a test", true);
            }
            Assert.Equal(testFolder + "testFile_0110.txt", _lamed.lib.IO.File.Exists_GetNextNo(testFolder + "testFile.txt"));

            Assert.Throws <ArgumentException>(() => _lamed.lib.IO.File.Exists_GetNextNo(testFolder + "testFile.txt", jumpFactor: 1));

            if (showTestFolder)
            {
                _lamed.lib.Command.Execute_Explorer(testFolder);
            }
            else
            {
                Test_Config.Folder_Cleanup(testFolder);
            }
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        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
        }
Exemple #12
0
        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
        }
Exemple #13
0
        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);
        }
Exemple #14
0
        public void File_Write_Test()
        {
            // Although here are many methods tested, it is better because the testcases are also created by these methods
            // Get the path
            var appFolder  = _lamed.lib.IO.Folder.Path_Application();
            var testFolder = appFolder + "TestFolderIO/";

            Test_Config.Folder_Cleanup(testFolder);  // Make sure folder is clean
            Test_Config.Folder_Create(testFolder);

            #region File_Write
            var file = testFolder + "testFile.txt";
            //var ex1 =Assert.Throws<InvalidOperationException>(() => _lamed.lib.IO.RW.File_Write(file, "This is test line0", true, true));
            //Assert.Equal("Error! It is not possible to append and overwrite the file at the same time.", ex1.Message);

            // Overwrite twice
            _lamed.lib.IO.RW.File_Write(file, "This is test line1", false);
            Assert.Equal("This is test line1", _lamed.lib.IO.RW.File_Read2Str(file));
            Assert.Equal("6a3b0ffb40384ac41dd702307f16e1e2", _lamed.lib.IO.File.Hash_ToStr(file));

            _lamed.lib.IO.RW.File_Write(file, "This is test line2", true);
            Assert.Equal("This is test line2", _lamed.lib.IO.RW.File_Read2Str(file));
            Assert.Equal("a14d3fe730b2f308931327bede1cc479", _lamed.lib.IO.File.Hash_ToStr(file));
            Assert.Equal(true, _lamed.lib.IO.Folder.IsFolder(testFolder));
            Assert.Equal(false, _lamed.lib.IO.Folder.IsFolder(file));
            Assert.Equal(false, _lamed.lib.IO.File.IsFile(testFolder));
            Assert.Equal(true, _lamed.lib.IO.File.IsFile(file));
            #endregion

            #region FileAttributes
            _lamed.lib.IO.File.Attributes_Set(file, FileAttributes.Hidden);
            Assert.Equal(true, _lamed.lib.IO.File.Attributes_Check(file, FileAttributes.Hidden));
            #endregion

            #region Append to file
            _lamed.lib.IO.RW.File_Write(file, "This is test line3", enIO_WriteAction.AppendFile);
            Assert.Equal("This is test line2".NL() + "This is test line3", _lamed.lib.IO.RW.File_Read2Str(file));
            #endregion

            #region Write to existing file
            var ex = Assert.Throws <ArgumentException>(() => _lamed.lib.IO.RW.File_Write(file, "This is a test", enIO_WriteAction.WriteFile));
            Assert.Equal("Error! Can not write to file because it already exists.".NL() + "Parameter name: writeAction", ex.Message);
            #endregion

            #region Copy & move
            // Copy & move
            _lamed.lib.IO.File.Copy(file, testFolder + "file2.txt");
            _lamed.lib.IO.File.Copy(file, testFolder + "file2.txt", true);
            var ex3 = Assert.Throws <IOException>(() => _lamed.lib.IO.File.Copy(file, testFolder + "file2.txt"));
            Assert.Equal(true, ex3.Message.Contains("/bin/Debug/TestFolderIO/file2.txt' already exists."));  // This test is not valid
            _lamed.lib.IO.File.Copy(file, testFolder + "file3.txt");
            _lamed.lib.IO.File.Copy(file, testFolder + "file4.txt");
            Assert.True(_lamed.lib.IO.File.Exists(testFolder + "file4.txt"));
            _lamed.lib.IO.File.Move(testFolder + "file4.txt", testFolder + "file5.txt");
            Assert.False(_lamed.lib.IO.File.Exists(testFolder + "file4.txt"));
            Assert.True(_lamed.lib.IO.File.Exists(testFolder + "file5.txt"));
            _lamed.lib.IO.File.Move(testFolder + "file5.txt", testFolder + "file5.txt");
            Assert.True(_lamed.lib.IO.File.Exists(testFolder + "file5.txt"));
            #endregion

            #region Find files
            // Files
            IList <string> files = _lamed.lib.IO.Search.Files(testFolder);
            Assert.Equal(4, files.Count);
            Assert.Equal(testFolder + "file2.txt", files[0]);

            // FileInSubFolders
            var testFolderList = new List <string> {
                testFolder
            };
            string folderAndFileFound;
            bool   result = _lamed.lib.IO.Search.FileInSubFolders(testFolderList, "file2.txt", out folderAndFileFound);
            Assert.Equal(true, result);
            Assert.Equal(true, folderAndFileFound.Contains("/bin/Debug/TestFolderIO/file2.txt"));

            bool result2 = _lamed.lib.IO.Search.FileInSubFolders(testFolderList, "fileThatWillNotBeFound.txt", out folderAndFileFound);
            Assert.Equal(false, result2);
            Assert.Equal("", folderAndFileFound);

            // Empty file
            Assert.Throws <ArgumentNullException>(() => _lamed.lib.IO.Search.FileInSubFolders(testFolderList, "", out folderAndFileFound));

            #endregion

            #region Delete the file twice
            Assert.Equal(true, _lamed.lib.IO.File.Exists(file));
            Assert.Equal(true, _lamed.lib.IO.File.Delete(file));
            Assert.Equal(false, _lamed.lib.IO.File.Exists(file));

            // Read from file that does not exist
            Assert.Equal("", _lamed.lib.IO.RW.File_Read2Str(file, false));
            var ex2 = Assert.Throws <FileNotFoundException>(() => _lamed.lib.IO.RW.File_Read2Str(file));
            Assert.Equal($"Could not find file '{file}'.", ex2.Message);

            // Delete more files
            var iTotal1 = _lamed.lib.IO.File.DeleteFiles(files);
            var iTotal2 = _lamed.lib.IO.File.DeleteFiles(testFolder);
            Assert.Equal(3, iTotal1);
            Assert.Equal(0, iTotal2);
            #endregion

            // Cleanup
            Test_Config.Folder_Cleanup(testFolder);
            Assert.Equal(false, _lamed.lib.IO.File.Delete(file));
        }