diff --git a/Tms.Adapter.Core/Configurator/Configurator.cs b/Tms.Adapter.Core/Configurator/Configurator.cs
index df776c0..4d4545c 100644
--- a/Tms.Adapter.Core/Configurator/Configurator.cs
+++ b/Tms.Adapter.Core/Configurator/Configurator.cs
@@ -1,3 +1,4 @@
+using System.Configuration;
using System.Text.Json;
namespace Tms.Adapter.Core.Configurator;
@@ -44,8 +45,10 @@ public static TmsSettings GetConfig()
Console.WriteLine($"Configuration file was not found at {defaultJsonConfigPath}");
}
+ ApplyEnv(config);
+ Validate(config);
- return ApplyEnv(config);
+ return config;
}
private static string GetConfigFileName()
@@ -106,4 +109,37 @@ private static TmsSettings ApplyEnv(TmsSettings settings)
return settings;
}
+
+ private static void Validate(TmsSettings settings)
+ {
+
+ if (!Uri.IsWellFormedUriString(settings.Url, UriKind.Absolute))
+ {
+ throw new ConfigurationErrorsException("Url is invalid");
+ }
+
+ if (string.IsNullOrWhiteSpace(settings.PrivateToken))
+ {
+ throw new ConfigurationErrorsException("Private token is invalid");
+ }
+
+ if (!Guid.TryParse(settings.ProjectId, out var _))
+ {
+ throw new ConfigurationErrorsException("Project id is invalid");
+ }
+
+ if (!Guid.TryParse(settings.ConfigurationId, out var _))
+ {
+ throw new ConfigurationErrorsException("Configuration id is invalid");
+ }
+
+ if (!string.IsNullOrWhiteSpace(settings.TestRunId))
+ {
+ if (!Guid.TryParse(settings.TestRunId, out var _))
+ {
+ throw new ConfigurationErrorsException(
+ "Config contains not valid test run id.");
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/Tms.Adapter.Core/Tms.Adapter.Core.csproj b/Tms.Adapter.Core/Tms.Adapter.Core.csproj
index a1ae095..28718ff 100644
--- a/Tms.Adapter.Core/Tms.Adapter.Core.csproj
+++ b/Tms.Adapter.Core/Tms.Adapter.Core.csproj
@@ -46,6 +46,7 @@
+