diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index 21f7542..bc48a7a 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -28,3 +28,22 @@ jobs:
run: dotnet restore src/Tomas.Terminal
- name: Build
run: dotnet build src/Tomas.Terminal -c Release --no-restore
+
+ test:
+ timeout-minutes: 15
+ continue-on-error: true
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ dotnet: ["6.0.x"]
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: ${{ matrix.dotnet }}
+ - name: Install test dependencies
+ run: dotnet restore src/Tomas.Tests
+ - name: Test
+ run: dotnet test src --no-restore --debug
\ No newline at end of file
diff --git a/src/TOMAS.sln b/src/TOMAS.sln
index 44fc703..d18435f 100644
--- a/src/TOMAS.sln
+++ b/src/TOMAS.sln
@@ -22,6 +22,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tomas.Terminal", "Tomas.Ter
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tomas.Kernel", "Tomas.Kernel\Tomas.Kernel.csproj", "{B70BDFD5-64BA-4FCE-A00F-DDD209C2C0FB}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tomas.Tests", "Tomas.Tests\Tomas.Tests.csproj", "{76AD2140-2975-43DA-89A9-0BEC70B2ECDD}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -44,6 +46,10 @@ Global
{B70BDFD5-64BA-4FCE-A00F-DDD209C2C0FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B70BDFD5-64BA-4FCE-A00F-DDD209C2C0FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B70BDFD5-64BA-4FCE-A00F-DDD209C2C0FB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {76AD2140-2975-43DA-89A9-0BEC70B2ECDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {76AD2140-2975-43DA-89A9-0BEC70B2ECDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {76AD2140-2975-43DA-89A9-0BEC70B2ECDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {76AD2140-2975-43DA-89A9-0BEC70B2ECDD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/Tomas.Core/GlobalUsing.cs b/src/Tomas.Core/Usings.cs
similarity index 100%
rename from src/Tomas.Core/GlobalUsing.cs
rename to src/Tomas.Core/Usings.cs
diff --git a/src/Tomas.Interface/Usings.cs b/src/Tomas.Interface/Usings.cs
new file mode 100644
index 0000000..e69de29
diff --git a/src/Tomas.Kernel/SysFS.cs b/src/Tomas.Kernel/SysFS.cs
index 5b5865a..6ad6324 100644
--- a/src/Tomas.Kernel/SysFS.cs
+++ b/src/Tomas.Kernel/SysFS.cs
@@ -8,152 +8,138 @@ namespace Tomas.Kernel;
static class SysFS
{
- // The root directory of the file system
- public const string ROOT_DIR = "0:\\";
- // The system directory, located in the root directory
- static string SYSTEM_DIR = $"{ROOT_DIR}\\SYSTEM\\";
+ // The root directory of the file system
+ public const string ROOT_DIR = "0:\\";
+ // The system directory, located in the root directory
+ static string SYSTEM_DIR = $"{ROOT_DIR}\\SYSTEM\\";
- static string LOG_FILE = $"{SYSTEM_DIR}system.log";
+ static string LOG_FILE = $"{SYSTEM_DIR}system.log";
- public const string FS_ERROR = "File system disabled.";
+ public const string FS_ERROR = "File system disabled.";
- ///
- /// An instance of the CosmosVFS class, used for accessing the virtual file system
- ///
- static CosmosVFS fileSystem = new();
+ ///
+ /// An instance of the CosmosVFS class, used for accessing the virtual file system
+ ///
+ static CosmosVFS fileSystem = new();
- ///
- /// Initializes the file system by creating the system directory and sysinfo.txt file
- /// and setting the IsFSActive property of the SysMeta class to true
- ///
- public static void Initialize()
- {
- try
- {
- var createSysFiles = "Creating system files.";
- var setSysPref = "Writing system info.";
- var fsSuccess = "File system succesfully initialized.";
- var sysInfoFile = "sysinfo.txt";
+ ///
+ /// Initializes the file system by creating the system directory and sysinfo.txt file
+ /// and setting the IsFSActive property of the SysMeta class to true
+ ///
+ public static void Initialize()
+ {
+ try
+ {
+ // File to store system information
+ const string sysInfoFile = "sysinfo.txt";
- // Register the CosmosVFS instance as the virtual file system
- VFSManager.RegisterVFS(fileSystem);
+ // Create system directory if it doesn't exist
+ if (!Directory.Exists(SYSTEM_DIR))
+ fileSystem.CreateDirectory(SYSTEM_DIR);
- // Create the system directory
- if (!Directory.Exists(SYSTEM_DIR))
- fileSystem.CreateDirectory(SYSTEM_DIR);
+ // Create system log file if it doesn't exist
+ if (!File.Exists($"{SYSTEM_DIR}{LOG_FILE}"))
+ fileSystem.CreateFile($"{SYSTEM_DIR}{LOG_FILE}");
- // Create the system.log file in the system directory
- if (!File.Exists($"{SYSTEM_DIR}{LOG_FILE}"))
- fileSystem.CreateFile($"{SYSTEM_DIR}{LOG_FILE}");
+ // Create sysinfo.txt file if it doesn't exist
+ if (!File.Exists($"{SYSTEM_DIR}{sysInfoFile}"))
+ fileSystem.CreateFile($"{SYSTEM_DIR}{sysInfoFile}");
- Console.WriteLine(createSysFiles);
- File.AppendAllText(LOG_FILE, createSysFiles);
+ // Write system name, version, and build number to sysinfo.txt file
+ File.WriteAllText($"{SYSTEM_DIR}sysinfo.txt", $"{SysMeta.NAME} v{SysMeta.VERSION} ({SysMeta.BuildNumber})");
- // Create the sysinfo.txt file in the system directory
- if (!File.Exists($"{SYSTEM_DIR}{sysInfoFile}"))
- fileSystem.CreateFile($"{SYSTEM_DIR}{sysInfoFile}");
+ // Set IsFSEnabled property of SysMeta class to true
+ SysMeta.IsFSEnabled = true;
- Console.WriteLine(setSysPref);
+ // Read contents of sysinfo.txt file and print to console
+ var systemInfo = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt");
+ Console.WriteLine(systemInfo);
+ }
+ catch (Exception err)
+ {
+ // Print error message if an exception is caught
+ Console.WriteLine($"{err.Message}{Environment.NewLine}Warning: Error messages will not logged.");
+ }
+ }
- File.AppendAllText(LOG_FILE, setSysPref);
- // Write the system name, version, and build number to the sysinfo.txt file
- File.WriteAllText($"{SYSTEM_DIR}sysinfo.txt", $"{SysMeta.NAME} v{SysMeta.VERSION} ({SysMeta.BuildNumber})");
- Console.WriteLine(fsSuccess);
- File.AppendAllText(LOG_FILE, fsSuccess);
+ ///
+ /// Creates a new directory at the specified path
+ ///
+ /// directory
+ public static void CreateDirectory(string directory)
+ {
+ try
+ {
+ // If file system isn't enabeld, throw exception
+ if (!SysMeta.IsFSEnabled)
+ throw new IOException(FS_ERROR);
- // Set the IsFSActive property of the SysMeta class to true
- SysMeta.IsFSEnabled = true;
+ // Create the directory using the CosmosVFS instance
+ if (!Directory.Exists($"{ROOT_DIR}\\{directory}"))
+ fileSystem.CreateDirectory($"{ROOT_DIR}\\{directory}");
+ }
+ catch (IOException err)
+ {
+ // If an exception is caught, print an error message indicating the error
+ Console.WriteLine(err.Message);
+ File.AppendAllText(LOG_FILE, err.Message);
+ }
+ }
- // Read the contents of the sysinfo.txt file and print it to the console
- var systemInfo = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt");
+ ///
+ /// Creates a new file at the specified path
+ ///
+ /// file path
+ /// file
+ public static void CreateFile(string path, string file)
+ {
+ try
+ {
+ // If file system isn't enabeld, throw exception
+ if (!SysMeta.IsFSEnabled)
+ throw new IOException(FS_ERROR);
- Console.WriteLine(systemInfo);
- }
- catch (Exception err)
- {
- // If an exception is caught, print an error message indicating that the file system failed to load
- Console.WriteLine($"{err.Message}{Environment.NewLine}Warning: Error messages will not logged.");
- }
- }
+ // Create the file using the CosmosVFS instance
+ if (!File.Exists($"{ROOT_DIR}\\{path}\\{file}"))
+ fileSystem.CreateFile($"{ROOT_DIR}\\{path}\\{file}");
+ }
+ catch (IOException err)
+ {
+ // If an exception is caught, print an error message indicating the error
+ Console.WriteLine(err.Message);
+ File.AppendAllText(LOG_FILE, err.Message);
+ }
+ }
- ///
- /// Creates a new directory at the specified path
- ///
- /// directory
- public static void CreateDirectory(string directory)
- {
- try
- {
- // If file system isn't enabeld, throw exception
- if (!SysMeta.IsFSEnabled)
- throw new IOException(FS_ERROR);
+ ///
+ /// Lists all directories in the specified path
+ ///
+ /// path to directory
+ /// returns a list of directories
+ public static string[] ListDirectories(string path)
+ {
+ try
+ {
+ // If file system isn't enabeld, throw exception
+ if (!SysMeta.IsFSEnabled)
+ throw new IOException(FS_ERROR);
- // Create the directory using the CosmosVFS instance
- if (!Directory.Exists($"{ROOT_DIR}\\{directory}"))
- fileSystem.CreateDirectory($"{ROOT_DIR}\\{directory}");
- }
- catch (IOException err)
- {
- // If an exception is caught, print an error message indicating the error
- Console.WriteLine(err.Message);
- File.AppendAllText(LOG_FILE, err.Message);
- }
- }
+ // Get the directories in the specified path using the Directory.GetDirectories method
+ var dirs = Directory.GetDirectories(path);
- ///
- /// Creates a new file at the specified path
- ///
- /// file path
- /// file
- public static void CreateFile(string path, string file)
- {
- try
- {
- // If file system isn't enabeld, throw exception
- if (!SysMeta.IsFSEnabled)
- throw new IOException(FS_ERROR);
+ // Return the directories
+ return dirs;
+ }
+ catch (IOException err)
+ {
+ // If an exception is caught, print an error message indicating the error
+ Console.WriteLine(err.Message);
+ File.AppendAllText(LOG_FILE, err.Message);
- // Create the file using the CosmosVFS instance
- if (!File.Exists($"{ROOT_DIR}\\{path}\\{file}"))
- fileSystem.CreateFile($"{ROOT_DIR}\\{path}\\{file}");
- }
- catch (IOException err)
- {
- // If an exception is caught, print an error message indicating the error
- Console.WriteLine(err.Message);
- File.AppendAllText(LOG_FILE, err.Message);
- }
- }
-
- ///
- /// Lists all directories in the specified path
- ///
- /// path to directory
- /// returns a list of directories
- public static string[] ListDirectories(string path)
- {
- try
- {
- // If file system isn't enabeld, throw exception
- if (!SysMeta.IsFSEnabled)
- throw new IOException(FS_ERROR);
-
- // Get the directories in the specified path using the Directory.GetDirectories method
- var dirs = Directory.GetDirectories(path);
-
- // Return the directories
- return dirs;
- }
- catch (IOException err)
- {
- // If an exception is caught, print an error message indicating the error
- Console.WriteLine(err.Message);
- File.AppendAllText(LOG_FILE, err.Message);
-
- throw;
- }
- }
+ throw;
+ }
+ }
}
diff --git a/src/Tomas.Kernel/GlobalUsing.cs b/src/Tomas.Kernel/Usings.cs
similarity index 100%
rename from src/Tomas.Kernel/GlobalUsing.cs
rename to src/Tomas.Kernel/Usings.cs
diff --git a/src/Tomas.Tests/Shell/MockProgram.cs b/src/Tomas.Tests/Shell/MockProgram.cs
new file mode 100644
index 0000000..3077976
--- /dev/null
+++ b/src/Tomas.Tests/Shell/MockProgram.cs
@@ -0,0 +1,16 @@
+/*
+In jurisdictions that recognize copyright waivers, I've waived all copyright
+and related or neighboring rights for to this project. In areas where these
+waivers are not recognized, BSD-3-Clause is enforced.
+See the (UN)LICENSE file in the project root for more information.
+*/
+namespace Tomas.Tests.Shell;
+
+internal class MockProgram : IProgram
+{
+ public bool Run(IShell shell)
+ {
+ Debug.WriteLine("Test Program.");
+ return true;
+ }
+}
diff --git a/src/Tomas.Tests/Shell/MockShell.cs b/src/Tomas.Tests/Shell/MockShell.cs
new file mode 100644
index 0000000..0ea450a
--- /dev/null
+++ b/src/Tomas.Tests/Shell/MockShell.cs
@@ -0,0 +1,17 @@
+/*
+In jurisdictions that recognize copyright waivers, I've waived all copyright
+and related or neighboring rights for to this project. In areas where these
+waivers are not recognized, BSD-3-Clause is enforced.
+See the (UN)LICENSE file in the project root for more information.
+*/
+namespace Tomas.Tests.Shell;
+
+internal class MockShell : IShell
+{
+ public string? ReadLine { get; }
+
+ public Dictionary Programs => new()
+ {
+ { "test", new MockProgram() },
+ };
+}
diff --git a/src/Tomas.Tests/ShellTests.cs b/src/Tomas.Tests/ShellTests.cs
new file mode 100644
index 0000000..e837252
--- /dev/null
+++ b/src/Tomas.Tests/ShellTests.cs
@@ -0,0 +1,26 @@
+/*
+In jurisdictions that recognize copyright waivers, I've waived all copyright
+and related or neighboring rights for to this project. In areas where these
+waivers are not recognized, BSD-3-Clause is enforced.
+See the (UN)LICENSE file in the project root for more information.
+*/
+using Tomas.Tests.Shell;
+
+namespace Tomas.Tests;
+
+public class ShellTests
+{
+ // Create a new instance of the mock shell
+ readonly MockShell _mockShell = new();
+
+ [Fact]
+ public void ProgramTest()
+ {
+ // Create a mock program
+ var program = new MockProgram();
+
+ // Assert that the Run method of the program and returns true when passed the shell object.
+ Assert.True(program.Run(_mockShell));
+ }
+
+}
\ No newline at end of file
diff --git a/src/Tomas.Tests/Tomas.Tests.csproj b/src/Tomas.Tests/Tomas.Tests.csproj
new file mode 100644
index 0000000..5c6309a
--- /dev/null
+++ b/src/Tomas.Tests/Tomas.Tests.csproj
@@ -0,0 +1,29 @@
+
+
+
+ net6.0
+ enable
+ enable
+ enable
+ false
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
+
diff --git a/src/Tomas.Tests/Usings.cs b/src/Tomas.Tests/Usings.cs
new file mode 100644
index 0000000..d97cace
--- /dev/null
+++ b/src/Tomas.Tests/Usings.cs
@@ -0,0 +1,11 @@
+/*
+In jurisdictions that recognize copyright waivers, I've waived all copyright
+and related or neighboring rights for to this project. In areas where these
+waivers are not recognized, BSD-3-Clause is enforced.
+See the (UN)LICENSE file in the project root for more information.
+*/
+global using Xunit;
+global using System.Diagnostics.CodeAnalysis;
+global using System.Diagnostics;
+global using Tomas.Core;
+global using Tomas.Interface;
\ No newline at end of file