diff --git a/src/.editorconfig b/src/.editorconfig
index dcf65efd1..ee1c896a8 100644
--- a/src/.editorconfig
+++ b/src/.editorconfig
@@ -10,7 +10,7 @@ indent_style = space
charset = utf-8-bom
trim_trailing_whitespace = true
insert_final_newline = true
-max_line_length = 180
+max_line_length = 160
# Microsoft .NET properties
csharp_preserve_single_line_blocks = true
diff --git a/src/Application/Framework.Application.Tests/Framework.Application.Tests.csproj b/src/Application/Framework.Application.Tests/Framework.Application.Tests.csproj
index f6403c8e1..7395050bc 100644
--- a/src/Application/Framework.Application.Tests/Framework.Application.Tests.csproj
+++ b/src/Application/Framework.Application.Tests/Framework.Application.Tests.csproj
@@ -10,7 +10,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/Application/Framework.Application.Tests/PeriodTests.cs b/src/Application/Framework.Application.Tests/PeriodTests.cs
index 87c5cff45..be6feb93e 100644
--- a/src/Application/Framework.Application.Tests/PeriodTests.cs
+++ b/src/Application/Framework.Application.Tests/PeriodTests.cs
@@ -41,10 +41,10 @@ public void GetFinancialYear_MonthOutOfRange_ThrowArgumentOutOfRangeException(in
var service = new FinancialYearCalculator(new FinancialYearServiceSettings());
// Act
- Action action = () => service.GetFinancialYear(2017, month);
+ var ex = Record.Exception(() => service.GetFinancialYear(2017, month));
// Assert
- Assert.Throws(action);
+ Assert.IsType(ex);
}
///
@@ -61,9 +61,9 @@ public void GetFinancialYear_YearOutOfRange_ThrowArgumentOutOfRangeException(int
var service = new FinancialYearCalculator(new FinancialYearServiceSettings());
// Act
- Action action = () => service.GetFinancialYear(year, month);
+ var ex = Record.Exception(() => service.GetFinancialYear(year, month));
// Assert
- Assert.Throws(action);
+ Assert.IsType(ex);
}
}
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/Framework.AutomationCore.ServiceEnvironment.LegacyContext.csproj b/src/AutomationCore/Framework.AutomationCore.Legacy/Framework.AutomationCore.Legacy.csproj
similarity index 72%
rename from src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/Framework.AutomationCore.ServiceEnvironment.LegacyContext.csproj
rename to src/AutomationCore/Framework.AutomationCore.Legacy/Framework.AutomationCore.Legacy.csproj
index e9e84160c..bb3f58337 100644
--- a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/Framework.AutomationCore.ServiceEnvironment.LegacyContext.csproj
+++ b/src/AutomationCore/Framework.AutomationCore.Legacy/Framework.AutomationCore.Legacy.csproj
@@ -1,7 +1,7 @@
- Luxoft.Framework.AutomationCore.ServiceEnvironment.LegacyContext
+ Luxoft.Framework.AutomationCore.Legacy
Framework.AutomationCore
@@ -15,7 +15,7 @@
-
+
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/IntegrationTestBase.cs b/src/AutomationCore/Framework.AutomationCore.Legacy/IntegrationTestBase.cs
similarity index 79%
rename from src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/IntegrationTestBase.cs
rename to src/AutomationCore/Framework.AutomationCore.Legacy/IntegrationTestBase.cs
index ceb3b13a1..825b8b09f 100644
--- a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/IntegrationTestBase.cs
+++ b/src/AutomationCore/Framework.AutomationCore.Legacy/IntegrationTestBase.cs
@@ -3,7 +3,6 @@
using Framework.Application;
using Framework.Application.Repository;
using Framework.AutomationCore.RootServiceProviderContainer;
-using Framework.AutomationCore.ServiceProviderPool;
using Framework.BLL.DTOMapping.Domain;
using Framework.Configuration.BLL;
using Framework.Configuration.Domain;
@@ -18,15 +17,14 @@
namespace Framework.AutomationCore;
-public abstract class IntegrationTestBase(IServiceProviderPool rootServiceProviderPool)
- : IntegrationTestBase(rootServiceProviderPool), IRootServiceProviderContainer
+public abstract class IntegrationTestBase(IServiceProvider rootServiceProvider) : RootServiceProviderContainer(rootServiceProvider)
where TBLLContext : IServiceProviderContainer
{
public Task EvaluateAsync(
DBSessionMode sessionMode,
UserCredential? customUserCredential,
Func> getResult) =>
- this.RootServiceProvider.GetRequiredService>().EvaluateAsync(sessionMode, customUserCredential, getResult);
+ rootServiceProvider.GetRequiredService>().EvaluateAsync(sessionMode, customUserCredential, getResult);
protected IConfigurationBLLContext GetConfigurationBLLContext(TBLLContext context) => context.ServiceProvider.GetRequiredService();
@@ -34,7 +32,7 @@ public Task EvaluateAsync(
///
/// Отчистка списка нотифицаций
///
- public override void ClearNotifications() =>
+ public virtual void ClearNotifications() =>
this.EvaluateWrite(context => this.GetConfigurationBLLContext(context).Logics.DomainObjectNotification.Pipe(bll => bll.GetFullList().ForEach(bll.Remove)));
///
@@ -46,12 +44,12 @@ protected virtual List> GetModifications() =>
this.GetConfigurationBLLContext(context).Logics.DomainObjectModification.GetFullList()
.ToList(mod => new ObjectModificationInfoDTO
- {
- Identity = mod.DomainObjectId,
- ModificationType = mod.Type,
- Revision = mod.Revision,
- TypeInfoDescription = new TypeInfoDescriptionDTO { Name = mod.DomainType.Name, Namespace = mod.DomainType.Namespace }
- }));
+ {
+ Identity = mod.DomainObjectId,
+ ModificationType = mod.Type,
+ Revision = mod.Revision,
+ TypeInfoDescription = new TypeInfoDescriptionDTO { Name = mod.DomainType.Name, Namespace = mod.DomainType.Namespace }
+ }));
///
/// Отчистка списка модификаций
@@ -62,7 +60,7 @@ protected virtual void ClearModifications() =>
///
/// Отчистка интеграционных евентов
///
- public override void ClearIntegrationEvents()
+ public virtual void ClearIntegrationEvents()
{
this.ClearModifications();
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/RootServiceProviderContainer/ContextEvaluatorExtensions.cs b/src/AutomationCore/Framework.AutomationCore.Legacy/RootServiceProviderContainer/ContextEvaluatorExtensions.cs
similarity index 100%
rename from src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/RootServiceProviderContainer/ContextEvaluatorExtensions.cs
rename to src/AutomationCore/Framework.AutomationCore.Legacy/RootServiceProviderContainer/ContextEvaluatorExtensions.cs
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/RootServiceProviderContainer/ContextEvaluatorWithMappingExtensions.cs b/src/AutomationCore/Framework.AutomationCore.Legacy/RootServiceProviderContainer/ContextEvaluatorWithMappingExtensions.cs
similarity index 100%
rename from src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/RootServiceProviderContainer/ContextEvaluatorWithMappingExtensions.cs
rename to src/AutomationCore/Framework.AutomationCore.Legacy/RootServiceProviderContainer/ContextEvaluatorWithMappingExtensions.cs
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/RootServiceProviderContainer/IRootServiceProviderContainer.cs b/src/AutomationCore/Framework.AutomationCore.Legacy/RootServiceProviderContainer/IRootServiceProviderContainer.cs
similarity index 100%
rename from src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/RootServiceProviderContainer/IRootServiceProviderContainer.cs
rename to src/AutomationCore/Framework.AutomationCore.Legacy/RootServiceProviderContainer/IRootServiceProviderContainer.cs
diff --git a/src/AutomationCore/Framework.AutomationCore.Legacy/RootServiceProviderContainer/RootServiceProviderContainer.cs b/src/AutomationCore/Framework.AutomationCore.Legacy/RootServiceProviderContainer/RootServiceProviderContainer.cs
new file mode 100644
index 000000000..7e236216c
--- /dev/null
+++ b/src/AutomationCore/Framework.AutomationCore.Legacy/RootServiceProviderContainer/RootServiceProviderContainer.cs
@@ -0,0 +1,3 @@
+namespace Framework.AutomationCore.RootServiceProviderContainer;
+
+public class RootServiceProviderContainer(IServiceProvider rootServiceProvider) : RootServiceProviderContainer(rootServiceProvider), IRootServiceProviderContainer;
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/RootServiceProviderContainer/RootServiceProviderContainer.cs b/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/RootServiceProviderContainer/RootServiceProviderContainer.cs
deleted file mode 100644
index f13c8b40f..000000000
--- a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment.LegacyContext/RootServiceProviderContainer/RootServiceProviderContainer.cs
+++ /dev/null
@@ -1,4 +0,0 @@
-namespace Framework.AutomationCore.RootServiceProviderContainer;
-
-public abstract class RootServiceProviderContainer(IServiceProvider rootServiceProvider)
- : RootServiceProviderContainer(rootServiceProvider), IRootServiceProviderContainer;
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/Framework.AutomationCore.ServiceEnvironment.csproj b/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/Framework.AutomationCore.ServiceEnvironment.csproj
deleted file mode 100644
index d413da5e6..000000000
--- a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/Framework.AutomationCore.ServiceEnvironment.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- Luxoft.Framework.AutomationCore.ServiceEnvironment
- Framework.AutomationCore
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/IntegrationTestBase.cs b/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/IntegrationTestBase.cs
deleted file mode 100644
index a0bcb5cf1..000000000
--- a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/IntegrationTestBase.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using Framework.AutomationCore.Enums;
-using Framework.AutomationCore.ServiceEnvironment.Services;
-using Framework.AutomationCore.ServiceProviderPool;
-using Framework.AutomationCore.Utils.DatabaseUtils;
-
-using Microsoft.Extensions.DependencyInjection;
-
-using Anch.SecuritySystem.Testing;
-
-namespace Framework.AutomationCore;
-
-public abstract class IntegrationTestBase(IServiceProviderPool rootServiceProviderPool)
- : RootServiceProviderContainer.RootServiceProviderContainer(rootServiceProviderPool.Get())
-{
- public virtual void Initialize()
- {
- this.ReattachDatabase();
- this.ClearNotifications();
- this.ClearIntegrationEvents();
- this.ResetServices();
- }
-
- public virtual void Cleanup()
- {
- try
- {
- this.DropDatabaseAfterTest();
- this.CleanupTestEnvironment();
- }
- finally
- {
- this.ReleaseServiceProvider();
- }
- }
-
- protected virtual void ResetServices()
- {
- this.RootServiceProvider.GetService()?.Reset();
- this.RootServiceProvider.GetService()?.Reset();
- }
-
- protected virtual void DropDatabaseAfterTest()
- {
- if (this.AutomationFrameworkSettings.UseLocalDb || this.AutomationFrameworkSettings.TestRunMode == TestRunMode.DefaultRunModeOnEmptyDatabase)
- {
- AssemblyInitializeAndCleanupBase.RunAction("Drop Database", this.DatabaseContext.Drop);
- }
- }
-
- protected virtual void ReleaseServiceProvider()
- => rootServiceProviderPool.Release(this.RootServiceProvider);
-
- protected virtual void ReattachDatabase()
- {
- switch (this.AutomationFrameworkSettings.TestRunMode)
- {
- case TestRunMode.DefaultRunModeOnEmptyDatabase:
- case TestRunMode.RestoreDatabaseUsingAttach:
- AssemblyInitializeAndCleanupBase.RunAction("Drop Database", this.DatabaseContext.Drop);
- AssemblyInitializeAndCleanupBase.RunAction("Restore Databases", this.DatabaseContext.AttachDatabase);
- break;
- }
- }
-
- protected virtual void CleanupTestEnvironment()
- {
- }
-
- ///
- /// Отчистка списка нотифицаций
- ///
- public virtual void ClearNotifications()
- {
- }
-
- ///
- /// Отчистка интеграционных евентов
- ///
- public virtual void ClearIntegrationEvents()
- {
- }
-}
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/RootServiceProviderContainer/IRootServiceProviderContainer.cs b/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/RootServiceProviderContainer/IRootServiceProviderContainer.cs
deleted file mode 100644
index ed88e6f66..000000000
--- a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/RootServiceProviderContainer/IRootServiceProviderContainer.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Framework.AutomationCore.RootServiceProviderContainer;
-
-public interface IRootServiceProviderContainer
-{
- IServiceProvider RootServiceProvider { get; }
-}
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/RootServiceProviderContainer/RootServiceProviderContainer.cs b/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/RootServiceProviderContainer/RootServiceProviderContainer.cs
deleted file mode 100644
index 461122bdb..000000000
--- a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/RootServiceProviderContainer/RootServiceProviderContainer.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using Framework.Application.FinancialYear;
-using Framework.AutomationCore.ServiceEnvironment;
-using Framework.AutomationCore.Settings;
-using Framework.AutomationCore.Utils.DatabaseUtils.Interfaces;
-
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.DependencyInjection;
-
-using Anch.SecuritySystem;
-
-namespace Framework.AutomationCore.RootServiceProviderContainer;
-
-public abstract class RootServiceProviderContainer(IServiceProvider rootServiceProvider) : IRootServiceProviderContainer
-{
- public virtual IServiceProvider RootServiceProvider { get; } = rootServiceProvider;
-
- public AutomationFrameworkSettings AutomationFrameworkSettings => this.GetAutomationFrameworkSettings();
-
- public TimeProvider TimeProvider => this.GetTimeProvider();
-
- public IFinancialYearService FinancialYearService => this.RootServiceProvider.GetRequiredService();
-
- public IDatabaseContext DatabaseContext => this.GetDatabaseContext();
-
- public virtual ControllerEvaluator GetControllerEvaluator(UserCredential? userCredential = null)
- where TController : ControllerBase =>
- this.RootServiceProvider.GetDefaultControllerEvaluator(userCredential);
-}
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/TestInitializeAndCleanup.cs b/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/TestInitializeAndCleanup.cs
deleted file mode 100644
index 8a26d3115..000000000
--- a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/TestInitializeAndCleanup.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using Framework.AutomationCore.Enums;
-using Framework.AutomationCore.ServiceEnvironment.Services;
-using Framework.AutomationCore.Settings;
-using Framework.AutomationCore.Utils.DatabaseUtils;
-using Framework.AutomationCore.Utils.DatabaseUtils.Interfaces;
-
-using Microsoft.Extensions.Options;
-
-using Anch.SecuritySystem.Testing;
-
-namespace Framework.AutomationCore;
-
-public class TestInitializeAndCleanup(
- IOptions settings,
- IDatabaseContext databaseContext,
- IntegrationTestTimeProvider timeProvider,
- RootImpersonateServiceState rootImpersonateServiceState)
-{
- private readonly AutomationFrameworkSettings settings = settings.Value;
-
- public virtual async Task InitializeAsync()
- {
- this.ReattachDatabase();
- this.ResetServices();
- }
-
- public virtual async Task CleanupAsync()
- {
- this.DropDatabaseAfterTest();
- this.CleanupTestEnvironment();
- }
-
- protected virtual void ResetServices()
- {
- timeProvider.Reset();
- rootImpersonateServiceState.Reset();
- }
-
- protected virtual void DropDatabaseAfterTest()
- {
- if (this.settings.UseLocalDb || this.settings.TestRunMode == TestRunMode.DefaultRunModeOnEmptyDatabase || this.settings.TestsParallelize)
- {
- AssemblyInitializeAndCleanupBase.RunAction("Drop Database", databaseContext.Drop);
- }
- }
-
- protected virtual void ReattachDatabase()
- {
- switch (this.settings.TestRunMode)
- {
- case TestRunMode.DefaultRunModeOnEmptyDatabase:
- case TestRunMode.RestoreDatabaseUsingAttach:
- AssemblyInitializeAndCleanupBase.RunAction("Drop Database", databaseContext.Drop);
- AssemblyInitializeAndCleanupBase.RunAction("Restore Databases", databaseContext.AttachDatabase);
- break;
- }
- }
-
- protected virtual void CleanupTestEnvironment()
- {
- }
-}
diff --git a/src/AutomationCore/Framework.AutomationCore.Xunit/AutomationCoreFrameworkInitializer.cs b/src/AutomationCore/Framework.AutomationCore.Xunit/AutomationCoreFrameworkInitializer.cs
index f0dad9dc1..28d2e226f 100644
--- a/src/AutomationCore/Framework.AutomationCore.Xunit/AutomationCoreFrameworkInitializer.cs
+++ b/src/AutomationCore/Framework.AutomationCore.Xunit/AutomationCoreFrameworkInitializer.cs
@@ -1,73 +1,73 @@
-using Bss.Testing.Xunit.Interfaces;
+//using Bss.Testing.Xunit.Interfaces;
-using Framework.AutomationCore.Extensions;
-using Framework.AutomationCore.Settings;
-using Framework.AutomationCore.Utils.DatabaseUtils;
-using Framework.AutomationCore.Utils.DatabaseUtils.Interfaces;
-using Framework.AutomationCore.Xunit.ServiceProviderPool;
+//using Framework.AutomationCore.Extensions;
+//using Framework.AutomationCore.Settings;
+//using Framework.AutomationCore.Utils.DatabaseUtils;
+//using Framework.AutomationCore.Utils.DatabaseUtils.Interfaces;
+//using Framework.AutomationCore.Xunit.ServiceProviderPool;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.DependencyInjection.Extensions;
-using Microsoft.Extensions.Options;
+//using Microsoft.Extensions.Configuration;
+//using Microsoft.Extensions.DependencyInjection;
+//using Microsoft.Extensions.DependencyInjection.Extensions;
+//using Microsoft.Extensions.Options;
-namespace Framework.AutomationCore.Xunit;
+//namespace Framework.AutomationCore.Xunit;
-public abstract class AutomationCoreFrameworkInitializer : IFrameworkInitializer
-{
- public abstract IServiceCollection ConfigureFramework(IServiceCollection services);
+//public abstract class AutomationCoreFrameworkInitializer : IFrameworkInitializer
+//{
+// public abstract IServiceCollection ConfigureFramework(IServiceCollection services);
- public abstract IServiceProvider ConfigureTestEnvironment(IServiceCollection services, IConfiguration configuration);
+// public abstract IServiceProvider ConfigureTestEnvironment(IServiceCollection services, IConfiguration configuration);
- public IServiceProvider GetFrameworkServiceProvider()
- {
- var frameworkServices = new ServiceCollection();
- AddSettings(frameworkServices);
- this.ConfigureFramework(frameworkServices);
+// public IServiceProvider GetFrameworkServiceProvider()
+// {
+// var frameworkServices = new ServiceCollection();
+// AddSettings(frameworkServices);
+// this.ConfigureFramework(frameworkServices);
- frameworkServices.TryAddSingleton();
- frameworkServices.TryAddSingleton();
+// frameworkServices.TryAddSingleton();
+// frameworkServices.TryAddSingleton();
- frameworkServices.AddSingleton(
- sp => new ServiceProviderPoolFunc(this.GetPoolServiceProviderFunc(sp)));
+// frameworkServices.AddSingleton(
+// sp => new ServiceProviderPoolFunc(this.GetPoolServiceProviderFunc(sp)));
- return frameworkServices.BuildServiceProvider(
- new ServiceProviderOptions
- {
- ValidateScopes = true,
- ValidateOnBuild = true
- });
- }
+// return frameworkServices.BuildServiceProvider(
+// new ServiceProviderOptions
+// {
+// ValidateScopes = true,
+// ValidateOnBuild = true
+// });
+// }
- private Func GetPoolServiceProviderFunc(IServiceProvider frameworkSp)
- {
- var rootConfiguration = frameworkSp.GetRequiredService();
- var automationFrameworkSettings = frameworkSp.GetRequiredService>();
+// private Func GetPoolServiceProviderFunc(IServiceProvider frameworkSp)
+// {
+// var rootConfiguration = frameworkSp.GetRequiredService();
+// var automationFrameworkSettings = frameworkSp.GetRequiredService>();
- return () =>
- {
- var databaseContext = new DatabaseContext(rootConfiguration, automationFrameworkSettings);
- var configuration = rootConfiguration.BuildFromRootWithConnectionStrings(databaseContext);
+// return () =>
+// {
+// var databaseContext = new DatabaseContext(rootConfiguration, automationFrameworkSettings);
+// var configuration = rootConfiguration.BuildFromRootWithConnectionStrings(databaseContext);
- var environmentServices = new ServiceCollection()
- .AddSingleton(databaseContext)
- .AddSingleton(configuration)
- .AddSingleton(automationFrameworkSettings);
+// var environmentServices = new ServiceCollection()
+// .AddSingleton(databaseContext)
+// .AddSingleton(configuration)
+// .AddSingleton(automationFrameworkSettings);
- return this.ConfigureTestEnvironment(environmentServices, configuration);
- };
- }
+// return this.ConfigureTestEnvironment(environmentServices, configuration);
+// };
+// }
- private static void AddSettings(IServiceCollection services)
- {
- services.AddOptions();
- services.AddSingleton>(
- s =>
- {
- return new ConfigureOptions(
- opt => s.GetRequiredService()
- .Bind(nameof(AutomationFrameworkSettings), opt));
- });
- }
-}
+// private static void AddSettings(IServiceCollection services)
+// {
+// services.AddOptions();
+// services.AddSingleton>(
+// s =>
+// {
+// return new ConfigureOptions(
+// opt => s.GetRequiredService()
+// .Bind(nameof(AutomationFrameworkSettings), opt));
+// });
+// }
+//}
diff --git a/src/AutomationCore/Framework.AutomationCore.Xunit/DependencyInjection.cs b/src/AutomationCore/Framework.AutomationCore.Xunit/DependencyInjection.cs
index 30a09ccfb..fd1f43432 100644
--- a/src/AutomationCore/Framework.AutomationCore.Xunit/DependencyInjection.cs
+++ b/src/AutomationCore/Framework.AutomationCore.Xunit/DependencyInjection.cs
@@ -1,17 +1,17 @@
-using Bss.Testing.Xunit.Interfaces;
+//using Bss.Testing.Xunit.Interfaces;
-using Framework.AutomationCore.ServiceEnvironment;
-using Framework.AutomationCore.Settings;
-using Framework.AutomationCore.Xunit.ServiceEnvironment;
+//using Framework.AutomationCore.ServiceEnvironment;
+//using Framework.AutomationCore.Settings;
+//using Framework.AutomationCore.Xunit.ServiceEnvironment;
-using Microsoft.Extensions.DependencyInjection;
+//using Microsoft.Extensions.DependencyInjection;
-namespace Framework.AutomationCore.Xunit;
+//namespace Framework.AutomationCore.Xunit;
-public static class DependencyInjection
-{
- public static IServiceCollection AddXunitIntegrationTests(this IServiceCollection services, Action? setup = null) =>
- services
- .AddSingleton()
- .AddIntegrationTests(setup);
-}
+//public static class DependencyInjection
+//{
+// public static IServiceCollection AddXunitIntegrationTests(this IServiceCollection services, Action? setup = null) =>
+// services
+// .AddSingleton()
+// .AddIntegrationTests(setup);
+//}
diff --git a/src/AutomationCore/Framework.AutomationCore.Xunit/Framework.AutomationCore.Xunit.csproj b/src/AutomationCore/Framework.AutomationCore.Xunit/Framework.AutomationCore.Xunit.csproj
index d92a0413a..995539b25 100644
--- a/src/AutomationCore/Framework.AutomationCore.Xunit/Framework.AutomationCore.Xunit.csproj
+++ b/src/AutomationCore/Framework.AutomationCore.Xunit/Framework.AutomationCore.Xunit.csproj
@@ -8,12 +8,4 @@
-
-
-
-
-
-
-
-
diff --git a/src/AutomationCore/Framework.AutomationCore.Xunit/ServiceEnvironment/DiAssemblyInitializeAndCleanup.cs b/src/AutomationCore/Framework.AutomationCore.Xunit/ServiceEnvironment/DiAssemblyInitializeAndCleanup.cs
deleted file mode 100644
index a578f2d4a..000000000
--- a/src/AutomationCore/Framework.AutomationCore.Xunit/ServiceEnvironment/DiAssemblyInitializeAndCleanup.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using Bss.Testing.Xunit.Interfaces;
-
-using Framework.AutomationCore.Settings;
-using Framework.AutomationCore.Utils.DatabaseUtils.Interfaces;
-
-using Microsoft.Extensions.Options;
-
-namespace Framework.AutomationCore.Xunit.ServiceEnvironment;
-
-public class DiAssemblyInitializeAndCleanup(
- IOptions settings,
- ITestDatabaseGenerator databaseGenerator)
- : AssemblyInitializeAndCleanupBase, IAssemblyInitializeAndCleanup
-{
- private readonly AutomationFrameworkSettings settings = settings.Value;
-
- public async Task EnvironmentInitializeAsync() => await this.InitializeAsync(this.settings, databaseGenerator);
-
- public async Task EnvironmentCleanupAsync() => await this.CleanupAsync(this.settings, databaseGenerator);
-}
diff --git a/src/AutomationCore/Framework.AutomationCore.Xunit/ServiceEnvironment/DiTestInitializeAndCleanup.cs b/src/AutomationCore/Framework.AutomationCore.Xunit/ServiceEnvironment/DiTestInitializeAndCleanup.cs
deleted file mode 100644
index 0abbf7997..000000000
--- a/src/AutomationCore/Framework.AutomationCore.Xunit/ServiceEnvironment/DiTestInitializeAndCleanup.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using Bss.Testing.Xunit.Interfaces;
-
-using Framework.AutomationCore.ServiceEnvironment.Services;
-using Framework.AutomationCore.Settings;
-using Framework.AutomationCore.Utils.DatabaseUtils.Interfaces;
-
-using Microsoft.Extensions.Options;
-
-using Anch.SecuritySystem.Testing;
-
-namespace Framework.AutomationCore.Xunit.ServiceEnvironment;
-
-public class DiTestInitializeAndCleanup(
- IOptions settings,
- IDatabaseContext databaseContext,
- IntegrationTestTimeProvider timeProvider,
- RootImpersonateServiceState rootImpersonateServiceState)
- : TestInitializeAndCleanup(settings, databaseContext, timeProvider, rootImpersonateServiceState),
- ITestInitializeAndCleanup;
diff --git a/src/AutomationCore/Framework.AutomationCore.Xunit/ServiceProviderPool/DiServiceProviderPool.cs b/src/AutomationCore/Framework.AutomationCore.Xunit/ServiceProviderPool/DiServiceProviderPool.cs
deleted file mode 100644
index 879bf7ce8..000000000
--- a/src/AutomationCore/Framework.AutomationCore.Xunit/ServiceProviderPool/DiServiceProviderPool.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.Collections.Concurrent;
-
-using Bss.Testing.Xunit.Interfaces;
-
-namespace Framework.AutomationCore.Xunit.ServiceProviderPool;
-
-public class DiServiceProviderPool(ServiceProviderPoolFunc createServiceProviderFunc) : ITestServiceProviderPool
-{
- private readonly Func createServiceProviderFunc = createServiceProviderFunc.Value;
- private readonly ConcurrentBag providersCache = [];
-
- public IServiceProvider Get() =>
- this.providersCache.TryTake(out var provider) ? provider : this.createServiceProviderFunc.Invoke();
-
- public void Release(IServiceProvider serviceProvider) => this.providersCache.Add(serviceProvider);
-}
diff --git a/src/AutomationCore/Framework.AutomationCore.Xunit/ServiceProviderPool/ServiceProviderPoolFunc.cs b/src/AutomationCore/Framework.AutomationCore.Xunit/ServiceProviderPool/ServiceProviderPoolFunc.cs
deleted file mode 100644
index 15409c654..000000000
--- a/src/AutomationCore/Framework.AutomationCore.Xunit/ServiceProviderPool/ServiceProviderPoolFunc.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Framework.AutomationCore.Xunit.ServiceProviderPool;
-
-public class ServiceProviderPoolFunc(Func func)
-{
- public readonly Func Value = func;
-}
diff --git a/src/AutomationCore/Framework.AutomationCore/AssemblyInitializeAndCleanup.cs b/src/AutomationCore/Framework.AutomationCore/AssemblyInitializeAndCleanup.cs
deleted file mode 100644
index e20aa7a52..000000000
--- a/src/AutomationCore/Framework.AutomationCore/AssemblyInitializeAndCleanup.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using Framework.AutomationCore.Settings;
-using Framework.AutomationCore.Utils.DatabaseUtils.Interfaces;
-
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Options;
-
-namespace Framework.AutomationCore;
-
-public class AssemblyInitializeAndCleanup(
- Func getServiceProviderAction,
- Action releaseServiceProviderAction)
- : AssemblyInitializeAndCleanupBase
-{
- public async Task EnvironmentInitializeAsync()
- {
- var serviceProvider = getServiceProviderAction.Invoke();
-
- try
- {
- await this.InitializeAsync(serviceProvider);
- }
- finally
- {
- releaseServiceProviderAction(serviceProvider);
- }
- }
-
- public async Task EnvironmentCleanupAsync()
- {
- var serviceProvider = getServiceProviderAction.Invoke();
- try
- {
- await this.CleanupAsync(serviceProvider);
- }
- finally
- {
- releaseServiceProviderAction(serviceProvider);
- }
- }
-
- protected async Task CleanupAsync(IServiceProvider serviceProvider)
- {
- var settings = serviceProvider.GetRequiredService>();
- var databaseGenerator = serviceProvider.GetRequiredService();
-
- await this.CleanupAsync(settings.Value, databaseGenerator);
- }
-
- protected async Task InitializeAsync(IServiceProvider serviceProvider)
- {
- var settings = serviceProvider.GetRequiredService>();
- var databaseGenerator = serviceProvider.GetRequiredService();
-
- await this.InitializeAsync(settings.Value, databaseGenerator);
- }
-}
diff --git a/src/AutomationCore/Framework.AutomationCore/AssemblyInitializeAndCleanupBase.cs b/src/AutomationCore/Framework.AutomationCore/AssemblyInitializeAndCleanupBase.cs
deleted file mode 100644
index 84a8a1fe6..000000000
--- a/src/AutomationCore/Framework.AutomationCore/AssemblyInitializeAndCleanupBase.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using System.Diagnostics;
-
-using Framework.AutomationCore.Enums;
-using Framework.AutomationCore.Settings;
-using Framework.AutomationCore.Utils.DatabaseUtils;
-using Framework.AutomationCore.Utils.DatabaseUtils.Interfaces;
-
-namespace Framework.AutomationCore;
-
-public class AssemblyInitializeAndCleanupBase
-{
- public static void RunAction(string name, Action action)
- {
- var watch = new Stopwatch();
-
- Console.WriteLine(name);
-
- watch.Start();
- action();
- watch.Stop();
-
- Console.WriteLine("Elapsed time - {0}", watch.Elapsed);
- Console.WriteLine();
- Console.WriteLine();
- }
-
- protected virtual async Task CleanupAsync(AutomationFrameworkSettings settings, ITestDatabaseGenerator databaseGenerator)
- {
- switch (settings.TestRunMode)
- {
- case TestRunMode.DefaultRunModeOnEmptyDatabase:
- await databaseGenerator.CheckTestDatabaseAsync();
- databaseGenerator.DatabaseContext.Drop();
- databaseGenerator.DeleteDetachedFiles();
- databaseGenerator.DeleteLocalDb();
- break;
-
- default:
- databaseGenerator.DeleteLocalDb();
- break;
- }
- }
-
-
- protected virtual async Task InitializeAsync(AutomationFrameworkSettings settings, ITestDatabaseGenerator databaseGenerator)
- {
- switch (settings.TestRunMode)
- {
- case TestRunMode.RestoreDatabaseUsingAttach:
- databaseGenerator.CreateLocalDb();
- await databaseGenerator.CheckTestDatabaseAsync();
- await databaseGenerator.CheckAndCreateDetachedFilesAsync();
- databaseGenerator.DatabaseContext.Drop();
- break;
- case TestRunMode.GenerateTestDataOnExistingDatabase:
- break;
- default:
- databaseGenerator.CreateLocalDb();
- await databaseGenerator.CheckTestDatabaseAsync();
- databaseGenerator.DeleteDetachedFiles();
- databaseGenerator.DatabaseContext.ReCreate();
- await databaseGenerator.GenerateDatabasesAsync();
- databaseGenerator.ExecuteInsertsForDatabases();
- await databaseGenerator.GenerateTestDataAsync();
- databaseGenerator.DatabaseContext.CopyDetachedFiles();
- databaseGenerator.DatabaseContext.Drop();
- break;
- }
- }
-}
diff --git a/src/AutomationCore/Framework.AutomationCore/BssDatabaseFilePathExtractor.cs b/src/AutomationCore/Framework.AutomationCore/BssDatabaseFilePathExtractor.cs
new file mode 100644
index 000000000..09e256e77
--- /dev/null
+++ b/src/AutomationCore/Framework.AutomationCore/BssDatabaseFilePathExtractor.cs
@@ -0,0 +1,69 @@
+using Anch.Core;
+using Anch.DependencyInjection;
+using Anch.Testing;
+using Anch.Testing.Database;
+using Anch.Testing.Database.DependencyInjection;
+
+using Framework.AutomationCore.ServiceEnvironment;
+using Framework.AutomationCore.Settings;
+using Framework.AutomationCore.TestingProvider;
+using Framework.Core;
+using Framework.Database;
+using Framework.Database.ConnectionStringSource;
+
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Framework.AutomationCore;
+
+public abstract class BssTestEnvironment : ITestEnvironment
+{
+ protected abstract IConfiguration Configuration { get; }
+
+ private AutomationFrameworkSettings Settings => field ??= new AutomationFrameworkSettings().Self(this.Configuration.Bind);
+
+ protected virtual string DefaultConnectionStringName => "DefaultConnection";
+
+ protected virtual string DefaultConnectionString => field ??= this.Configuration.GetConnectionString(this.DefaultConnectionStringName)
+ ?? throw new InvalidOperationException(
+ $"{this.DefaultConnectionStringName} connection string is not configured.");
+
+ private TestDatabaseSettings TestDatabaseSettings =>
+ field ??= new TestDatabaseSettings { InitMode = this.Settings.DatabaseInitMode, DefaultConnectionString = new(this.DefaultConnectionString) };
+
+ public bool AllowParallelization => this.Settings.TestsParallelize;
+
+ protected virtual void InitServices(IServiceCollection services)
+ {
+
+ }
+
+ protected virtual void InitInitializers(IDatabaseTestingSetup setup)
+ {
+
+ }
+
+ public IServiceProvider BuildServiceProvider(IServiceCollection services)
+ {
+ services.AddOptions();
+
+ return services.AddSingleton(this.Configuration)
+
+ .Self(this.InitServices)
+
+ .AddIntegrationTests()
+
+ .AddDatabaseTesting(dts => dts
+ .SetProvider()
+ .Self(this.InitInitializers)
+ .SetSettings(this.TestDatabaseSettings)
+ .RebindActualConnection(connectionString =>
+ new ManualDefaultConnectionStringSource(connectionString.Value)))
+
+ .Pipe(this.InternalBuildServiceProvider);
+ }
+
+ protected virtual IServiceProvider InternalBuildServiceProvider(IServiceCollection services) =>
+ services.AddValidator()
+ .BuildServiceProvider(new ServiceProviderOptions { ValidateScopes = true, ValidateOnBuild = true });
+}
diff --git a/src/AutomationCore/Framework.AutomationCore/Enums/TestRunMode.cs b/src/AutomationCore/Framework.AutomationCore/Enums/TestRunMode.cs
deleted file mode 100644
index 60ce04af9..000000000
--- a/src/AutomationCore/Framework.AutomationCore/Enums/TestRunMode.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Framework.AutomationCore.Enums;
-
-public enum TestRunMode
-{
- DefaultRunModeOnEmptyDatabase = 0,
-
- RestoreDatabaseUsingAttach = 1,
-
- GenerateTestDataOnExistingDatabase = 2,
-}
diff --git a/src/AutomationCore/Framework.AutomationCore/Environment/TestEnvironment.cs b/src/AutomationCore/Framework.AutomationCore/Environment/TestEnvironment.cs
deleted file mode 100644
index 2475bd399..000000000
--- a/src/AutomationCore/Framework.AutomationCore/Environment/TestEnvironment.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using Framework.AutomationCore.ServiceProviderPool;
-
-namespace Framework.AutomationCore.Environment;
-
-public class TestEnvironment
-{
- public readonly AssemblyInitializeAndCleanup AssemblyInitializeAndCleanup;
-
- public readonly IServiceProviderPool ServiceProviderPool;
-
- internal TestEnvironment(IServiceProviderPool serviceProviderPool, AssemblyInitializeAndCleanup assemblyInitializeAndCleanup)
- {
- this.AssemblyInitializeAndCleanup = assemblyInitializeAndCleanup;
- this.ServiceProviderPool = serviceProviderPool;
- }
-}
diff --git a/src/AutomationCore/Framework.AutomationCore/Environment/TestEnvironmentBuilder.cs b/src/AutomationCore/Framework.AutomationCore/Environment/TestEnvironmentBuilder.cs
deleted file mode 100644
index 21d93ee64..000000000
--- a/src/AutomationCore/Framework.AutomationCore/Environment/TestEnvironmentBuilder.cs
+++ /dev/null
@@ -1,169 +0,0 @@
-using Anch.DependencyInjection;
-
-using Framework.AutomationCore.Extensions;
-using Framework.AutomationCore.ServiceProviderPool;
-using Framework.AutomationCore.Settings;
-using Framework.AutomationCore.Utils.DatabaseUtils;
-using Framework.AutomationCore.Utils.DatabaseUtils.Interfaces;
-
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.DependencyInjection.Extensions;
-using Microsoft.Extensions.Options;
-
-namespace Framework.AutomationCore.Environment;
-
-public class TestEnvironmentBuilder
-{
- private IConfiguration? withConfiguration;
-
- private Func? withServiceProviderBuildFunc;
-
- private Action withServiceProvAfterBuildAction = _ => { };
-
- private Action withAutomationFrameworkSettings = _ => { };
-
- private Type? withDatabaseGenerator;
-
- public TestEnvironmentBuilder WithConfiguration(IConfiguration rootConfiguration)
- {
- this.withConfiguration = rootConfiguration;
-
- return this;
- }
-
- public TestEnvironmentBuilder WithDefaultConfiguration(
- string environmentVariablesPrefix = "",
- string settingsFileName = "appsettings.json")
- {
- this.withConfiguration = new ConfigurationBuilder()
- .SetBasePath(Directory.GetCurrentDirectory())
- .AddJsonFile(settingsFileName, false)
- .AddJsonFile($@"{System.Environment.MachineName}.{settingsFileName}", true)
- .AddEnvironmentVariables(environmentVariablesPrefix)
- .Build();
-
- return this;
- }
-
- public TestEnvironmentBuilder WithAutomationFrameworkSettings(Action settings)
- {
- this.withAutomationFrameworkSettings = settings;
-
- return this;
- }
-
- public TestEnvironmentBuilder WithServiceProviderBuildFunc(Func buildFunc)
- {
- this.withServiceProviderBuildFunc = buildFunc;
-
- return this;
- }
-
- public TestEnvironmentBuilder WithServiceProviderAfterBuildAction(Action afterBuildAction)
- {
- this.withServiceProvAfterBuildAction = afterBuildAction;
-
- return this;
- }
-
- public TestEnvironmentBuilder WithDatabaseGenerator() where T: ITestDatabaseGenerator
- {
- this.withDatabaseGenerator = typeof(T);
-
- return this;
- }
-
- public TestEnvironment Build()
- {
- if (this.withConfiguration == null)
- {
- this.WithDefaultConfiguration();
- }
-
- if (this.withDatabaseGenerator == null)
- {
- throw new ArgumentException("Please provide DatabaseGenerator via '.WithDatabaseGenerator()'");
- }
-
- if (this.withServiceProviderBuildFunc == null)
- {
- throw new ArgumentException("Please provide ServiceProvider build function via '.WithServiceProviderBuildFunc()'");
- }
-
- var serviceProviderPool = this.GetServiceProviderPool(
- this.withConfiguration!,
- this.withServiceProviderBuildFunc,
- this.withServiceProvAfterBuildAction,
- this.withDatabaseGenerator,
- this.withAutomationFrameworkSettings);
-
- return new TestEnvironment(
- serviceProviderPool,
- this.GetAssemblyInitializeAndCleanup(serviceProviderPool));
- }
-
- protected virtual AssemblyInitializeAndCleanup GetAssemblyInitializeAndCleanup(
- IServiceProviderPool serviceProviderPool) =>
- new(
- serviceProviderPool.Get,
- serviceProviderPool.Release);
-
- protected virtual IServiceProvider BuildServiceProvider(IServiceCollection serviceCollection) =>
- serviceCollection
- .AddValidator()
- .Validate()
- .BuildServiceProvider(
- new ServiceProviderOptions { ValidateOnBuild = true, ValidateScopes = true });
-
- protected virtual IServiceProviderPool GetServiceProviderPool(
- IConfiguration rootConfiguration,
- Func serviceProviderBuildFunc,
- Action serviceProviderAfterBuildAction,
- Type databaseGenerator,
- Action settingsAction) =>
- new ServiceProviderPool.ServiceProviderPool(
- () => this.ServiceProviderGenerationFunc(
- serviceProviderBuildFunc,
- serviceProviderAfterBuildAction,
- rootConfiguration,
- databaseGenerator,
- settingsAction),
- rootConfiguration.GetValue("TestsParallelize"),
- rootConfiguration.GetValue("DisableServiceProviderPoolLimiter"));
-
- private IServiceProvider ServiceProviderGenerationFunc(
- Func serviceProviderBuildFunc,
- Action serviceProviderAfterBuildAction,
- IConfiguration rootConfiguration,
- Type databaseGeneratorType,
- Action settingsAction)
- {
- var settings = GetSettings(rootConfiguration, settingsAction);
- var databaseContext = new DatabaseContext(rootConfiguration, settings);
-
- var cfg = rootConfiguration.BuildFromRootWithConnectionStrings(databaseContext);
-
- var environmentServices = new ServiceCollection();
- serviceProviderBuildFunc.Invoke(cfg, environmentServices);
- environmentServices.TryAddSingleton(settings);
- environmentServices.TryAddSingleton(databaseContext);
- environmentServices.AddSingleton(cfg)
- .AddSingleton(typeof(ITestDatabaseGenerator), databaseGeneratorType);
-
- var environmentServiceProvider = this.BuildServiceProvider(environmentServices);
-
- serviceProviderAfterBuildAction(environmentServiceProvider);
-
- return environmentServiceProvider;
- }
-
- private static IOptions GetSettings(IConfiguration configuration, Action action)
- {
- var settings = new AutomationFrameworkSettings();
- configuration.GetSection(nameof(AutomationFrameworkSettings)).Bind(settings);
- action(settings);
-
- return Options.Create(settings);
- }
-}
diff --git a/src/AutomationCore/Framework.AutomationCore/Extensions/ConfigurationExtensions.cs b/src/AutomationCore/Framework.AutomationCore/Extensions/ConfigurationExtensions.cs
deleted file mode 100644
index 3fa66d88a..000000000
--- a/src/AutomationCore/Framework.AutomationCore/Extensions/ConfigurationExtensions.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using Framework.AutomationCore.Utils.DatabaseUtils.Interfaces;
-
-using Microsoft.Extensions.Configuration;
-
-namespace Framework.AutomationCore.Extensions;
-
-public static class ConfigurationExtensions
-{
- public static IConfiguration BuildFromRootWithConnectionStrings(
- this IConfiguration rootConfiguration,
- IDatabaseContext databaseContext) =>
- new ConfigurationBuilder()
- .AddConfiguration(rootConfiguration)
- .AddInMemoryCollection(
- rootConfiguration.GetSection("ConnectionStrings")
- .GetChildren()
- .ToDictionary(x => $"ConnectionStrings:{x.Key}", _ => databaseContext.Main.ConnectionString))
- .Build();
-}
diff --git a/src/AutomationCore/Framework.AutomationCore/Extensions/Excel/Column.cs b/src/AutomationCore/Framework.AutomationCore/Extensions/Excel/Column.cs
deleted file mode 100644
index 551701f63..000000000
--- a/src/AutomationCore/Framework.AutomationCore/Extensions/Excel/Column.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace Framework.AutomationCore.Extensions.Excel;
-
-[AttributeUsage(AttributeTargets.All)]
-public class Column : Attribute
-{
- public string Name { get; set; }
-
- public int? Index { get; }
-
- public Column(string name) => this.Name = name;
-
- public Column(int index) => this.Index = index;
-}
diff --git a/src/AutomationCore/Framework.AutomationCore/Extensions/ObjectExtensions.cs b/src/AutomationCore/Framework.AutomationCore/Extensions/ObjectExtensions.cs
deleted file mode 100644
index 2b6b6a7aa..000000000
--- a/src/AutomationCore/Framework.AutomationCore/Extensions/ObjectExtensions.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System.ComponentModel;
-using System.Reflection;
-
-namespace Framework.AutomationCore.Extensions;
-
-public static class ObjectExtensions
-{
- public static string GetDescription(this Enum obj, string propertyName)
- {
- var propertyInfo = obj.GetType().GetProperty(propertyName);
- var attr = propertyInfo?.GetCustomAttribute(typeof(DescriptionAttribute));
-
- return attr != null
- ? ((DescriptionAttribute)attr).Description
- : propertyName;
- }
-}
diff --git a/src/AutomationCore/Framework.AutomationCore/Extensions/StreamExtensions.cs b/src/AutomationCore/Framework.AutomationCore/Extensions/StreamExtensions.cs
deleted file mode 100644
index fd55604d5..000000000
--- a/src/AutomationCore/Framework.AutomationCore/Extensions/StreamExtensions.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace Framework.AutomationCore.Extensions;
-
-public static class StreamExtensions
-{
- public static void Save(this Stream stream, string folder, string? fileName = null, string extension = "xlsx")
- {
- fileName = fileName != null ? $"{fileName}.{extension}" : $"report_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.{extension}";
- var filePath = Path.Combine(folder, fileName);
-
- using var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write);
- stream.CopyTo(fileStream);
- stream.Close();
- fileStream.Close();
- }
-}
diff --git a/src/AutomationCore/Framework.AutomationCore/Framework.AutomationCore.csproj b/src/AutomationCore/Framework.AutomationCore/Framework.AutomationCore.csproj
index 8d54dbe86..ed91a75b5 100644
--- a/src/AutomationCore/Framework.AutomationCore/Framework.AutomationCore.csproj
+++ b/src/AutomationCore/Framework.AutomationCore/Framework.AutomationCore.csproj
@@ -9,24 +9,17 @@
-
-
+
+
+
-
+
-
-
-
-
-
-
-
-
-
+
diff --git a/src/AutomationCore/Framework.AutomationCore/Helpers/DatabaseHelper.cs b/src/AutomationCore/Framework.AutomationCore/Helpers/DatabaseHelper.cs
deleted file mode 100644
index 0ca7568ac..000000000
--- a/src/AutomationCore/Framework.AutomationCore/Helpers/DatabaseHelper.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.Reflection;
-
-using Dapper;
-using Dapper.Contrib.Extensions;
-
-using Microsoft.Data.SqlClient;
-
-namespace Framework.AutomationCore.Helpers;
-
-public static class DatabaseHelper
-{
- public static List GetAll(string connectionString)
- where T : class
- {
- var tableName = GetTableName(typeof(T));
-
- using (var connection = new SqlConnection(connectionString))
- {
- connection.Open();
- return connection.Query($"SELECT * FROM {tableName}").ToList();
- }
- }
-
- private static string GetTableName(Type type)
- {
- var tableAttrName =
- type.GetCustomAttribute(false)?.Name
- ?? (type.GetCustomAttributes(false).FirstOrDefault(attr => attr.GetType().Name == "TableAttribute") as dynamic)?.Name;
-
- if (tableAttrName != null)
- {
- return tableAttrName;
- }
-
- throw new Exception($"Table name for '{type.Name}' not found");
- }
-}
diff --git a/src/AutomationCore/Framework.AutomationCore/RootServiceProviderContainer/IRootServiceProviderContainer.cs b/src/AutomationCore/Framework.AutomationCore/RootServiceProviderContainer/IRootServiceProviderContainer.cs
new file mode 100644
index 000000000..d23a71ac3
--- /dev/null
+++ b/src/AutomationCore/Framework.AutomationCore/RootServiceProviderContainer/IRootServiceProviderContainer.cs
@@ -0,0 +1,16 @@
+using Anch.SecuritySystem;
+
+using Framework.AutomationCore.ServiceEnvironment;
+
+using Microsoft.AspNetCore.Mvc;
+
+namespace Framework.AutomationCore.RootServiceProviderContainer;
+
+public interface IRootServiceProviderContainer
+{
+ IServiceProvider RootServiceProvider { get; }
+
+ ControllerEvaluator GetControllerEvaluator(UserCredential? userCredential = null)
+ where TController : ControllerBase =>
+ this.RootServiceProvider.GetDefaultControllerEvaluator(userCredential);
+}
diff --git a/src/AutomationCore/Framework.AutomationCore/RootServiceProviderContainer/RootServiceProviderContainer.cs b/src/AutomationCore/Framework.AutomationCore/RootServiceProviderContainer/RootServiceProviderContainer.cs
new file mode 100644
index 000000000..652eacd57
--- /dev/null
+++ b/src/AutomationCore/Framework.AutomationCore/RootServiceProviderContainer/RootServiceProviderContainer.cs
@@ -0,0 +1,16 @@
+using Anch.SecuritySystem;
+
+using Framework.AutomationCore.ServiceEnvironment;
+
+using Microsoft.AspNetCore.Mvc;
+
+namespace Framework.AutomationCore.RootServiceProviderContainer;
+
+public class RootServiceProviderContainer(IServiceProvider rootServiceProvider) : IRootServiceProviderContainer
+{
+ public IServiceProvider RootServiceProvider { get; } = rootServiceProvider;
+
+ public virtual ControllerEvaluator GetControllerEvaluator(UserCredential? userCredential = null)
+ where TController : ControllerBase =>
+ this.RootServiceProvider.GetDefaultControllerEvaluator(userCredential);
+}
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/RootServiceProviderContainer/RootServiceProviderContainerExtensions.cs b/src/AutomationCore/Framework.AutomationCore/RootServiceProviderContainer/RootServiceProviderContainerExtensions.cs
similarity index 52%
rename from src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/RootServiceProviderContainer/RootServiceProviderContainerExtensions.cs
rename to src/AutomationCore/Framework.AutomationCore/RootServiceProviderContainer/RootServiceProviderContainerExtensions.cs
index f41948f98..6b2ea9c33 100644
--- a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/RootServiceProviderContainer/RootServiceProviderContainerExtensions.cs
+++ b/src/AutomationCore/Framework.AutomationCore/RootServiceProviderContainer/RootServiceProviderContainerExtensions.cs
@@ -1,10 +1,12 @@
using System.Linq.Expressions;
-using Framework.AutomationCore.ServiceEnvironment;
+using Framework.Application.FinancialYear;
using Framework.AutomationCore.ServiceEnvironment.Services;
using Framework.AutomationCore.Settings;
using Framework.AutomationCore.Utils.DatabaseUtils.Interfaces;
+//using Framework.AutomationCore.Utils.DatabaseUtils.Interfaces;
+
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
@@ -15,20 +17,23 @@ public static class RootServiceProviderContainerExtensions
{
extension(IRootServiceProviderContainer rootServiceProviderContainer)
{
- public IDatabaseContext GetDatabaseContext() => rootServiceProviderContainer.RootServiceProvider.GetRequiredService();
+ public AutomationFrameworkSettings AutomationFrameworkSettings => rootServiceProviderContainer.RootServiceProvider.GetRequiredService>().Value;
+
+ public TimeProvider TimeProvider => rootServiceProviderContainer.RootServiceProvider.GetRequiredService();
- public AutomationFrameworkSettings GetAutomationFrameworkSettings() => rootServiceProviderContainer.RootServiceProvider.GetRequiredService>().Value;
+ public IFinancialYearService FinancialYearService => rootServiceProviderContainer.RootServiceProvider.GetRequiredService();
- public TimeProvider GetTimeProvider() => rootServiceProviderContainer.RootServiceProvider.GetRequiredService();
+ public IDatabaseContext DatabaseContext => rootServiceProviderContainer.RootServiceProvider.GetRequiredService();
public void SetCurrentDateTime(DateTime newDateTime) => rootServiceProviderContainer.RootServiceProvider.GetRequiredService().SetCurrentDateTime(newDateTime);
public TResult EvaluateController(Expression> func)
where TController : ControllerBase =>
- rootServiceProviderContainer.RootServiceProvider.GetDefaultControllerEvaluator().Evaluate(func);
+
+ rootServiceProviderContainer.GetControllerEvaluator().Evaluate(func);
public void EvaluateController(Expression> action)
where TController : ControllerBase =>
- rootServiceProviderContainer.RootServiceProvider.GetDefaultControllerEvaluator().Evaluate(action);
+ rootServiceProviderContainer.GetControllerEvaluator().Evaluate(action);
}
}
diff --git a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/ServiceEnvironment/ControllerEvaluator.cs b/src/AutomationCore/Framework.AutomationCore/ServiceEnvironment/ControllerEvaluator.cs
similarity index 98%
rename from src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/ServiceEnvironment/ControllerEvaluator.cs
rename to src/AutomationCore/Framework.AutomationCore/ServiceEnvironment/ControllerEvaluator.cs
index 76f61dfc8..b1895ff8e 100644
--- a/src/AutomationCore/Framework.AutomationCore.ServiceEnvironment/ServiceEnvironment/ControllerEvaluator.cs
+++ b/src/AutomationCore/Framework.AutomationCore/ServiceEnvironment/ControllerEvaluator.cs
@@ -25,7 +25,7 @@ public void Evaluate(Expression> actionExpr) =>
this.InternalEvaluateAsync