From d3659779ee76cf90df1117fe308f2d379b40aecc Mon Sep 17 00:00:00 2001 From: Loretta Date: Mon, 1 Dec 2025 16:17:57 +0100 Subject: [PATCH 1/6] .Net10, VS2026; StockTaking in progress... --- Libraries/Nop.Core/Nop.Core.csproj | 8 ++++---- Libraries/Nop.Data/Nop.Data.csproj | 2 +- .../Nop.Plugin.ExternalAuth.Facebook.csproj | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Libraries/Nop.Core/Nop.Core.csproj b/Libraries/Nop.Core/Nop.Core.csproj index f3c9b34..4fa9460 100644 --- a/Libraries/Nop.Core/Nop.Core.csproj +++ b/Libraries/Nop.Core/Nop.Core.csproj @@ -19,10 +19,10 @@ - - - - + + + + diff --git a/Libraries/Nop.Data/Nop.Data.csproj b/Libraries/Nop.Data/Nop.Data.csproj index 296705f..6e923c2 100644 --- a/Libraries/Nop.Data/Nop.Data.csproj +++ b/Libraries/Nop.Data/Nop.Data.csproj @@ -19,7 +19,7 @@ - + diff --git a/Plugins/Nop.Plugin.ExternalAuth.Facebook/Nop.Plugin.ExternalAuth.Facebook.csproj b/Plugins/Nop.Plugin.ExternalAuth.Facebook/Nop.Plugin.ExternalAuth.Facebook.csproj index 05bd7f2..2a3d667 100644 --- a/Plugins/Nop.Plugin.ExternalAuth.Facebook/Nop.Plugin.ExternalAuth.Facebook.csproj +++ b/Plugins/Nop.Plugin.ExternalAuth.Facebook/Nop.Plugin.ExternalAuth.Facebook.csproj @@ -58,7 +58,7 @@ - + From 9a3720f05345ba95ea1239dc59a1c1365e7ae78e Mon Sep 17 00:00:00 2001 From: Loretta Date: Wed, 10 Dec 2025 09:47:06 +0100 Subject: [PATCH 2/6] Add FruitBank SANDBOX for isolated SignalR endpoint testing Introduces a new SANDBOX environment with a dedicated web app (`Mango.Sandbox.EndPoints`) for testing SignalR endpoints in isolation from the main application. Adds null plugin manager implementations to avoid plugin dependencies. Includes automated MSTest tests (`Mango.Sandbox.EndPoints.Tests`), a manual SignalR test client, and a PowerShell script for building and running the sandbox. Provides configuration files and health endpoints for robust, independent development and testing of FruitBank SignalR logic. --- FruitBank.sln | 49 +- .../Mango.Sandbox.EndPoints.Tests.csproj | 19 + .../SignalREndpointTests.cs | 218 ++++++ .../Mango.Sandbox.EndPoints.csproj | 144 ++++ .../Mango.Sandbox.EndPoints/Program.cs | 739 ++++++++++++++++++ .../NullAuthenticationPluginManager.cs | 30 + .../Services/NullDiscountPluginManager.cs | 26 + .../Services/NullExchangeRatePluginManager.cs | 31 + .../NullExternalAuthenticationService.cs | 35 + ...lMultiFactorAuthenticationPluginManager.cs | 36 + .../Services/NullPaymentPluginManager.cs | 36 + .../Services/NullPickupPluginManager.cs | 30 + .../Services/NullSearchPluginManager.cs | 33 + .../Services/NullShippingPluginManager.cs | 36 + .../Services/NullTaxPluginManager.cs | 30 + .../Services/NullWidgetPluginManager.cs | 30 + .../appsettings.Development.json | 8 + .../Mango.Sandbox.EndPoints/appsettings.json | 13 + .../Mango.Sandbox.EndPoints/test-sandbox.ps1 | 81 ++ .../Mango.Sandbox.SignalRTestClient.csproj | 11 + .../Program.cs | 48 ++ 21 files changed, 1681 insertions(+), 2 deletions(-) create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/Mango.Sandbox.EndPoints.Tests.csproj create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointTests.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Mango.Sandbox.EndPoints.csproj create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Program.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullAuthenticationPluginManager.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullDiscountPluginManager.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExchangeRatePluginManager.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExternalAuthenticationService.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullMultiFactorAuthenticationPluginManager.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPaymentPluginManager.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPickupPluginManager.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullSearchPluginManager.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullShippingPluginManager.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullTaxPluginManager.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullWidgetPluginManager.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/appsettings.Development.json create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/appsettings.json create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/test-sandbox.ps1 create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Mango.Sandbox.SignalRTestClient.csproj create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Program.cs diff --git a/FruitBank.sln b/FruitBank.sln index 84afd68..4220d61 100644 --- a/FruitBank.sln +++ b/FruitBank.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.32002.185 +# Visual Studio Version 18 +VisualStudioVersion = 18.0.11222.15 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{E4ACA93B-D3DE-4557-B069-F1DB42925A4B}" EndProject @@ -87,6 +87,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nop.Plugin.Misc.MangoCore", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mango.Nop.Data", "..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Data\Mango.Nop.Data.csproj", "{EE44B558-F1DA-433A-BD4C-D275986A4679}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mango.Sandbox.EndPoints", "Tests\Mango.Sandbox\Mango.Sandbox.EndPoints\Mango.Sandbox.EndPoints.csproj", "{D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mango.Sandbox.EndPoints.Tests", "Tests\Mango.Sandbox\Mango.Sandbox.EndPoints.Tests\Mango.Sandbox.EndPoints.Tests.csproj", "{B8491E5C-DBB5-1594-052E-744D78D7A4DE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mango.Sandbox.SignalRTestClient", "Tests\Mango.Sandbox\Mango.Sandbox.SignalRTestClient\Mango.Sandbox.SignalRTestClient.csproj", "{B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -507,6 +513,42 @@ Global {EE44B558-F1DA-433A-BD4C-D275986A4679}.Release|Mixed Platforms.Build.0 = Release|Any CPU {EE44B558-F1DA-433A-BD4C-D275986A4679}.Release|x86.ActiveCfg = Release|Any CPU {EE44B558-F1DA-433A-BD4C-D275986A4679}.Release|x86.Build.0 = Release|Any CPU + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}.Debug|x86.ActiveCfg = Debug|Any CPU + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}.Debug|x86.Build.0 = Debug|Any CPU + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}.Release|Any CPU.Build.0 = Release|Any CPU + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}.Release|x86.ActiveCfg = Release|Any CPU + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C}.Release|x86.Build.0 = Release|Any CPU + {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Debug|x86.ActiveCfg = Debug|Any CPU + {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Debug|x86.Build.0 = Debug|Any CPU + {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Release|Any CPU.Build.0 = Release|Any CPU + {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Release|x86.ActiveCfg = Release|Any CPU + {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Release|x86.Build.0 = Release|Any CPU + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Debug|x86.ActiveCfg = Debug|Any CPU + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Debug|x86.Build.0 = Debug|Any CPU + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Release|Any CPU.Build.0 = Release|Any CPU + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Release|x86.ActiveCfg = Release|Any CPU + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -550,6 +592,9 @@ Global {3E893AC2-29F1-48FC-B33F-F73C6EE2BE90} = {0742FDF3-0F2E-4C64-9521-E58A7FF2ED26} {3976CB1D-8080-4B84-8C01-1F98BFCAF2B3} = {0742FDF3-0F2E-4C64-9521-E58A7FF2ED26} {EE44B558-F1DA-433A-BD4C-D275986A4679} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} + {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C} = {E8FC6874-E230-468A-9685-4747354B92FF} + {B8491E5C-DBB5-1594-052E-744D78D7A4DE} = {E8FC6874-E230-468A-9685-4747354B92FF} + {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F} = {E8FC6874-E230-468A-9685-4747354B92FF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {EE72A8B2-332A-4175-9319-6726D36E9D25} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/Mango.Sandbox.EndPoints.Tests.csproj b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/Mango.Sandbox.EndPoints.Tests.csproj new file mode 100644 index 0000000..0c2b8e2 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/Mango.Sandbox.EndPoints.Tests.csproj @@ -0,0 +1,19 @@ + + + + net9.0 + enable + enable + false + true + + + + + + + + + + + diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointTests.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointTests.cs new file mode 100644 index 0000000..76a7aa6 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointTests.cs @@ -0,0 +1,218 @@ +using Microsoft.AspNetCore.SignalR.Client; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Diagnostics; +using System.Text; +using System.Text.Json; + +namespace Mango.Sandbox.EndPoints.Tests; + +/// +/// SignalR Endpoint tesztek. +/// FONTOS: A SANDBOX-ot manuálisan kell elindítani a tesztek futtatása előtt! +// Indítás: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579 +/// +[TestClass] +public class SignalREndpointTests +{ + private static readonly string SandboxUrl = "http://localhost:59579"; + private static readonly string HubUrl = $"{SandboxUrl}/fbHub"; + + // SignalR Tags from FruitBank.Common.SignalRs.SignalRTags + private const int GetMeasuringUsersTag = 70; + private const int GetStockQuantityHistoryDtosTag = 40; + private const int GetStockQuantityHistoryDtosByProductIdTag = 41; + private const int GetShippingDocumentsByShippingIdTag = 60; + private const int GetOrderDtoByIdTag = 21; + private const int GetStockTakingItemsByIdTag = 81; + + [ClassInitialize] + public static async Task ClassInitialize(TestContext context) + { + using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) }; + try + { + var response = await httpClient.GetAsync($"{SandboxUrl}/health"); + Assert.IsTrue(response.IsSuccessStatusCode, + "SANDBOX is not running! Start it manually: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579"); + } + catch (Exception ex) + { + Assert.Fail($"SANDBOX is not running! Error: {ex.Message}\n" + + "Start it manually: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579"); + } + } + + #region HTTP Endpoint Tests + + [TestMethod] + public async Task HealthEndpoint_ReturnsSuccess() + { + using var httpClient = new HttpClient(); + var response = await httpClient.GetAsync($"{SandboxUrl}/health"); + Assert.IsTrue(response.IsSuccessStatusCode, $"Health endpoint returned {response.StatusCode}"); + } + + [TestMethod] + public async Task RootEndpoint_ReturnsSandboxIsRunning() + { + using var httpClient = new HttpClient(); + var response = await httpClient.GetStringAsync(SandboxUrl); + Assert.AreEqual("SANDBOX is running!", response); + } + + #endregion + + #region SignalR Connection Tests + + [TestMethod] + public async Task SignalR_Negotiate_ReturnsSuccess() + { + using var httpClient = new HttpClient(); + var response = await httpClient.PostAsync($"{HubUrl}/negotiate?negotiateVersion=1", null); + Assert.IsTrue(response.IsSuccessStatusCode, $"SignalR negotiate returned {response.StatusCode}"); + } + + [TestMethod] + public async Task SignalR_Connect_Succeeds() + { + var connection = new HubConnectionBuilder() + .WithUrl(HubUrl) + .Build(); + + try + { + await connection.StartAsync(); + Assert.AreEqual(HubConnectionState.Connected, connection.State); + } + finally + { + await connection.StopAsync(); + } + } + + #endregion + + #region SignalR Business Endpoint Tests + + [TestMethod] + public async Task SignalR_GetMeasuringUsers_ReturnsJson() + { + await TestSignalREndpoint(GetMeasuringUsersTag, null, "GetMeasuringUsers"); + } + + [TestMethod] + public async Task SignalR_GetStockQuantityHistoryDtos_ReturnsJson() + { + await TestSignalREndpoint(GetStockQuantityHistoryDtosTag, null, "GetStockQuantityHistoryDtos"); + } + + [TestMethod] + public async Task SignalR_GetStockQuantityHistoryDtosByProductId_ReturnsJson() + { + // ProductId = 10 + await TestSignalREndpoint(GetStockQuantityHistoryDtosByProductIdTag, 10, "GetStockQuantityHistoryDtosByProductId"); + } + + [TestMethod] + public async Task SignalR_GetShippingDocumentsByShippingId_ReturnsJson() + { + // ShippingId = 5 + await TestSignalREndpoint(GetShippingDocumentsByShippingIdTag, 5, "GetShippingDocumentsByShippingId"); + } + + [TestMethod] + public async Task SignalR_GetOrderDtoById_ReturnsJson() + { + // OrderId = 15 + await TestSignalREndpoint(GetOrderDtoByIdTag, 15, "GetOrderDtoById"); + } + + [TestMethod] + public async Task SignalR_GetStockTakingItemsById_ReturnsJson() + { + // StockTakingItemId = 200 + await TestSignalREndpoint(GetStockTakingItemsByIdTag, 200, "GetStockTakingItemsById"); + } + + #endregion + + #region Helper Methods + + private async Task TestSignalREndpoint(int tag, object? parameter, string endpointName) + { + var connection = new HubConnectionBuilder() + .WithUrl(HubUrl) + .Build(); + + string? receivedJson = null; + int receivedTag = -1; + var responseReceived = new TaskCompletionSource(); + + connection.On("ReceiveMessage", (responseTag, data) => + { + receivedTag = responseTag; + if (data != null && data.Length > 0) + { + receivedJson = Encoding.UTF8.GetString(data); + } + responseReceived.TrySetResult(true); + }); + + try + { + await connection.StartAsync(); + Assert.AreEqual(HubConnectionState.Connected, connection.State, $"Failed to connect to SignalR hub for {endpointName}"); + + // Készítsük el a request data-t + byte[] requestData = parameter != null + ? Encoding.UTF8.GetBytes(JsonSerializer.Serialize(parameter)) + : Array.Empty(); + + await connection.InvokeAsync("ReceiveMessage", tag, requestData); + + var completed = await Task.WhenAny(responseReceived.Task, Task.Delay(15000)); + + if (completed == responseReceived.Task) + { + Console.WriteLine($"[{endpointName}] Response tag: {receivedTag}"); + Console.WriteLine($"[{endpointName}] Response JSON: {receivedJson?.Substring(0, Math.Min(500, receivedJson?.Length ?? 0))}..."); + + // Ellenőrizzük, hogy valid JSON-e (ha van adat) + if (!string.IsNullOrEmpty(receivedJson)) + { + try + { + var jsonDoc = JsonDocument.Parse(receivedJson); + Assert.IsTrue( + jsonDoc.RootElement.ValueKind == JsonValueKind.Array || + jsonDoc.RootElement.ValueKind == JsonValueKind.Object || + jsonDoc.RootElement.ValueKind == JsonValueKind.Null, + $"[{endpointName}] Response is not a valid JSON"); + } + catch (JsonException ex) + { + Assert.Fail($"[{endpointName}] Invalid JSON response: {ex.Message}"); + } + } + } + else + { + Assert.AreEqual(HubConnectionState.Connected, connection.State, + $"[{endpointName}] Connection was closed - check SANDBOX logs for DI errors"); + } + } + catch (Exception ex) + { + Assert.Fail($"[{endpointName}] SignalR error: {ex.Message}. Check SANDBOX logs for missing DI registrations."); + } + finally + { + if (connection.State == HubConnectionState.Connected) + { + await connection.StopAsync(); + } + } + } + + #endregion +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Mango.Sandbox.EndPoints.csproj b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Mango.Sandbox.EndPoints.csproj new file mode 100644 index 0000000..7337993 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Mango.Sandbox.EndPoints.csproj @@ -0,0 +1,144 @@ + + + + net9.0 + enable + enable + + false + + $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\..\..\..'))\ + $([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\..\..\..\..'))\ + $(FruitBankRoot)Presentation\Nop.Web\Plugins\Misc.FruitBankPlugin\ + $(SourceRoot)FruitBankHybridApp\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(PluginOutputDir)Nop.Plugin.Misc.FruitBankPlugin.dll + + + $(PluginOutputDir)Mango.Nop.Core.dll + + + $(PluginOutputDir)Mango.Nop.Services.dll + + + + + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Core.dll + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Core.Server.dll + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Database.dll + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Entities.dll + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Entities.Server.dll + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Interfaces.dll + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Interfaces.Server.dll + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Models.Server.dll + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Services.dll + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Services.Server.dll + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Utils.dll + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\FruitBank.Common.dll + + + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\FruitBank.Common.Server.dll + + + + diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Program.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Program.cs new file mode 100644 index 0000000..c674ff9 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Program.cs @@ -0,0 +1,739 @@ +using AyCode.Core.Loggers; +using FluentValidation; +using FluentValidation.AspNetCore; +using FruitBank.Common; +using FruitBank.Common.Interfaces; +using FruitBank.Common.Server.Interfaces; +using FruitBank.Common.Server.Services.Loggers; +using FruitBank.Common.Server.Services.SignalRs; +using Mango.Nop.Services; +using Mango.Nop.Services.Loggers; +using Mango.Sandbox.EndPoints.Services; +using Microsoft.AspNetCore.Http.Connections; +using Microsoft.AspNetCore.Mvc.Infrastructure; +using Nop.Core; +using Nop.Core.Caching; +using Nop.Core.Configuration; +using Nop.Core.Domain; +using Nop.Core.Domain.Blogs; +using Nop.Core.Domain.Catalog; +using Nop.Core.Domain.Common; +using Nop.Core.Domain.Customers; +using Nop.Core.Domain.Directory; +using Nop.Core.Domain.Forums; +using Nop.Core.Domain.Gdpr; +using Nop.Core.Domain.Localization; +using Nop.Core.Domain.Media; +using Nop.Core.Domain.Messages; +using Nop.Core.Domain.News; +using Nop.Core.Domain.Orders; +using Nop.Core.Domain.Payments; +using Nop.Core.Domain.Security; +using Nop.Core.Domain.Seo; +using Nop.Core.Domain.Shipping; +using Nop.Core.Domain.Stores; +using Nop.Core.Domain.Tax; +using Nop.Core.Domain.Vendors; +using Nop.Core.Events; +using Nop.Core.Http; +using Nop.Core.Infrastructure; +using Nop.Core.Security; +using Nop.Data; +using Nop.Data.DataProviders; +using Nop.Data.Mapping; +using Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers; +using Nop.Plugin.Misc.FruitBankPlugin.Controllers; +using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer; +using Nop.Plugin.Misc.FruitBankPlugin.Factories; +using Nop.Plugin.Misc.FruitBankPlugin.Mapping; +using Nop.Plugin.Misc.FruitBankPlugin.Services; +using Nop.Services.Affiliates; +using Nop.Services.Attributes; +using Nop.Services.Authentication; +using Nop.Services.Authentication.External; +using Nop.Services.Authentication.MultiFactor; +using Nop.Services.Blogs; +using Nop.Services.Caching; +using Nop.Services.Catalog; +using Nop.Services.Cms; +using Nop.Services.Common; +using Nop.Services.Configuration; +using Nop.Services.Customers; +using Nop.Services.Directory; +using Nop.Services.Discounts; +using Nop.Services.Events; +using Nop.Services.ExportImport; +using Nop.Services.Forums; +using Nop.Services.Gdpr; +using Nop.Services.Helpers; +using Nop.Services.Html; +using Nop.Services.Installation; +using Nop.Services.Localization; +using Nop.Services.Logging; +using Nop.Services.Media; +using Nop.Services.Media.RoxyFileman; +using Nop.Services.Messages; +using Nop.Services.News; +using Nop.Services.Orders; +using Nop.Services.Payments; +using Nop.Services.Plugins; +using Nop.Services.Plugins.Marketplace; +using Nop.Services.Polls; +using Nop.Services.ScheduleTasks; +using Nop.Services.Security; +using Nop.Services.Seo; +using Nop.Services.Shipping; +using Nop.Services.Shipping.Date; +using Nop.Services.Shipping.Pickup; +using Nop.Services.Stores; +using Nop.Services.Tax; +using Nop.Services.Themes; +using Nop.Services.Topics; +using Nop.Services.Vendors; +using Nop.Web.Areas.Admin.Factories; +using Nop.Web.Areas.Admin.Helpers; +using Nop.Web.Framework; +using Nop.Web.Framework.Factories; +using Nop.Web.Framework.Infrastructure; +using Nop.Web.Framework.Menu; +using Nop.Web.Framework.Mvc.Routing; +using Nop.Web.Framework.Themes; +using Nop.Web.Framework.UI; +using Nop.Web.Infrastructure.Installation; +using System.Net.Http.Headers; + +var builder = WebApplication.CreateBuilder(args); + +// =========================================== +// === KONFIGURÁCIÓ === +// =========================================== + +var prodAppSettingsPath = Path.GetFullPath(Path.Combine( + builder.Environment.ContentRootPath, + "..", "..", "..", + "Presentation", "Nop.Web", "App_Data", "appsettings.json")); + +if (File.Exists(prodAppSettingsPath)) +{ + builder.Configuration.AddJsonFile(prodAppSettingsPath, optional: false, reloadOnChange: true); + Console.WriteLine($"[SANDBOX] PROD config loaded: {prodAppSettingsPath}"); +} +else +{ + Console.WriteLine($"[SANDBOX] WARNING: PROD appsettings.json not found at: {prodAppSettingsPath}"); +} + +builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); +Console.WriteLine("[SANDBOX] SANDBOX config overrides applied"); + +// =========================================== +// === NAME COMPATIBILITY - LinqToDB tábla mapping === +// =========================================== + +NameCompatibilityManager.AdditionalNameCompatibilities.Add(typeof(NameCompatibility)); +Console.WriteLine("[SANDBOX] FruitBank NameCompatibility registered for LinqToDB table mapping"); + +// =========================================== +// === FILE PROVIDER (STATIC) === +// =========================================== + +CommonHelper.DefaultFileProvider = new NopFileProvider(builder.Environment); + +// =========================================== +// === TYPE FINDER === +// =========================================== + +var typeFinder = new WebAppTypeFinder(); +Singleton.Instance = typeFinder; +builder.Services.AddSingleton(typeFinder); +Console.WriteLine("[SANDBOX] TypeFinder registered"); + +// =========================================== +// === ENGINE === +// =========================================== + +var engine = new NopEngine(); +Singleton.Instance = engine; +builder.Services.AddSingleton(engine); +Console.WriteLine("[SANDBOX] NopEngine registered"); + +// =========================================== +// === CORS === +// =========================================== + +builder.Services.AddCors(options => +{ + options.AddDefaultPolicy(policy => + { + policy.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); + }); + + options.AddPolicy("SignalR", policy => + { + policy.SetIsOriginAllowed(_ => true).AllowAnyMethod().AllowAnyHeader().AllowCredentials(); + }); +}); + +// =========================================== +// === DI VALIDÁCIÓ KIKAPCSOLÁSA === +// =========================================== + +builder.Host.UseDefaultServiceProvider(options => +{ + options.ValidateScopes = false; + options.ValidateOnBuild = false; +}); + +// =========================================== +// === MVC INFRASTRUKTÚRA === +// =========================================== + +builder.Services.AddControllersWithViews(); +builder.Services.AddRazorPages(); +builder.Services.AddSession(); + +// =========================================== +// === ALAPVETŐ INFRASTRUKTÚRA === +// =========================================== + +builder.Services.AddHttpContextAccessor(); +builder.Services.AddSingleton(); +builder.Services.AddMemoryCache(); + +// =========================================== +// === APP SETTINGS === +// =========================================== + +var appSettings = new AppSettings(); +builder.Configuration.Bind(appSettings); +builder.Services.AddSingleton(appSettings); +Singleton.Instance = appSettings; + +// =========================================== +// === FILE PROVIDER (DI) === +// =========================================== + +builder.Services.AddScoped(); + +// =========================================== +// === ADATBÁZIS ÉS REPOSITORY === +// =========================================== + +builder.Services.AddScoped(); +builder.Services.AddScoped(typeof(IRepository<>), typeof(EntityRepository<>)); + +// =========================================== +// === CACHE SZOLGÁLTATÁSOK === +// =========================================== + +builder.Services.AddTransient(typeof(IConcurrentCollection<>), typeof(ConcurrentTrie<>)); +builder.Services.AddSingleton(); +builder.Services.AddScoped(); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); +builder.Services.AddScoped(); + +// =========================================== +// === EVENT PUBLISHER === +// =========================================== + +builder.Services.AddSingleton(); + +// =========================================== +// === LAZY WRAPPERS === +// =========================================== + +builder.Services.AddScoped(typeof(Lazy<>), typeof(LazyInstance<>)); + +// =========================================== +// === NOP SETTINGS (Domain Settings) - DINAMIKUS REGISZTRÁCIÓ === +// =========================================== + +// Alapvető Settings-ek fix értékekkel (amik a SANDBOX működéséhez szükségesek) +builder.Services.AddScoped(sp => new CookieSettings()); +builder.Services.AddScoped(sp => new CurrencySettings { PrimaryStoreCurrencyId = 1 }); +builder.Services.AddScoped(sp => new LocalizationSettings { DefaultAdminLanguageId = 1, AutomaticallyDetectLanguage = false }); +builder.Services.AddScoped(sp => new TaxSettings { TaxDisplayType = TaxDisplayType.IncludingTax }); +builder.Services.AddScoped(sp => new CatalogSettings()); +builder.Services.AddScoped(sp => new OrderSettings()); +builder.Services.AddScoped(sp => new ShippingSettings()); +builder.Services.AddScoped(sp => new RewardPointsSettings()); +builder.Services.AddScoped(sp => new CustomerSettings()); +builder.Services.AddScoped(sp => new CommonSettings()); +builder.Services.AddScoped(sp => new ShoppingCartSettings()); +builder.Services.AddScoped(sp => new MediaSettings()); +builder.Services.AddScoped(sp => new StoreInformationSettings()); +builder.Services.AddScoped(sp => new SeoSettings()); +builder.Services.AddScoped(sp => new SecuritySettings()); +builder.Services.AddScoped(sp => new AdminAreaSettings()); +builder.Services.AddScoped(sp => new EmailAccountSettings()); +builder.Services.AddScoped(sp => new MessagesSettings()); +builder.Services.AddScoped(sp => new ExternalAuthenticationSettings()); +builder.Services.AddScoped(sp => new VendorSettings()); +builder.Services.AddScoped(sp => new BlogSettings()); +builder.Services.AddScoped(sp => new NewsSettings()); +builder.Services.AddScoped(sp => new ForumSettings()); +builder.Services.AddScoped(sp => new GdprSettings()); +builder.Services.AddScoped(sp => new PaymentSettings()); +builder.Services.AddScoped(sp => new AddressSettings()); +builder.Services.AddScoped(sp => new DateTimeSettings()); +builder.Services.AddScoped(sp => new CaptchaSettings()); +builder.Services.AddScoped(sp => new DisplayDefaultMenuItemSettings()); +builder.Services.AddScoped(sp => new DisplayDefaultFooterItemSettings()); +builder.Services.AddScoped(sp => new PdfSettings()); +builder.Services.AddScoped(sp => new RobotsTxtSettings()); +builder.Services.AddScoped(sp => new SitemapSettings()); +builder.Services.AddScoped(sp => new SitemapXmlSettings()); +builder.Services.AddScoped(sp => new MeasureSettings()); +builder.Services.AddScoped(sp => new MultiFactorAuthenticationSettings()); +builder.Services.AddScoped(sp => new ProxySettings()); + +// További Settings-ek (Nop.Core.Domain namespace-ekből) +builder.Services.AddScoped(sp => new Nop.Core.Domain.Catalog.ProductEditorSettings()); +builder.Services.AddScoped(sp => new Nop.Core.Domain.Messages.MessageTemplatesSettings()); + +// =========================================== +// === NOP CORE SZOLGÁLTATÁSOK === +// =========================================== + +// Web & Utils +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Context +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Plugins +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Settings & Config +builder.Services.AddScoped(); + +// Security & Permission +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Authentication +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Store +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Localization +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Currency & Directory +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Customer +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Address & Vendor & Affiliate +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Generic Attribute +builder.Services.AddScoped(); + +// Maintenance +builder.Services.AddScoped(); + +// Catalog +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Pricing (CustomPriceCalculationService a FruitBank-ból) +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Search +builder.Services.AddScoped(); + +// Orders +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Shipping +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Tax +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Payment +builder.Services.AddScoped(); + +// Discounts +builder.Services.AddScoped(); + +// Media +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Messages & Notifications +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// SEO & HTML +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Logging +builder.Services.AddScoped(); + +// Topics & Content +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// GDPR +builder.Services.AddScoped(); + +// Export/Import +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Themes +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Schedule Tasks +builder.Services.AddSingleton(); +builder.Services.AddTransient(); +builder.Services.AddScoped(); + +// Installation +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Slug Route Transformer (ha van adatbázis) +builder.Services.AddScoped(); + +// Routing +builder.Services.AddSingleton(); + +// Roxy File Manager +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Web Framework +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// Attribute Services (generic) +builder.Services.AddScoped(typeof(IAttributeService<,>), typeof(AttributeService<,>)); +builder.Services.AddScoped(typeof(IAttributeParser<,>), typeof(Nop.Services.Attributes.AttributeParser<,>)); +builder.Services.AddScoped(typeof(IAttributeFormatter<,>), typeof(AttributeFormatter<,>)); + +// Plugin Managers (generic) +builder.Services.AddScoped(typeof(IPluginManager<>), typeof(PluginManager<>)); + +// =========================================== +// === PLUGIN MANAGEREK (Null implementációk) === +// =========================================== + +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// =========================================== +// === NOP.WEB COMMON FACTORIES (Nop.Web\Infrastructure\NopStartup.cs) === +// =========================================== + +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// =========================================== +// === NOP.WEB ADMIN MODEL FACTORIES (Nop.Web\Infrastructure\NopStartup.cs) === +// =========================================== + +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +// IOrderModelFactory - FruitBank CustomOrderModelFactory felülírja! +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +// IProductModelFactory - FruitBank CustomProductModelFactory felülírja! +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// =========================================== +// === NOP.WEB PUBLIC FACTORIES (Nop.Web\Infrastructure\NopStartup.cs) === +// =========================================== + +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// =========================================== +// === NOP.WEB HELPERS === +// =========================================== + +builder.Services.AddScoped(); + +// =========================================== +// === FRUITBANK PLUGIN SZOLGÁLTATÁSOK (PluginNopStartup-ból) === +// ===========================================; + +// Logger +builder.Services.AddScoped(); +builder.Services.AddTransient(); +builder.Services.AddScoped(); +builder.Services.AddSingleton(); + +// Core +builder.Services.AddSingleton(); +builder.Services.AddScoped(); + +// Event Consumer +builder.Services.AddScoped, EventConsumer>(); + +// Business Services +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// ReplicateService with HttpClient +builder.Services.AddScoped(); +builder.Services.AddHttpClient(client => +{ + client.DefaultRequestHeaders.Authorization = + new AuthenticationHeaderValue("Bearer", "r8_MUApXYIE5mRjxqy20tsGLehWBJkCzNj0Cwvrh"); +}); + +// DbTable Services +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// DbContext Services +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// SignalR Services +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +// =========================================== +// === SIGNALR KONFIGURÁCIÓ === +// =========================================== + +builder.Services.AddSignalR(hubOptions => +{ + hubOptions.EnableDetailedErrors = true; + hubOptions.MaximumReceiveMessageSize = 30_000_000; + hubOptions.KeepAliveInterval = TimeSpan.FromSeconds(FruitBankConstClient.SignalRKeepAliveIntervalSecond); + hubOptions.ClientTimeoutInterval = TimeSpan.FromSeconds(FruitBankConstClient.SignarlRTimeoutIntervalSecond); + hubOptions.StatefulReconnectBufferSize = 30_000_000; +}); + +// =========================================== +// === APP BUILD === +// =========================================== + +var app = builder.Build(); + +app.UseCors("SignalR"); +app.UseSession(); + +var fruitBankHubEndPoint = $"/{FruitBankConstClient.DefaultHubName}"; +app.MapHub(fruitBankHubEndPoint, options => +{ + options.Transports = HttpTransportType.WebSockets; + options.WebSockets.CloseTimeout = TimeSpan.FromSeconds(10); + options.AllowStatefulReconnects = true; + options.TransportMaxBufferSize = 30_000_000; + options.ApplicationMaxBufferSize = 30_000_000; + options.TransportSendTimeout = TimeSpan.FromSeconds(60); +}); + +var loggerHubEndPoint = $"/{FruitBankConstClient.LoggerHubName}"; +app.MapHub(loggerHubEndPoint, options => +{ + options.AllowStatefulReconnects = false; +}); + +app.MapGet("/", () => "SANDBOX is running!"); +app.MapGet("/health", () => Results.Ok(new { status = "healthy", timestamp = DateTime.UtcNow })); + +// =========================================== +// === CONSOLE OUTPUT === +// =========================================== + +var finalConnectionString = app.Configuration.GetConnectionString("ConnectionString") ?? ""; +var databaseName = "Unknown"; +if (!string.IsNullOrEmpty(finalConnectionString)) +{ + var match = System.Text.RegularExpressions.Regex.Match(finalConnectionString, @"Initial Catalog=([^;]+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase); + if (match.Success) + { + databaseName = match.Groups[1].Value; + } +} + +Console.Title = $"[SB] - {databaseName}"; + +Console.WriteLine("==========================================="); +Console.WriteLine($" FRUITBANK SANDBOX - {databaseName}"); +Console.WriteLine("==========================================="); +Console.WriteLine($" Database: {databaseName}"); +Console.WriteLine($" Base URL: http://localhost:59579"); +Console.WriteLine($" SignalR Hub: {fruitBankHubEndPoint}"); +Console.WriteLine($" Logger Hub: {loggerHubEndPoint}"); +Console.WriteLine("==========================================="); + +app.Run(); diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullAuthenticationPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullAuthenticationPluginManager.cs new file mode 100644 index 0000000..d65a42e --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullAuthenticationPluginManager.cs @@ -0,0 +1,30 @@ +using Nop.Core.Domain.Customers; +using Nop.Services.Authentication.External; +using Nop.Services.Plugins; + +namespace Mango.Sandbox.EndPoints.Services; + +public class NullAuthenticationPluginManager : IAuthenticationPluginManager +{ + public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public bool IsPluginActive(IExternalAuthenticationMethod plugin, List systemNames) => false; + + public bool IsPluginActive(IExternalAuthenticationMethod plugin) => false; + + public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(false); + + public Task GetPluginLogoUrlAsync(IExternalAuthenticationMethod plugin) + => Task.FromResult(string.Empty); +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullDiscountPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullDiscountPluginManager.cs new file mode 100644 index 0000000..5361a93 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullDiscountPluginManager.cs @@ -0,0 +1,26 @@ +using Nop.Core.Domain.Customers; +using Nop.Core.Domain.Discounts; +using Nop.Services.Discounts; +using Nop.Services.Plugins; + +namespace Mango.Sandbox.EndPoints.Services; + +/// +/// Null implementation of IDiscountPluginManager for SANDBOX +/// +public class NullDiscountPluginManager : IDiscountPluginManager +{ + public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public bool IsPluginActive(IDiscountRequirementRule plugin, List systemNames) => false; + + public Task GetPluginLogoUrlAsync(IDiscountRequirementRule plugin) + => Task.FromResult(string.Empty); +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExchangeRatePluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExchangeRatePluginManager.cs new file mode 100644 index 0000000..b87ed19 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExchangeRatePluginManager.cs @@ -0,0 +1,31 @@ +using Nop.Core.Domain.Customers; +using Nop.Core.Domain.Directory; +using Nop.Services.Directory; +using Nop.Services.Plugins; + +namespace Mango.Sandbox.EndPoints.Services; + +/// +/// Null implementation of IExchangeRatePluginManager for SANDBOX +/// +public class NullExchangeRatePluginManager : IExchangeRatePluginManager +{ + public Task LoadPrimaryPluginAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public bool IsPluginActive(IExchangeRateProvider exchangeRateProvider) => false; + + public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public bool IsPluginActive(IExchangeRateProvider plugin, List systemNames) => false; + + public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task GetPluginLogoUrlAsync(IExchangeRateProvider plugin) + => Task.FromResult(string.Empty); +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExternalAuthenticationService.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExternalAuthenticationService.cs new file mode 100644 index 0000000..5413328 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExternalAuthenticationService.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Mvc; +using Nop.Core.Domain.Customers; +using Nop.Services.Authentication.External; + +namespace Mango.Sandbox.EndPoints.Services; + +/// +/// Null implementation of IExternalAuthenticationService for SANDBOX +/// +public class NullExternalAuthenticationService : IExternalAuthenticationService +{ + public Task AuthenticateAsync(ExternalAuthenticationParameters parameters, string returnUrl = null!) + => Task.FromResult(new NotFoundResult()); + + public Task GetExternalAuthenticationRecordByIdAsync(int externalAuthenticationRecordId) + => Task.FromResult(null); + + public Task> GetCustomerExternalAuthenticationRecordsAsync(Customer customer) + => Task.FromResult>(new List()); + + public Task DeleteExternalAuthenticationRecordAsync(ExternalAuthenticationRecord externalAuthenticationRecord) + => Task.CompletedTask; + + public Task GetExternalAuthenticationRecordByExternalAuthenticationParametersAsync(ExternalAuthenticationParameters parameters) + => Task.FromResult(null); + + public Task AssociateExternalAccountWithUserAsync(Customer customer, ExternalAuthenticationParameters parameters) + => Task.CompletedTask; + + public Task GetUserByExternalAuthenticationParametersAsync(ExternalAuthenticationParameters parameters) + => Task.FromResult(null); + + public Task RemoveAssociationAsync(ExternalAuthenticationParameters parameters) + => Task.CompletedTask; +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullMultiFactorAuthenticationPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullMultiFactorAuthenticationPluginManager.cs new file mode 100644 index 0000000..ed080be --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullMultiFactorAuthenticationPluginManager.cs @@ -0,0 +1,36 @@ +using Nop.Core.Domain.Customers; +using Nop.Services.Authentication.MultiFactor; +using Nop.Services.Plugins; + +namespace Mango.Sandbox.EndPoints.Services; + +/// +/// Null implementation of IMultiFactorAuthenticationPluginManager for SANDBOX +/// +public class NullMultiFactorAuthenticationPluginManager : IMultiFactorAuthenticationPluginManager +{ + public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task HasActivePluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult(false); + + public bool IsPluginActive(IMultiFactorAuthenticationMethod plugin) => false; + + public bool IsPluginActive(IMultiFactorAuthenticationMethod plugin, List systemNames) => false; + + public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(false); + + public Task GetPluginLogoUrlAsync(IMultiFactorAuthenticationMethod plugin) + => Task.FromResult(string.Empty); +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPaymentPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPaymentPluginManager.cs new file mode 100644 index 0000000..23db962 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPaymentPluginManager.cs @@ -0,0 +1,36 @@ +using Nop.Core.Domain.Customers; +using Nop.Services.Payments; +using Nop.Services.Plugins; + +namespace Mango.Sandbox.EndPoints.Services; + +public class NullPaymentPluginManager : IPaymentPluginManager +{ + public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, int filterByCountryId = 0) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public bool IsPluginActive(IPaymentMethod plugin, List systemNames) => false; + + public bool IsPluginActive(IPaymentMethod plugin) => false; + + public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(false); + + public Task GetPluginLogoUrlAsync(IPaymentMethod plugin) + => Task.FromResult(string.Empty); + + public Task> GetRestrictedCountryIdsAsync(IPaymentMethod paymentMethod) + => Task.FromResult>(new List()); + + public Task SaveRestrictedCountriesAsync(IPaymentMethod paymentMethod, IList countryIds) + => Task.CompletedTask; +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPickupPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPickupPluginManager.cs new file mode 100644 index 0000000..6e375ad --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPickupPluginManager.cs @@ -0,0 +1,30 @@ +using Nop.Core.Domain.Customers; +using Nop.Services.Plugins; +using Nop.Services.Shipping.Pickup; + +namespace Mango.Sandbox.EndPoints.Services; + +public class NullPickupPluginManager : IPickupPluginManager +{ + public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, string filterByCountryId = null!) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public bool IsPluginActive(IPickupPointProvider plugin, List systemNames) => false; + + public bool IsPluginActive(IPickupPointProvider plugin) => false; + + public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(false); + + public Task GetPluginLogoUrlAsync(IPickupPointProvider plugin) + => Task.FromResult(string.Empty); +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullSearchPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullSearchPluginManager.cs new file mode 100644 index 0000000..d9c496b --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullSearchPluginManager.cs @@ -0,0 +1,33 @@ +using Nop.Core.Domain.Customers; +using Nop.Services.Catalog; +using Nop.Services.Plugins; + +namespace Mango.Sandbox.EndPoints.Services; + +/// +/// Null implementation of ISearchPluginManager for SANDBOX +/// +public class NullSearchPluginManager : ISearchPluginManager +{ + public Task LoadPrimaryPluginAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public bool IsPluginActive(ISearchProvider searchProvider) => false; + + public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(false); + + public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public bool IsPluginActive(ISearchProvider plugin, List systemNames) => false; + + public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task GetPluginLogoUrlAsync(ISearchProvider plugin) + => Task.FromResult(string.Empty); +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullShippingPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullShippingPluginManager.cs new file mode 100644 index 0000000..d2980f5 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullShippingPluginManager.cs @@ -0,0 +1,36 @@ +using Nop.Core.Domain.Customers; +using Nop.Services.Plugins; +using Nop.Services.Shipping; + +namespace Mango.Sandbox.EndPoints.Services; + +public class NullShippingPluginManager : IShippingPluginManager +{ + public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, string filterByCountryId = null!) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public bool IsPluginActive(IShippingRateComputationMethod plugin, List systemNames) => false; + + public bool IsPluginActive(IShippingRateComputationMethod plugin) => false; + + public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(false); + + public Task GetPluginLogoUrlAsync(IShippingRateComputationMethod plugin) + => Task.FromResult(string.Empty); + + public Task> GetRestrictedCountryIdsAsync(IShippingRateComputationMethod shippingMethod) + => Task.FromResult>(new List()); + + public Task SaveRestrictedCountriesAsync(IShippingRateComputationMethod shippingMethod, IList countryIds) + => Task.CompletedTask; +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullTaxPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullTaxPluginManager.cs new file mode 100644 index 0000000..f105bec --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullTaxPluginManager.cs @@ -0,0 +1,30 @@ +using Nop.Core.Domain.Customers; +using Nop.Services.Plugins; +using Nop.Services.Tax; + +namespace Mango.Sandbox.EndPoints.Services; + +public class NullTaxPluginManager : ITaxPluginManager +{ + public Task LoadPrimaryPluginAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public bool IsPluginActive(ITaxProvider plugin, List systemNames) => false; + + public bool IsPluginActive(ITaxProvider plugin) => false; + + public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(false); + + public Task GetPluginLogoUrlAsync(ITaxProvider plugin) + => Task.FromResult(string.Empty); +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullWidgetPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullWidgetPluginManager.cs new file mode 100644 index 0000000..c687b92 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullWidgetPluginManager.cs @@ -0,0 +1,30 @@ +using Nop.Core.Domain.Customers; +using Nop.Services.Cms; +using Nop.Services.Plugins; + +namespace Mango.Sandbox.EndPoints.Services; + +public class NullWidgetPluginManager : IWidgetPluginManager +{ + public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, string widgetZone = null!) + => Task.FromResult>(new List()); + + public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(null); + + public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) + => Task.FromResult>(new List()); + + public bool IsPluginActive(IWidgetPlugin plugin, List systemNames) => false; + + public bool IsPluginActive(IWidgetPlugin plugin) => false; + + public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) + => Task.FromResult(false); + + public Task GetPluginLogoUrlAsync(IWidgetPlugin plugin) + => Task.FromResult(string.Empty); +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/appsettings.Development.json b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/appsettings.json b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/appsettings.json new file mode 100644 index 0000000..0032257 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/appsettings.json @@ -0,0 +1,13 @@ +{ + "ConnectionStrings": { + "ConnectionString": "Data Source=195.26.231.218;Initial Catalog=FruitBank_DEV;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=v6f_?xNfg9N1;Trust Server Certificate=True" + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.SignalR": "Debug" + } + }, + "AllowedHosts": "*" +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/test-sandbox.ps1 b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/test-sandbox.ps1 new file mode 100644 index 0000000..a8e0f3b --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/test-sandbox.ps1 @@ -0,0 +1,81 @@ +# SANDBOX Tesztelő Script +# Futtatás: .\test-sandbox.ps1 + +$ErrorActionPreference = "Continue" +$projectPath = $PSScriptRoot +$url = "http://localhost:59579" + +Write-Host "=== SANDBOX TESZTELŐ ===" -ForegroundColor Cyan + +# 1. Build +Write-Host "`n[1/5] Building..." -ForegroundColor Yellow +$buildResult = dotnet build $projectPath --verbosity quiet 2>&1 +if ($LASTEXITCODE -ne 0) { + Write-Host "BUILD FAILED!" -ForegroundColor Red + $buildResult | Where-Object { $_ -match "error" } | ForEach-Object { Write-Host $_ -ForegroundColor Red } + exit 1 +} +Write-Host "Build OK" -ForegroundColor Green + +# 2. Ellenőrizzük, fut-e már +$existingProcess = Get-Process -Name "Mango.Sandbox.EndPoints" -ErrorAction SilentlyContinue +if ($existingProcess) { + Write-Host "`n[2/5] Stopping existing SANDBOX..." -ForegroundColor Yellow + Stop-Process -Name "Mango.Sandbox.EndPoints" -Force + Start-Sleep -Seconds 2 +} + +# 3. Indítás háttérben +Write-Host "`n[3/5] Starting SANDBOX..." -ForegroundColor Yellow +$process = Start-Process -FilePath "dotnet" -ArgumentList "run", "--project", $projectPath, "--urls", $url -PassThru -RedirectStandardOutput "$projectPath\sandbox-stdout.log" -RedirectStandardError "$projectPath\sandbox-stderr.log" +Start-Sleep -Seconds 10 + +# 4. Health check +Write-Host "`n[4/5] Testing endpoints..." -ForegroundColor Yellow + +try { + $response = Invoke-WebRequest -Uri "$url/" -UseBasicParsing -TimeoutSec 5 + if ($response.StatusCode -eq 200) { + Write-Host " / endpoint: OK" -ForegroundColor Green + } +} catch { + Write-Host " / endpoint: FAILED - $_" -ForegroundColor Red +} + +try { + $response = Invoke-WebRequest -Uri "$url/health" -UseBasicParsing -TimeoutSec 5 + if ($response.StatusCode -eq 200) { + Write-Host " /health endpoint: OK" -ForegroundColor Green + } +} catch { + Write-Host " /health endpoint: FAILED - $_" -ForegroundColor Red +} + +# SignalR negotiate teszt +try { + $response = Invoke-WebRequest -Uri "$url/fbHub/negotiate?negotiateVersion=1" -Method POST -UseBasicParsing -TimeoutSec 5 + Write-Host " SignalR negotiate: OK" -ForegroundColor Green +} catch { + Write-Host " SignalR negotiate: FAILED - $_" -ForegroundColor Red +} + +# 5. SignalR Hub hívás teszt (GetMeasuringUsers - tag 70) +Write-Host "`n[5/5] Testing SignalR Hub method..." -ForegroundColor Yellow +Write-Host " GetMeasuringUsers (tag 70) - Check SANDBOX console for logs" -ForegroundColor Gray + +# Hibák kiírása +Write-Host "`n=== STDERR LOG (last 50 lines) ===" -ForegroundColor Cyan +if (Test-Path "$projectPath\sandbox-stderr.log") { + Get-Content "$projectPath\sandbox-stderr.log" -Tail 50 | ForEach-Object { + if ($_ -match "error|fail|exception") { + Write-Host $_ -ForegroundColor Red + } elseif ($_ -match "warn") { + Write-Host $_ -ForegroundColor Yellow + } else { + Write-Host $_ -ForegroundColor Gray + } + } +} + +Write-Host "`n=== SANDBOX PID: $($process.Id) ===" -ForegroundColor Cyan +Write-Host "Leállítás: Stop-Process -Id $($process.Id)" -ForegroundColor Gray diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Mango.Sandbox.SignalRTestClient.csproj b/Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Mango.Sandbox.SignalRTestClient.csproj new file mode 100644 index 0000000..bd8e06d --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Mango.Sandbox.SignalRTestClient.csproj @@ -0,0 +1,11 @@ + + + Exe + net9.0 + enable + enable + + + + + diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Program.cs b/Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Program.cs new file mode 100644 index 0000000..a0dcd51 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Program.cs @@ -0,0 +1,48 @@ +// SignalR Test Client - teszteli a SANDBOX kapcsolatot +using Microsoft.AspNetCore.SignalR.Client; +using System.Text.Json; + +Console.WriteLine("=== SANDBOX SignalR Test Client ==="); + +var hubUrl = "http://localhost:59579/fbHub"; +Console.WriteLine($"Connecting to: {hubUrl}"); + +var connection = new HubConnectionBuilder() + .WithUrl(hubUrl) + .WithAutomaticReconnect() + .Build(); + +connection.On("ReceiveMessage", (tag, data) => +{ + Console.WriteLine($"Received message - Tag: {tag}, Data length: {data?.Length ?? 0}"); +}); + +try +{ + await connection.StartAsync(); + Console.WriteLine($"Connected! State: {connection.State}"); + + // Teszt: GetMeasuringUsers (tag 70) hívása + Console.WriteLine("\nTesting GetMeasuringUsers (tag 70)..."); + + // A SignalR metódus hívása - a szerver "ReceiveMessage" metódusát hívjuk + // MessagePack formátumban küldjük az adatot + var requestData = new { Tag = 70, Data = Array.Empty() }; + + await connection.InvokeAsync("ReceiveMessage", 70, Array.Empty()); + + Console.WriteLine("Message sent! Waiting for response..."); + await Task.Delay(3000); + + Console.WriteLine("\nTest completed!"); +} +catch (Exception ex) +{ + Console.WriteLine($"Error: {ex.Message}"); + Console.WriteLine($"Stack: {ex.StackTrace}"); +} +finally +{ + await connection.StopAsync(); + Console.WriteLine("Disconnected."); +} From c8fa8d1c4cfc56ec1ccbf5d0216a1c14a592b748 Mon Sep 17 00:00:00 2001 From: Loretta Date: Thu, 11 Dec 2025 23:46:35 +0100 Subject: [PATCH 3/6] Minimal SignalR test hub and endpoint for isolated testing Refactored Mango.Sandbox.EndPoints to enable minimal, dependency-light SignalR endpoint testing. Introduced DevAdminSignalRHubSandbox and TestSignalREndpoint for protocol/contract tests without full NopCommerce/FruitBank infra. Added SignalRClientSandbox and comprehensive MSTest coverage for all parameter types. Simplified Program.cs startup, updated project references, and added minimal logger. Original SignalREndpointTests replaced with focused, low-level and high-level tests. CORS and DTOs updated for compatibility. --- .../Mango.Sandbox.EndPoints.Tests.csproj | 66 +- .../SignalRClientSandbox.cs | 30 + .../SignalRClientToEndpointTest.cs | 457 ++++++++++++ .../SignalREndpointSimpleTests.cs | 210 ++++++ .../SignalREndpointTests.cs | 218 ------ .../SignalREndpointWithNopEnvTests.cs | 218 ++++++ .../DevAdminSignalRHubSandbox.cs | 42 ++ .../Mango.Sandbox.EndPoints/Logger.cs | 40 ++ .../Mango.Sandbox.EndPoints.csproj | 64 +- .../Mango.Sandbox.EndPoints/Program.cs | 651 +----------------- .../TestSignalREndpoint.cs | 587 ++++++++++++++++ .../Mango.Sandbox.EndPoints/appsettings.json | 45 +- 12 files changed, 1732 insertions(+), 896 deletions(-) create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientSandbox.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientToEndpointTest.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointSimpleTests.cs delete mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointTests.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointWithNopEnvTests.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/DevAdminSignalRHubSandbox.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Logger.cs create mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/TestSignalREndpoint.cs diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/Mango.Sandbox.EndPoints.Tests.csproj b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/Mango.Sandbox.EndPoints.Tests.csproj index 0c2b8e2..ce96e04 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/Mango.Sandbox.EndPoints.Tests.csproj +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/Mango.Sandbox.EndPoints.Tests.csproj @@ -1,4 +1,4 @@ - + net9.0 @@ -10,10 +10,74 @@ + + + + + + + + + + ..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Core.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Core.Server.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Core.Tests.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Database.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Database.Tests.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Entities.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Entities.Server.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.Server.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Models.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Models.Server.dll + + + ..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Services.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.Tests.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Services.Tests.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll + + + ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Utils.Server.dll + + + ..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\FruitBank.Common.dll + + + diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientSandbox.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientSandbox.cs new file mode 100644 index 0000000..7b33e03 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientSandbox.cs @@ -0,0 +1,30 @@ +using AyCode.Core.Loggers; +using AyCode.Services.SignalRs; +using Mango.Sandbox.EndPoints; + +namespace Mango.Sandbox.EndPoints.Tests; + +/// +/// SignalR kliens a Sandbox teszteléshez. +/// Az AcSignalRClientBase-ből származik, a GetByIdAsync, GetAllAsync, PostDataAsync, GetAllIntoAsync metódusokat örökli. +/// +public class SignalRClientSandbox : AcSignalRClientBase +{ + public SignalRClientSandbox(string hubUrl) + : base(hubUrl, new Logger()) + { + } + + protected override SignalResponseJsonMessage DeserializeResponseMsgPack(byte[] messageBytes) + { + var responseJsonMessage = base.DeserializeResponseMsgPack(messageBytes); + Console.WriteLine(responseJsonMessage.ResponseDataJson); + return responseJsonMessage; + } + + protected override Task MessageReceived(int messageTag, byte[] messageBytes) + { + Console.WriteLine($"[SignalRClientSandbox] Push message received: tag={messageTag}"); + return Task.CompletedTask; + } +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientToEndpointTest.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientToEndpointTest.cs new file mode 100644 index 0000000..0ba373e --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientToEndpointTest.cs @@ -0,0 +1,457 @@ +using AyCode.Services.SignalRs; +using Mango.Sandbox.EndPoints; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Mango.Sandbox.EndPoints.Tests; + +/// +/// Komplex SignalR tesztek a SignalRClientSandbox használatával. +/// Az AcSignalRClientBase GetByIdAsync, GetAllAsync, PostDataAsync, GetAllIntoAsync metĂłdusait teszteli. +/// FONTOS: A SANDBOX-ot manuálisan kell elindĂ­tani a tesztek futtatása elĹ‘tt! +/// +[TestClass] +public class SignalRClientToEndpointTest +{ + private static readonly string HubUrl = "http://localhost:59579/fbHub"; + private static SignalRClientSandbox _client = null!; + + [ClassInitialize] + public static async Task ClassInitialize(TestContext context) + { + // Sandbox ellenĹ‘rzĂ©s + //using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) }; + //try + //{ + // var response = await httpClient.GetAsync("http://localhost:59579/health"); + // Assert.IsTrue(response.IsSuccessStatusCode, + // "SANDBOX not running! Start: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579"); + //} + //catch (Exception ex) + //{ + // Assert.Fail($"SANDBOX not running! {ex.Message}"); + //} + + _client = new SignalRClientSandbox(HubUrl); + await _client.StartConnection(); + } + + [ClassCleanup] + public static async Task ClassCleanup() + { + if (_client != null) + await _client.StopConnection(); + } + + #region GetAllAsync Tesztek - ParamĂ©ter nĂ©lkĂĽl + + [TestMethod] + public async Task GetAllAsync_NoParams_ReturnsTestItems() + { + // Act - GetAllAsync(tag) + var result = await _client.GetAllAsync>(TestSignalRTags.GetTestItems); + + // Assert + Assert.IsNotNull(result); + Assert.IsTrue(result.Count > 0); + Console.WriteLine($"[GetAllAsync] Received {result.Count} items"); + } + + [TestMethod] + public async Task GetAllAsync_NoParams_Callback_ReturnsTestItems() + { + // Arrange + List? receivedItems = null; + var tcs = new TaskCompletionSource(); + + // Act - GetAllAsync(tag, callback) + await _client.GetAllAsync>(TestSignalRTags.GetTestItems, response => + { + receivedItems = response.ResponseData; + tcs.SetResult(true); + return Task.CompletedTask; + }); + + await Task.WhenAny(tcs.Task, Task.Delay(5000)); + + // Assert + Assert.IsNotNull(receivedItems); + Assert.IsTrue(receivedItems.Count > 0); + } + + [TestMethod] + public async Task GetAllAsync_HandleNoParams_ReturnsOk() + { + // Act - paramĂ©ter nĂ©lkĂĽli metĂłdus + var result = await _client.GetAllAsync(TestSignalRTags.NoParams); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual("OK", result); + } + + #endregion + + #region GetByIdAsync Tesztek - Egyetlen ID + + [TestMethod] + public async Task GetByIdAsync_SingleInt_ReturnsFormattedString() + { + // Act - GetByIdAsync(tag, id) + var result = await _client.GetByIdAsync(TestSignalRTags.SingleIntParam, 42); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual("Received: 42", result); + } + + [TestMethod] + public async Task GetByIdAsync_String_ReturnsEcho() + { + // Act + var result = await _client.GetByIdAsync(TestSignalRTags.StringParam, "Hello World"); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual("Echo: Hello World", result); + } + + [TestMethod] + public async Task GetByIdAsync_Bool_ReturnsTrue() + { + // Act + var result = await _client.GetByIdAsync(TestSignalRTags.BoolParam, true); + + // Assert + Assert.IsTrue(result); + } + + [TestMethod] + public async Task GetByIdAsync_Guid_ReturnsSameGuid() + { + // Arrange + var guid = Guid.NewGuid(); + + // Act + var result = await _client.GetByIdAsync(TestSignalRTags.GuidParam, guid); + + // Assert + Assert.AreEqual(guid, result); + } + + [TestMethod] + public async Task GetByIdAsync_Decimal_ReturnsDoubled() + { + // Act + var result = await _client.GetByIdAsync(TestSignalRTags.DecimalParam, 123.45m); + + // Assert + Assert.AreEqual(246.90m, result); + } + + [TestMethod] + public async Task GetByIdAsync_Long_ReturnsSameLong() + { + // Act + var result = await _client.GetByIdAsync(TestSignalRTags.LongParam, 9223372036854775807L); + + // Assert + Assert.AreEqual(9223372036854775807L, result); + } + + [TestMethod] + public async Task GetByIdAsync_Double_ReturnsSameDouble() + { + // Act + var result = await _client.GetByIdAsync(TestSignalRTags.DoubleParam, 3.14159); + + // Assert + Assert.AreEqual(3.14159, result, 0.00001); + } + + [TestMethod] + public async Task GetByIdAsync_Enum_ReturnsSameEnum() + { + // Act + var result = await _client.GetByIdAsync(TestSignalRTags.EnumParam, (int)TestStatus.Active); + + // Assert + Assert.AreEqual(TestStatus.Active, result); + } + + [TestMethod] + public async Task GetByIdAsync_SingleInt_Callback_ReturnsFormattedString() + { + // Arrange + string? receivedResult = null; + var tcs = new TaskCompletionSource(); + + // Act - GetByIdAsync(tag, callback, id) + await _client.GetByIdAsync(TestSignalRTags.SingleIntParam, response => + { + receivedResult = response.ResponseData; + tcs.SetResult(true); + return Task.CompletedTask; + }, 100); + + await Task.WhenAny(tcs.Task, Task.Delay(5000)); + + // Assert + Assert.IsNotNull(receivedResult); + Assert.AreEqual("Received: 100", receivedResult); + } + + #endregion + + #region GetByIdAsync Tesztek - Több ID (object[]) + + [TestMethod] + public async Task GetByIdAsync_TwoInts_ReturnsSum() + { + // Act - GetByIdAsync(tag, ids[]) + var result = await _client.GetByIdAsync(TestSignalRTags.TwoIntParams, new object[] { 10, 20 }); + + // Assert + Assert.AreEqual(30, result); + } + + [TestMethod] + public async Task GetByIdAsync_MultipleTypes_ReturnsFormattedString() + { + // Act + var result = await _client.GetByIdAsync(TestSignalRTags.MultipleTypesParams, new object[] { true, "test", 123 }); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual("True-test-123", result); + } + + [TestMethod] + public async Task GetByIdAsync_FiveParams_ReturnsFormattedString() + { + // Arrange + var guid = Guid.NewGuid(); + + // Act + var result = await _client.GetByIdAsync(TestSignalRTags.FiveParams, new object[] { 1, "text", true, guid, 99.99m }); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual($"1-text-True-{guid}-99.99", result); + } + + [TestMethod] + public async Task GetByIdAsync_TwoInts_Callback_ReturnsSum() + { + // Arrange + int? receivedResult = null; + var tcs = new TaskCompletionSource(); + + // Act - GetByIdAsync(tag, callback, ids[]) + await _client.GetByIdAsync(TestSignalRTags.TwoIntParams, response => + { + receivedResult = response.ResponseData; + tcs.SetResult(true); + return Task.CompletedTask; + }, new object[] { 5, 7 }); + + await Task.WhenAny(tcs.Task, Task.Delay(5000)); + + // Assert + Assert.IsNotNull(receivedResult); + Assert.AreEqual(12, receivedResult.Value); + } + + #endregion + + #region GetAllAsync Tesztek - ContextParams-szal + + [TestMethod] + public async Task GetAllAsync_WithContextParams_IntArray_ReturnsDoubled() + { + // Act - GetAllAsync(tag, contextParams[]) + var result = await _client.GetAllAsync(TestSignalRTags.IntArrayParam, new object[] { new[] { 1, 2, 3 } }); + + // Assert + Assert.IsNotNull(result); + CollectionAssert.AreEqual(new[] { 2, 4, 6 }, result); + } + + [TestMethod] + public async Task GetAllAsync_WithContextParams_StringList_ReturnsUppercased() + { + // Act + var result = await _client.GetAllAsync>(TestSignalRTags.StringListParam, new object[] { new List { "apple", "banana" } }); + + // Assert + Assert.IsNotNull(result); + CollectionAssert.AreEqual(new List { "APPLE", "BANANA" }, result); + } + + [TestMethod] + public async Task GetAllAsync_WithContextParams_Callback_IntArray() + { + // Arrange + int[]? receivedResult = null; + var tcs = new TaskCompletionSource(); + + // Act - GetAllAsync(tag, callback, contextParams[]) + await _client.GetAllAsync(TestSignalRTags.IntArrayParam, response => + { + receivedResult = response.ResponseData; + tcs.SetResult(true); + return Task.CompletedTask; + }, new object[] { new[] { 5, 10, 15 } }); + + await Task.WhenAny(tcs.Task, Task.Delay(5000)); + + // Assert + Assert.IsNotNull(receivedResult); + CollectionAssert.AreEqual(new[] { 10, 20, 30 }, receivedResult); + } + + #endregion + + #region PostDataAsync Tesztek - Komplex Objektumok + + [TestMethod] + public async Task PostDataAsync_TestEchoRequest_ReturnsEchoResponse() + { + // Arrange + var request = new TestEchoRequest { Id = 42, Name = "TestName" }; + + // Act - PostDataAsync(tag, data) + var result = await _client.PostDataAsync(TestSignalRTags.EchoTag, request); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual(42, result.Id); + Assert.AreEqual("TestName", result.Name); + Assert.IsTrue(result.EchoedSuccessfully); + } + + [TestMethod] + public async Task PostDataAsync_TestOrderItem_ReturnsProcessedItem() + { + // Arrange + var item = new TestOrderItem { Id = 1, ProductName = "TestProduct", Quantity = 5, UnitPrice = 10m }; + + // Act + var result = await _client.PostDataAsync(TestSignalRTags.TestOrderItemParam, item); + //await Task.Delay(1000); + // Assert + Assert.IsNotNull(result); + //Assert.AreEqual("Processed: TestProduct", result.ProductName); + Assert.AreEqual(item.Quantity * 2, result.Quantity); // doubled + } + + [TestMethod] + public async Task PostDataAsync_TestOrder_ReturnsNestedOrder() + { + // Arrange + var order = new TestOrder + { + Id = 100, + CustomerName = "Test Customer", + OrderDate = DateTime.UtcNow, + Status = TestStatus.Active, + Items = [new() { Id = 1, ProductName = "Item1", Quantity = 2, UnitPrice = 10m }] + }; + + // Act + var result = await _client.PostDataAsync(TestSignalRTags.TestOrderParam, order); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual(100, result.Id); + Assert.AreEqual("Test Customer", result.CustomerName); + Assert.AreEqual(1, result.Items.Count); + } + + [TestMethod] + public async Task PostDataAsync_SharedTag_ReturnsTag() + { + // Arrange + var tag = new SharedTag { Id = 1, Name = "Tag1", Description = "Desc", IsActive = true }; + + // Act + var result = await _client.PostDataAsync(TestSignalRTags.SharedTagParam, tag); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual("Tag1", result.Name); + Assert.AreEqual("Desc", result.Description); + } + + [TestMethod] + public async Task PostDataAsync_Callback_TestEchoRequest() + { + // Arrange + var request = new TestEchoRequest { Id = 99, Name = "CallbackTest" }; + TestEchoResponse? receivedResult = null; + var tcs = new TaskCompletionSource(); + + // Act - PostDataAsync(tag, data, callback) + await _client.PostDataAsync(TestSignalRTags.EchoTag, request, response => + { + receivedResult = response.ResponseData; + tcs.SetResult(true); + return Task.CompletedTask; + }); + + await Task.WhenAny(tcs.Task, Task.Delay(5000)); + + // Assert + Assert.IsNotNull(receivedResult); + Assert.AreEqual(99, receivedResult.Id); + } + + #endregion + + #region Edge Case Tesztek + + [TestMethod] + public async Task GetByIdAsync_EmptyString_ReturnsEchoOfEmpty() + { + // Act + var result = await _client.GetByIdAsync(TestSignalRTags.StringParam, ""); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual("Echo: ", result); + } + + [TestMethod] + public async Task GetByIdAsync_Zero_ReturnsFormattedString() + { + // Act + var result = await _client.GetByIdAsync(TestSignalRTags.SingleIntParam, 0); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual("Received: 0", result); + } + + [TestMethod] + public async Task GetByIdAsync_NegativeInt_ReturnsFormattedString() + { + // Act + var result = await _client.GetByIdAsync(TestSignalRTags.SingleIntParam, -42); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual("Received: -42", result); + } + + [TestMethod] + public async Task GetAllAsync_EmptyArray_ReturnsEmptyArray() + { + // Act + var result = await _client.GetAllAsync(TestSignalRTags.IntArrayParam, new object[] { Array.Empty() }); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual(0, result.Length); + } + + #endregion +} \ No newline at end of file diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointSimpleTests.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointSimpleTests.cs new file mode 100644 index 0000000..1520649 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointSimpleTests.cs @@ -0,0 +1,210 @@ +using AyCode.Core.Extensions; +using AyCode.Services.SignalRs; +using FruitBank.Common.SignalRs; +using Mango.Sandbox.EndPoints; +using MessagePack; +using Microsoft.AspNetCore.SignalR.Client; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Text; +using MessagePack.Resolvers; + +namespace Mango.Sandbox.EndPoints.Tests; + +/// +/// Alacsony szintű SignalR tesztek - közvetlen HubConnection használatával. +/// FONTOS: A SANDBOX-ot manuálisan kell elindítani a tesztek futtatása előtt! +/// +[TestClass] +public class SignalREndpointSimpleTests +{ + private static readonly string SandboxUrl = "http://localhost:59579"; + private static readonly string HubUrl = $"{SandboxUrl}/fbHub"; + + [ClassInitialize] + public static async Task ClassInitialize(TestContext context) + { + using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) }; + try + { + var response = await httpClient.GetAsync($"{SandboxUrl}/health"); + Assert.IsTrue(response.IsSuccessStatusCode, + "SANDBOX not running! Start: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579"); + } + catch (Exception ex) + { + Assert.Fail($"SANDBOX not running! {ex.Message}"); + } + } + + #region HTTP Endpoint Tests + + [TestMethod] + public async Task HealthEndpoint_ReturnsSuccess() + { + using var httpClient = new HttpClient(); + var response = await httpClient.GetAsync($"{SandboxUrl}/health"); + Assert.IsTrue(response.IsSuccessStatusCode); + } + + [TestMethod] + public async Task RootEndpoint_ReturnsSandboxIsRunning() + { + using var httpClient = new HttpClient(); + var response = await httpClient.GetStringAsync(SandboxUrl); + Assert.AreEqual("SANDBOX is running!", response); + } + + #endregion + + #region SignalR Connection Tests + + [TestMethod] + public async Task SignalR_Negotiate_ReturnsSuccess() + { + using var httpClient = new HttpClient(); + var response = await httpClient.PostAsync($"{HubUrl}/negotiate?negotiateVersion=1", null); + Assert.IsTrue(response.IsSuccessStatusCode); + } + + [TestMethod] + public async Task SignalR_Connect_Succeeds() + { + var connection = new HubConnectionBuilder() + .WithUrl(HubUrl) + .Build(); + + try + { + await connection.StartAsync(); + Assert.AreEqual(HubConnectionState.Connected, connection.State); + } + finally + { + await connection.StopAsync(); + } + } + + #endregion + + #region Low-Level SignalR Tests + + [TestMethod] + public async Task SignalR_Ping_ReturnsResponse() + { + await SignalRClientHelper(TestSignalRTags.PingTag, "Hello SignalR!", "Ping", response => + { + Assert.IsNotNull(response); + var pingResponse = response.JsonTo(); + Assert.IsNotNull(pingResponse); + Console.WriteLine($"[Ping] Message: {pingResponse.Message}"); + }); + } + + [TestMethod] + public async Task SignalR_Echo_ReturnsEchoedData() + { + var request = new TestEchoRequest { Id = 42, Name = "TestName" }; + await SignalRClientHelper(TestSignalRTags.EchoTag, request, "Echo", response => + { + Assert.IsNotNull(response); + var echoResponse = response.JsonTo(); + Assert.IsNotNull(echoResponse); + Assert.AreEqual(42, echoResponse.Id); + }); + } + + [TestMethod] + public async Task SignalR_GetTestItems_ReturnsItemList() + { + await SignalRClientHelper(TestSignalRTags.GetTestItems, null, "GetTestItems", response => + { + Assert.IsNotNull(response); + var items = response.JsonTo>(); + Assert.IsNotNull(items); + Assert.IsTrue(items.Count > 0); + }); + } + + #endregion + + #region Helper Methods + + private async Task SignalRClientHelper(int tag, object? parameter, string endpointName, Action? validateResponse = null) + { + var connection = new HubConnectionBuilder() + .WithUrl(HubUrl) + .Build(); + + string? receivedJson = null; + var responseReceived = new TaskCompletionSource(); + + connection.On("OnReceiveMessage", (responseTag, data, requestId) => + { + if (data != null && data.Length > 0) + { + try + { + var options = MessagePack.Resolvers.ContractlessStandardResolver.Options; + var response = MessagePackSerializer.Deserialize(data, options); + receivedJson = response?.ResponseData; + } + catch + { + receivedJson = Encoding.UTF8.GetString(data); + } + } + responseReceived.TrySetResult(true); + }); + + try + { + await connection.StartAsync(); + Assert.AreEqual(HubConnectionState.Connected, connection.State); + + byte[]? requestData = CreateRequestData(parameter); + await connection.InvokeAsync("OnReceiveMessage", tag, requestData, (int?)null); + + var completed = await Task.WhenAny(responseReceived.Task, Task.Delay(5000)); + if (completed == responseReceived.Task) + { + validateResponse?.Invoke(receivedJson); + } + else + { + Assert.Fail($"[{endpointName}] Timeout"); + } + } + finally + { + if (connection.State == HubConnectionState.Connected) + await connection.StopAsync(); + } + } + + private static byte[]? CreateRequestData(object? parameter) + { + if (parameter == null) return null; + + var isPrimitive = parameter is string or int or long or double or float or decimal or bool or DateTime; + + if (isPrimitive) + { + var idMessage = new IdMessage(parameter); + return new SignalPostJsonDataMessage(idMessage).ToMessagePack(ContractlessStandardResolver.Options); + } + else + { + return new SignalPostJsonDataMessage(parameter).ToMessagePack(ContractlessStandardResolver.Options); + } + } + + #endregion +} + +/// +/// Wrapper a Task eredményekhez - a szerver Task-ot ad vissza {"Result":...} formátumban +/// +public class TaskResultWrapper +{ + public T? Result { get; set; } +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointTests.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointTests.cs deleted file mode 100644 index 76a7aa6..0000000 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointTests.cs +++ /dev/null @@ -1,218 +0,0 @@ -using Microsoft.AspNetCore.SignalR.Client; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Diagnostics; -using System.Text; -using System.Text.Json; - -namespace Mango.Sandbox.EndPoints.Tests; - -/// -/// SignalR Endpoint tesztek. -/// FONTOS: A SANDBOX-ot manuálisan kell elindítani a tesztek futtatása előtt! -// Indítás: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579 -/// -[TestClass] -public class SignalREndpointTests -{ - private static readonly string SandboxUrl = "http://localhost:59579"; - private static readonly string HubUrl = $"{SandboxUrl}/fbHub"; - - // SignalR Tags from FruitBank.Common.SignalRs.SignalRTags - private const int GetMeasuringUsersTag = 70; - private const int GetStockQuantityHistoryDtosTag = 40; - private const int GetStockQuantityHistoryDtosByProductIdTag = 41; - private const int GetShippingDocumentsByShippingIdTag = 60; - private const int GetOrderDtoByIdTag = 21; - private const int GetStockTakingItemsByIdTag = 81; - - [ClassInitialize] - public static async Task ClassInitialize(TestContext context) - { - using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) }; - try - { - var response = await httpClient.GetAsync($"{SandboxUrl}/health"); - Assert.IsTrue(response.IsSuccessStatusCode, - "SANDBOX is not running! Start it manually: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579"); - } - catch (Exception ex) - { - Assert.Fail($"SANDBOX is not running! Error: {ex.Message}\n" + - "Start it manually: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579"); - } - } - - #region HTTP Endpoint Tests - - [TestMethod] - public async Task HealthEndpoint_ReturnsSuccess() - { - using var httpClient = new HttpClient(); - var response = await httpClient.GetAsync($"{SandboxUrl}/health"); - Assert.IsTrue(response.IsSuccessStatusCode, $"Health endpoint returned {response.StatusCode}"); - } - - [TestMethod] - public async Task RootEndpoint_ReturnsSandboxIsRunning() - { - using var httpClient = new HttpClient(); - var response = await httpClient.GetStringAsync(SandboxUrl); - Assert.AreEqual("SANDBOX is running!", response); - } - - #endregion - - #region SignalR Connection Tests - - [TestMethod] - public async Task SignalR_Negotiate_ReturnsSuccess() - { - using var httpClient = new HttpClient(); - var response = await httpClient.PostAsync($"{HubUrl}/negotiate?negotiateVersion=1", null); - Assert.IsTrue(response.IsSuccessStatusCode, $"SignalR negotiate returned {response.StatusCode}"); - } - - [TestMethod] - public async Task SignalR_Connect_Succeeds() - { - var connection = new HubConnectionBuilder() - .WithUrl(HubUrl) - .Build(); - - try - { - await connection.StartAsync(); - Assert.AreEqual(HubConnectionState.Connected, connection.State); - } - finally - { - await connection.StopAsync(); - } - } - - #endregion - - #region SignalR Business Endpoint Tests - - [TestMethod] - public async Task SignalR_GetMeasuringUsers_ReturnsJson() - { - await TestSignalREndpoint(GetMeasuringUsersTag, null, "GetMeasuringUsers"); - } - - [TestMethod] - public async Task SignalR_GetStockQuantityHistoryDtos_ReturnsJson() - { - await TestSignalREndpoint(GetStockQuantityHistoryDtosTag, null, "GetStockQuantityHistoryDtos"); - } - - [TestMethod] - public async Task SignalR_GetStockQuantityHistoryDtosByProductId_ReturnsJson() - { - // ProductId = 10 - await TestSignalREndpoint(GetStockQuantityHistoryDtosByProductIdTag, 10, "GetStockQuantityHistoryDtosByProductId"); - } - - [TestMethod] - public async Task SignalR_GetShippingDocumentsByShippingId_ReturnsJson() - { - // ShippingId = 5 - await TestSignalREndpoint(GetShippingDocumentsByShippingIdTag, 5, "GetShippingDocumentsByShippingId"); - } - - [TestMethod] - public async Task SignalR_GetOrderDtoById_ReturnsJson() - { - // OrderId = 15 - await TestSignalREndpoint(GetOrderDtoByIdTag, 15, "GetOrderDtoById"); - } - - [TestMethod] - public async Task SignalR_GetStockTakingItemsById_ReturnsJson() - { - // StockTakingItemId = 200 - await TestSignalREndpoint(GetStockTakingItemsByIdTag, 200, "GetStockTakingItemsById"); - } - - #endregion - - #region Helper Methods - - private async Task TestSignalREndpoint(int tag, object? parameter, string endpointName) - { - var connection = new HubConnectionBuilder() - .WithUrl(HubUrl) - .Build(); - - string? receivedJson = null; - int receivedTag = -1; - var responseReceived = new TaskCompletionSource(); - - connection.On("ReceiveMessage", (responseTag, data) => - { - receivedTag = responseTag; - if (data != null && data.Length > 0) - { - receivedJson = Encoding.UTF8.GetString(data); - } - responseReceived.TrySetResult(true); - }); - - try - { - await connection.StartAsync(); - Assert.AreEqual(HubConnectionState.Connected, connection.State, $"Failed to connect to SignalR hub for {endpointName}"); - - // Készítsük el a request data-t - byte[] requestData = parameter != null - ? Encoding.UTF8.GetBytes(JsonSerializer.Serialize(parameter)) - : Array.Empty(); - - await connection.InvokeAsync("ReceiveMessage", tag, requestData); - - var completed = await Task.WhenAny(responseReceived.Task, Task.Delay(15000)); - - if (completed == responseReceived.Task) - { - Console.WriteLine($"[{endpointName}] Response tag: {receivedTag}"); - Console.WriteLine($"[{endpointName}] Response JSON: {receivedJson?.Substring(0, Math.Min(500, receivedJson?.Length ?? 0))}..."); - - // Ellenőrizzük, hogy valid JSON-e (ha van adat) - if (!string.IsNullOrEmpty(receivedJson)) - { - try - { - var jsonDoc = JsonDocument.Parse(receivedJson); - Assert.IsTrue( - jsonDoc.RootElement.ValueKind == JsonValueKind.Array || - jsonDoc.RootElement.ValueKind == JsonValueKind.Object || - jsonDoc.RootElement.ValueKind == JsonValueKind.Null, - $"[{endpointName}] Response is not a valid JSON"); - } - catch (JsonException ex) - { - Assert.Fail($"[{endpointName}] Invalid JSON response: {ex.Message}"); - } - } - } - else - { - Assert.AreEqual(HubConnectionState.Connected, connection.State, - $"[{endpointName}] Connection was closed - check SANDBOX logs for DI errors"); - } - } - catch (Exception ex) - { - Assert.Fail($"[{endpointName}] SignalR error: {ex.Message}. Check SANDBOX logs for missing DI registrations."); - } - finally - { - if (connection.State == HubConnectionState.Connected) - { - await connection.StopAsync(); - } - } - } - - #endregion -} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointWithNopEnvTests.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointWithNopEnvTests.cs new file mode 100644 index 0000000..9c11f96 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointWithNopEnvTests.cs @@ -0,0 +1,218 @@ +using Microsoft.AspNetCore.SignalR.Client; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Diagnostics; +using System.Text; +using System.Text.Json; + +namespace Mango.Sandbox.EndPoints.Tests; + +/// +/// SignalR Endpoint tesztek. +/// FONTOS: A SANDBOX-ot manuálisan kell elindítani a tesztek futtatása előtt! +// Indítás: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579 +/// +[TestClass] +public class SignalREndpointWithNopEnvTests +{ + private static readonly string SandboxUrl = "http://localhost:59579"; + private static readonly string HubUrl = $"{SandboxUrl}/fbHub"; + + // SignalR Tags from FruitBank.Common.SignalRs.SignalRTags + private const int GetMeasuringUsersTag = 70; + private const int GetStockQuantityHistoryDtosTag = 40; + private const int GetStockQuantityHistoryDtosByProductIdTag = 41; + private const int GetShippingDocumentsByShippingIdTag = 60; + private const int GetOrderDtoByIdTag = 21; + private const int GetStockTakingItemsByIdTag = 81; + + //[ClassInitialize] + //public static async Task ClassInitialize(TestContext context) + //{ + // using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) }; + // try + // { + // var response = await httpClient.GetAsync($"{SandboxUrl}/health"); + // Assert.IsTrue(response.IsSuccessStatusCode, + // "SANDBOX is not running! Start it manually: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579"); + // } + // catch (Exception ex) + // { + // Assert.Fail($"SANDBOX is not running! Error: {ex.Message}\n" + + // "Start it manually: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579"); + // } + //} + + //#region HTTP Endpoint Tests + + //[TestMethod] + //public async Task HealthEndpoint_ReturnsSuccess() + //{ + // using var httpClient = new HttpClient(); + // var response = await httpClient.GetAsync($"{SandboxUrl}/health"); + // Assert.IsTrue(response.IsSuccessStatusCode, $"Health endpoint returned {response.StatusCode}"); + //} + + //[TestMethod] + //public async Task RootEndpoint_ReturnsSandboxIsRunning() + //{ + // using var httpClient = new HttpClient(); + // var response = await httpClient.GetStringAsync(SandboxUrl); + // Assert.AreEqual("SANDBOX is running!", response); + //} + + //#endregion + + //#region SignalR Connection Tests + + //[TestMethod] + //public async Task SignalR_Negotiate_ReturnsSuccess() + //{ + // using var httpClient = new HttpClient(); + // var response = await httpClient.PostAsync($"{HubUrl}/negotiate?negotiateVersion=1", null); + // Assert.IsTrue(response.IsSuccessStatusCode, $"SignalR negotiate returned {response.StatusCode}"); + //} + + //[TestMethod] + //public async Task SignalR_Connect_Succeeds() + //{ + // var connection = new HubConnectionBuilder() + // .WithUrl(HubUrl) + // .Build(); + + // try + // { + // await connection.StartAsync(); + // Assert.AreEqual(HubConnectionState.Connected, connection.State); + // } + // finally + // { + // await connection.StopAsync(); + // } + //} + + //#endregion + + //#region SignalR Business Endpoint Tests + + //[TestMethod] + //public async Task SignalR_GetMeasuringUsers_ReturnsJson() + //{ + // await TestSignalREndpoint(GetMeasuringUsersTag, null, "GetMeasuringUsers"); + //} + + //[TestMethod] + //public async Task SignalR_GetStockQuantityHistoryDtos_ReturnsJson() + //{ + // await TestSignalREndpoint(GetStockQuantityHistoryDtosTag, null, "GetStockQuantityHistoryDtos"); + //} + + //[TestMethod] + //public async Task SignalR_GetStockQuantityHistoryDtosByProductId_ReturnsJson() + //{ + // // ProductId = 10 + // await TestSignalREndpoint(GetStockQuantityHistoryDtosByProductIdTag, 10, "GetStockQuantityHistoryDtosByProductId"); + //} + + //[TestMethod] + //public async Task SignalR_GetShippingDocumentsByShippingId_ReturnsJson() + //{ + // // ShippingId = 5 + // await TestSignalREndpoint(GetShippingDocumentsByShippingIdTag, 5, "GetShippingDocumentsByShippingId"); + //} + + //[TestMethod] + //public async Task SignalR_GetOrderDtoById_ReturnsJson() + //{ + // // OrderId = 15 + // await TestSignalREndpoint(GetOrderDtoByIdTag, 15, "GetOrderDtoById"); + //} + + //[TestMethod] + //public async Task SignalR_GetStockTakingItemsById_ReturnsJson() + //{ + // // StockTakingItemId = 200 + // await TestSignalREndpoint(GetStockTakingItemsByIdTag, 200, "GetStockTakingItemsById"); + //} + + //#endregion + + //#region Helper Methods + + //private async Task TestSignalREndpoint(int tag, object? parameter, string endpointName) + //{ + // var connection = new HubConnectionBuilder() + // .WithUrl(HubUrl) + // .Build(); + + // string? receivedJson = null; + // int receivedTag = -1; + // var responseReceived = new TaskCompletionSource(); + + // connection.On("ReceiveMessage", (responseTag, data) => + // { + // receivedTag = responseTag; + // if (data != null && data.Length > 0) + // { + // receivedJson = Encoding.UTF8.GetString(data); + // } + // responseReceived.TrySetResult(true); + // }); + + // try + // { + // await connection.StartAsync(); + // Assert.AreEqual(HubConnectionState.Connected, connection.State, $"Failed to connect to SignalR hub for {endpointName}"); + + // // Készítsük el a request data-t + // byte[] requestData = parameter != null + // ? Encoding.UTF8.GetBytes(JsonSerializer.Serialize(parameter)) + // : Array.Empty(); + + // await connection.InvokeAsync("ReceiveMessage", tag, requestData); + + // var completed = await Task.WhenAny(responseReceived.Task, Task.Delay(15000)); + + // if (completed == responseReceived.Task) + // { + // Console.WriteLine($"[{endpointName}] Response tag: {receivedTag}"); + // Console.WriteLine($"[{endpointName}] Response JSON: {receivedJson?.Substring(0, Math.Min(500, receivedJson?.Length ?? 0))}..."); + + // // Ellenőrizzük, hogy valid JSON-e (ha van adat) + // if (!string.IsNullOrEmpty(receivedJson)) + // { + // try + // { + // var jsonDoc = JsonDocument.Parse(receivedJson); + // Assert.IsTrue( + // jsonDoc.RootElement.ValueKind == JsonValueKind.Array || + // jsonDoc.RootElement.ValueKind == JsonValueKind.Object || + // jsonDoc.RootElement.ValueKind == JsonValueKind.Null, + // $"[{endpointName}] Response is not a valid JSON"); + // } + // catch (JsonException ex) + // { + // Assert.Fail($"[{endpointName}] Invalid JSON response: {ex.Message}"); + // } + // } + // } + // else + // { + // Assert.AreEqual(HubConnectionState.Connected, connection.State, + // $"[{endpointName}] Connection was closed - check SANDBOX logs for DI errors"); + // } + // } + // catch (Exception ex) + // { + // Assert.Fail($"[{endpointName}] SignalR error: {ex.Message}. Check SANDBOX logs for missing DI registrations."); + // } + // finally + // { + // if (connection.State == HubConnectionState.Connected) + // { + // await connection.StopAsync(); + // } + // } + //} + // + //#endregion +} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/DevAdminSignalRHubSandbox.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/DevAdminSignalRHubSandbox.cs new file mode 100644 index 0000000..97c4ab5 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/DevAdminSignalRHubSandbox.cs @@ -0,0 +1,42 @@ +using AyCode.Core.Enums; +using AyCode.Core.Loggers; +using AyCode.Models.Server.DynamicMethods; +using AyCode.Services.Server.SignalRs; +using AyCode.Services.SignalRs; +using FruitBank.Common.Interfaces; +using FruitBank.Common.Loggers; +using FruitBank.Common.Server.Interfaces; +using FruitBank.Common.Server.Services.SignalRs; +using FruitBank.Common.SignalRs; +using Mango.Nop.Core.Loggers; +using Microsoft.Extensions.Configuration; +//using Nop.Plugin.Misc.FruitBankPlugin.Controllers; + +namespace Mango.Sandbox.EndPoints; + +/// +/// Egyszerűsített SignalR Hub a teszteléshez. +/// Ez a Hub nem függ a 3 eredeti endpoint-tól (IFruitBankDataControllerServer, ICustomOrderSignalREndpointServer, IStockSignalREndpointServer). +/// +public class DevAdminSignalRHubSandbox : AcWebSignalRHubWithSessionBase> +{ + public DevAdminSignalRHubSandbox(IConfiguration configuration, ITestSignalREndpointServer testSignalREndpoint, IEnumerable logWriters) + : base(configuration, new Logger(logWriters.ToArray())) + { + DynamicMethodCallModels.Add(new AcDynamicMethodCallModel(testSignalREndpoint)); + + } + + protected override Task SendMessageToClient(IAcSignalRHubItemServer sendTo, int messageTag, ISignalRMessage message, int? requestId = null) + { + Console.WriteLine(((SignalResponseJsonMessage)message).ResponseDataJson); + + return base.SendMessageToClient(sendTo, messageTag, message, requestId); + } +} + +// =========================================== +// === EREDETI KÓD - KIKOMMENTEZVE === +// =========================================== +// A helyes using: FruitBank.Common.Server.Services.SignalRs (nem AyCode.Services.SignalRs!) +// Az AcWebSignalRHubWithSessionBase a FruitBank.Common.Server projektben van definiálva. diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Logger.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Logger.cs new file mode 100644 index 0000000..7f5ea04 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Logger.cs @@ -0,0 +1,40 @@ +using AyCode.Core.Enums; +using AyCode.Core.Loggers; + +namespace Mango.Sandbox.EndPoints; + + +public interface ILogger : ILogger +{ +} +public interface ILogger : IAcLoggerBase +{ +} + +public class Logger : Logger, ILogger +{ + //public Logger() : base(typeof(TCategory).Name) + //{ } + + public Logger(params IAcLogWriterBase[] logWriters) : base(typeof(TCategory).Name, logWriters) + { } + + public Logger(AppType appType, AyCode.Core.Loggers.LogLevel logLevel, params IAcLogWriterBase[] logWriters) : base(appType, logLevel, typeof(TCategory).Name, logWriters) + { } +} + +public class Logger : AcLoggerBase, ILogger +{ + public Logger(params IAcLogWriterBase[] logWriters) : this(null, logWriters) + { } + + public Logger(string? categoryName) : base(categoryName) + { } + + public Logger(string? categoryName, params IAcLogWriterBase[] logWriters) : base(categoryName, logWriters) + { } + + public Logger(AppType appType, AyCode.Core.Loggers.LogLevel logLevel, string? categoryName, params IAcLogWriterBase[] logWriters) : base(appType, logLevel, categoryName, logWriters) + { } +} + diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Mango.Sandbox.EndPoints.csproj b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Mango.Sandbox.EndPoints.csproj index 7337993..a8a0166 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Mango.Sandbox.EndPoints.csproj +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Mango.Sandbox.EndPoints.csproj @@ -1,10 +1,10 @@ - + net9.0 enable enable - + false + H:\Applications\Aycode\Source\AyCode.Core\ - + - + - + @@ -76,63 +78,57 @@ - - - + + + + + + - - - - $(PluginOutputDir)Nop.Plugin.Misc.FruitBankPlugin.dll - - - $(PluginOutputDir)Mango.Nop.Core.dll - - - $(PluginOutputDir)Mango.Nop.Services.dll - - + - + + - $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Core.dll + $(AyCodeRoot)AyCode.Core\bin\FruitBank\Debug\net9.0\AyCode.Core.dll - $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Core.Server.dll + $(AyCodeRoot)AyCode.Core.Server\bin\FruitBank\Debug\net9.0\AyCode.Core.Server.dll - $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Database.dll + $(AyCodeRoot)AyCode.Database\bin\FruitBank\Debug\net9.0\AyCode.Database.dll - $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Entities.dll + $(AyCodeRoot)AyCode.Entities\bin\FruitBank\Debug\net9.0\AyCode.Entities.dll - $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Entities.Server.dll + $(AyCodeRoot)AyCode.Entities.Server\bin\FruitBank\Debug\net9.0\AyCode.Entities.Server.dll - $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Interfaces.dll + $(AyCodeRoot)AyCode.Interfaces\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.dll - $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Interfaces.Server.dll + $(AyCodeRoot)AyCode.Interfaces.Server\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.Server.dll - $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Models.Server.dll + $(AyCodeRoot)AyCode.Models.Server\bin\FruitBank\Debug\net9.0\AyCode.Models.Server.dll - $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Services.dll + $(AyCodeRoot)AyCode.Services\bin\FruitBank\Debug\net9.0\AyCode.Services.dll - $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Services.Server.dll + $(AyCodeRoot)AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll - $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Utils.dll + $(AyCodeRoot)AyCode.Utils\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll + $(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\FruitBank.Common.dll diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Program.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Program.cs index c674ff9..5eac8f7 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Program.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Program.cs @@ -1,161 +1,17 @@ using AyCode.Core.Loggers; -using FluentValidation; -using FluentValidation.AspNetCore; using FruitBank.Common; -using FruitBank.Common.Interfaces; -using FruitBank.Common.Server.Interfaces; using FruitBank.Common.Server.Services.Loggers; using FruitBank.Common.Server.Services.SignalRs; -using Mango.Nop.Services; -using Mango.Nop.Services.Loggers; -using Mango.Sandbox.EndPoints.Services; +using Mango.Sandbox.EndPoints; using Microsoft.AspNetCore.Http.Connections; -using Microsoft.AspNetCore.Mvc.Infrastructure; -using Nop.Core; -using Nop.Core.Caching; -using Nop.Core.Configuration; -using Nop.Core.Domain; -using Nop.Core.Domain.Blogs; -using Nop.Core.Domain.Catalog; -using Nop.Core.Domain.Common; -using Nop.Core.Domain.Customers; -using Nop.Core.Domain.Directory; -using Nop.Core.Domain.Forums; -using Nop.Core.Domain.Gdpr; -using Nop.Core.Domain.Localization; -using Nop.Core.Domain.Media; -using Nop.Core.Domain.Messages; -using Nop.Core.Domain.News; -using Nop.Core.Domain.Orders; -using Nop.Core.Domain.Payments; -using Nop.Core.Domain.Security; -using Nop.Core.Domain.Seo; -using Nop.Core.Domain.Shipping; -using Nop.Core.Domain.Stores; -using Nop.Core.Domain.Tax; -using Nop.Core.Domain.Vendors; -using Nop.Core.Events; -using Nop.Core.Http; -using Nop.Core.Infrastructure; -using Nop.Core.Security; -using Nop.Data; -using Nop.Data.DataProviders; -using Nop.Data.Mapping; -using Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers; -using Nop.Plugin.Misc.FruitBankPlugin.Controllers; -using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer; -using Nop.Plugin.Misc.FruitBankPlugin.Factories; -using Nop.Plugin.Misc.FruitBankPlugin.Mapping; -using Nop.Plugin.Misc.FruitBankPlugin.Services; -using Nop.Services.Affiliates; -using Nop.Services.Attributes; -using Nop.Services.Authentication; -using Nop.Services.Authentication.External; -using Nop.Services.Authentication.MultiFactor; -using Nop.Services.Blogs; -using Nop.Services.Caching; -using Nop.Services.Catalog; -using Nop.Services.Cms; -using Nop.Services.Common; -using Nop.Services.Configuration; -using Nop.Services.Customers; -using Nop.Services.Directory; -using Nop.Services.Discounts; -using Nop.Services.Events; -using Nop.Services.ExportImport; -using Nop.Services.Forums; -using Nop.Services.Gdpr; -using Nop.Services.Helpers; -using Nop.Services.Html; -using Nop.Services.Installation; -using Nop.Services.Localization; -using Nop.Services.Logging; -using Nop.Services.Media; -using Nop.Services.Media.RoxyFileman; -using Nop.Services.Messages; -using Nop.Services.News; -using Nop.Services.Orders; -using Nop.Services.Payments; -using Nop.Services.Plugins; -using Nop.Services.Plugins.Marketplace; -using Nop.Services.Polls; -using Nop.Services.ScheduleTasks; -using Nop.Services.Security; -using Nop.Services.Seo; -using Nop.Services.Shipping; -using Nop.Services.Shipping.Date; -using Nop.Services.Shipping.Pickup; -using Nop.Services.Stores; -using Nop.Services.Tax; -using Nop.Services.Themes; -using Nop.Services.Topics; -using Nop.Services.Vendors; -using Nop.Web.Areas.Admin.Factories; -using Nop.Web.Areas.Admin.Helpers; -using Nop.Web.Framework; -using Nop.Web.Framework.Factories; -using Nop.Web.Framework.Infrastructure; -using Nop.Web.Framework.Menu; -using Nop.Web.Framework.Mvc.Routing; -using Nop.Web.Framework.Themes; -using Nop.Web.Framework.UI; -using Nop.Web.Infrastructure.Installation; -using System.Net.Http.Headers; var builder = WebApplication.CreateBuilder(args); // =========================================== -// === KONFIGURÁCIÓ === +// === MINIMÁLIS KONFIGURÁCIÓ A SIGNALR HUB TESZTELÉSÉHEZ === // =========================================== -var prodAppSettingsPath = Path.GetFullPath(Path.Combine( - builder.Environment.ContentRootPath, - "..", "..", "..", - "Presentation", "Nop.Web", "App_Data", "appsettings.json")); - -if (File.Exists(prodAppSettingsPath)) -{ - builder.Configuration.AddJsonFile(prodAppSettingsPath, optional: false, reloadOnChange: true); - Console.WriteLine($"[SANDBOX] PROD config loaded: {prodAppSettingsPath}"); -} -else -{ - Console.WriteLine($"[SANDBOX] WARNING: PROD appsettings.json not found at: {prodAppSettingsPath}"); -} - -builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); -Console.WriteLine("[SANDBOX] SANDBOX config overrides applied"); - -// =========================================== -// === NAME COMPATIBILITY - LinqToDB tábla mapping === -// =========================================== - -NameCompatibilityManager.AdditionalNameCompatibilities.Add(typeof(NameCompatibility)); -Console.WriteLine("[SANDBOX] FruitBank NameCompatibility registered for LinqToDB table mapping"); - -// =========================================== -// === FILE PROVIDER (STATIC) === -// =========================================== - -CommonHelper.DefaultFileProvider = new NopFileProvider(builder.Environment); - -// =========================================== -// === TYPE FINDER === -// =========================================== - -var typeFinder = new WebAppTypeFinder(); -Singleton.Instance = typeFinder; -builder.Services.AddSingleton(typeFinder); -Console.WriteLine("[SANDBOX] TypeFinder registered"); - -// =========================================== -// === ENGINE === -// =========================================== - -var engine = new NopEngine(); -Singleton.Instance = engine; -builder.Services.AddSingleton(engine); -Console.WriteLine("[SANDBOX] NopEngine registered"); +Console.WriteLine("[SANDBOX] Starting minimal SignalR Hub test configuration..."); // =========================================== // === CORS === @@ -184,489 +40,26 @@ builder.Host.UseDefaultServiceProvider(options => options.ValidateOnBuild = false; }); -// =========================================== -// === MVC INFRASTRUKTÚRA === -// =========================================== - -builder.Services.AddControllersWithViews(); -builder.Services.AddRazorPages(); -builder.Services.AddSession(); - // =========================================== // === ALAPVETŐ INFRASTRUKTÚRA === // =========================================== builder.Services.AddHttpContextAccessor(); -builder.Services.AddSingleton(); builder.Services.AddMemoryCache(); +builder.Services.AddDistributedMemoryCache(); // IDistributedCache a Session-höz +builder.Services.AddSession(); // =========================================== -// === APP SETTINGS === +// === LOGGER - Csak ConsoleLogWriter a teszteléshez === // =========================================== -var appSettings = new AppSettings(); -builder.Configuration.Bind(appSettings); -builder.Services.AddSingleton(appSettings); -Singleton.Instance = appSettings; - -// =========================================== -// === FILE PROVIDER (DI) === -// =========================================== - -builder.Services.AddScoped(); - -// =========================================== -// === ADATBÁZIS ÉS REPOSITORY === -// =========================================== - -builder.Services.AddScoped(); -builder.Services.AddScoped(typeof(IRepository<>), typeof(EntityRepository<>)); - -// =========================================== -// === CACHE SZOLGÁLTATÁSOK === -// =========================================== - -builder.Services.AddTransient(typeof(IConcurrentCollection<>), typeof(ConcurrentTrie<>)); -builder.Services.AddSingleton(); -builder.Services.AddScoped(); -builder.Services.AddSingleton(); -builder.Services.AddSingleton(); -builder.Services.AddScoped(); - -// =========================================== -// === EVENT PUBLISHER === -// =========================================== - -builder.Services.AddSingleton(); - -// =========================================== -// === LAZY WRAPPERS === -// =========================================== - -builder.Services.AddScoped(typeof(Lazy<>), typeof(LazyInstance<>)); - -// =========================================== -// === NOP SETTINGS (Domain Settings) - DINAMIKUS REGISZTRÁCIÓ === -// =========================================== - -// Alapvető Settings-ek fix értékekkel (amik a SANDBOX működéséhez szükségesek) -builder.Services.AddScoped(sp => new CookieSettings()); -builder.Services.AddScoped(sp => new CurrencySettings { PrimaryStoreCurrencyId = 1 }); -builder.Services.AddScoped(sp => new LocalizationSettings { DefaultAdminLanguageId = 1, AutomaticallyDetectLanguage = false }); -builder.Services.AddScoped(sp => new TaxSettings { TaxDisplayType = TaxDisplayType.IncludingTax }); -builder.Services.AddScoped(sp => new CatalogSettings()); -builder.Services.AddScoped(sp => new OrderSettings()); -builder.Services.AddScoped(sp => new ShippingSettings()); -builder.Services.AddScoped(sp => new RewardPointsSettings()); -builder.Services.AddScoped(sp => new CustomerSettings()); -builder.Services.AddScoped(sp => new CommonSettings()); -builder.Services.AddScoped(sp => new ShoppingCartSettings()); -builder.Services.AddScoped(sp => new MediaSettings()); -builder.Services.AddScoped(sp => new StoreInformationSettings()); -builder.Services.AddScoped(sp => new SeoSettings()); -builder.Services.AddScoped(sp => new SecuritySettings()); -builder.Services.AddScoped(sp => new AdminAreaSettings()); -builder.Services.AddScoped(sp => new EmailAccountSettings()); -builder.Services.AddScoped(sp => new MessagesSettings()); -builder.Services.AddScoped(sp => new ExternalAuthenticationSettings()); -builder.Services.AddScoped(sp => new VendorSettings()); -builder.Services.AddScoped(sp => new BlogSettings()); -builder.Services.AddScoped(sp => new NewsSettings()); -builder.Services.AddScoped(sp => new ForumSettings()); -builder.Services.AddScoped(sp => new GdprSettings()); -builder.Services.AddScoped(sp => new PaymentSettings()); -builder.Services.AddScoped(sp => new AddressSettings()); -builder.Services.AddScoped(sp => new DateTimeSettings()); -builder.Services.AddScoped(sp => new CaptchaSettings()); -builder.Services.AddScoped(sp => new DisplayDefaultMenuItemSettings()); -builder.Services.AddScoped(sp => new DisplayDefaultFooterItemSettings()); -builder.Services.AddScoped(sp => new PdfSettings()); -builder.Services.AddScoped(sp => new RobotsTxtSettings()); -builder.Services.AddScoped(sp => new SitemapSettings()); -builder.Services.AddScoped(sp => new SitemapXmlSettings()); -builder.Services.AddScoped(sp => new MeasureSettings()); -builder.Services.AddScoped(sp => new MultiFactorAuthenticationSettings()); -builder.Services.AddScoped(sp => new ProxySettings()); - -// További Settings-ek (Nop.Core.Domain namespace-ekből) -builder.Services.AddScoped(sp => new Nop.Core.Domain.Catalog.ProductEditorSettings()); -builder.Services.AddScoped(sp => new Nop.Core.Domain.Messages.MessageTemplatesSettings()); - -// =========================================== -// === NOP CORE SZOLGÁLTATÁSOK === -// =========================================== - -// Web & Utils -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Context -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Plugins -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Settings & Config -builder.Services.AddScoped(); - -// Security & Permission -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Authentication -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Store -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Localization -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Currency & Directory -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Customer -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Address & Vendor & Affiliate -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Generic Attribute -builder.Services.AddScoped(); - -// Maintenance -builder.Services.AddScoped(); - -// Catalog -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Pricing (CustomPriceCalculationService a FruitBank-ból) -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Search -builder.Services.AddScoped(); - -// Orders -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Shipping -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Tax -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Payment -builder.Services.AddScoped(); - -// Discounts -builder.Services.AddScoped(); - -// Media -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Messages & Notifications -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// SEO & HTML -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Logging -builder.Services.AddScoped(); - -// Topics & Content -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// GDPR -builder.Services.AddScoped(); - -// Export/Import -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Themes -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Schedule Tasks -builder.Services.AddSingleton(); -builder.Services.AddTransient(); -builder.Services.AddScoped(); - -// Installation -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Slug Route Transformer (ha van adatbázis) -builder.Services.AddScoped(); - -// Routing -builder.Services.AddSingleton(); - -// Roxy File Manager -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Web Framework -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// Attribute Services (generic) -builder.Services.AddScoped(typeof(IAttributeService<,>), typeof(AttributeService<,>)); -builder.Services.AddScoped(typeof(IAttributeParser<,>), typeof(Nop.Services.Attributes.AttributeParser<,>)); -builder.Services.AddScoped(typeof(IAttributeFormatter<,>), typeof(AttributeFormatter<,>)); - -// Plugin Managers (generic) -builder.Services.AddScoped(typeof(IPluginManager<>), typeof(PluginManager<>)); - -// =========================================== -// === PLUGIN MANAGEREK (Null implementációk) === -// =========================================== - -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// =========================================== -// === NOP.WEB COMMON FACTORIES (Nop.Web\Infrastructure\NopStartup.cs) === -// =========================================== - -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// =========================================== -// === NOP.WEB ADMIN MODEL FACTORIES (Nop.Web\Infrastructure\NopStartup.cs) === -// =========================================== - -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -// IOrderModelFactory - FruitBank CustomOrderModelFactory felülírja! -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -// IProductModelFactory - FruitBank CustomProductModelFactory felülírja! -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// =========================================== -// === NOP.WEB PUBLIC FACTORIES (Nop.Web\Infrastructure\NopStartup.cs) === -// =========================================== - -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// =========================================== -// === NOP.WEB HELPERS === -// =========================================== - -builder.Services.AddScoped(); - -// =========================================== -// === FRUITBANK PLUGIN SZOLGÁLTATÁSOK (PluginNopStartup-ból) === -// ===========================================; - -// Logger builder.Services.AddScoped(); -builder.Services.AddTransient(); -builder.Services.AddScoped(); -builder.Services.AddSingleton(); -// Core -builder.Services.AddSingleton(); -builder.Services.AddScoped(); +// =========================================== +// === TESZT ENDPOINT === +// =========================================== -// Event Consumer -builder.Services.AddScoped, EventConsumer>(); - -// Business Services -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// ReplicateService with HttpClient -builder.Services.AddScoped(); -builder.Services.AddHttpClient(client => -{ - client.DefaultRequestHeaders.Authorization = - new AuthenticationHeaderValue("Bearer", "r8_MUApXYIE5mRjxqy20tsGLehWBJkCzNj0Cwvrh"); -}); - -// DbTable Services -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// DbContext Services -builder.Services.AddScoped(); -builder.Services.AddScoped(); - -// SignalR Services -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); // =========================================== // === SIGNALR KONFIGURÁCIÓ === @@ -690,8 +83,14 @@ var app = builder.Build(); app.UseCors("SignalR"); app.UseSession(); +// =========================================== +// === SIGNALR HUB REGISZTRÁCIÓ === +// =========================================== + var fruitBankHubEndPoint = $"/{FruitBankConstClient.DefaultHubName}"; -app.MapHub(fruitBankHubEndPoint, options => + +// SANDBOX TESZT HUB - egyszerűsített, nincs Nop függőség +app.MapHub(fruitBankHubEndPoint, options => { options.Transports = HttpTransportType.WebSockets; options.WebSockets.CloseTimeout = TimeSpan.FromSeconds(10); @@ -714,23 +113,11 @@ app.MapGet("/health", () => Results.Ok(new { status = "healthy", timestamp = Dat // === CONSOLE OUTPUT === // =========================================== -var finalConnectionString = app.Configuration.GetConnectionString("ConnectionString") ?? ""; -var databaseName = "Unknown"; -if (!string.IsNullOrEmpty(finalConnectionString)) -{ - var match = System.Text.RegularExpressions.Regex.Match(finalConnectionString, @"Initial Catalog=([^;]+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase); - if (match.Success) - { - databaseName = match.Groups[1].Value; - } -} - -Console.Title = $"[SB] - {databaseName}"; +Console.Title = "[SB] - SignalR Test"; Console.WriteLine("==========================================="); -Console.WriteLine($" FRUITBANK SANDBOX - {databaseName}"); +Console.WriteLine(" FRUITBANK SANDBOX - SignalR Test Mode"); Console.WriteLine("==========================================="); -Console.WriteLine($" Database: {databaseName}"); Console.WriteLine($" Base URL: http://localhost:59579"); Console.WriteLine($" SignalR Hub: {fruitBankHubEndPoint}"); Console.WriteLine($" Logger Hub: {loggerHubEndPoint}"); diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/TestSignalREndpoint.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/TestSignalREndpoint.cs new file mode 100644 index 0000000..80fea18 --- /dev/null +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/TestSignalREndpoint.cs @@ -0,0 +1,587 @@ +using AyCode.Services.SignalRs; +using FruitBank.Common.Dtos; +using FruitBank.Common.SignalRs; +using System.Globalization; +using System.Text.Json.Serialization; + +namespace Mango.Sandbox.EndPoints; + +/// +/// Egyszerű teszt SignalR endpoint a DevAdminSignalRHub teszteléséhez. +/// Ez az endpoint minimális függőséggel rendelkezik, hogy könnyebben diagnosztizálható legyen a SignalR Hub működése. +/// +public class TestSignalREndpoint : ITestSignalREndpointServer +{ + #region Primitív Paraméter Handlerek + + /// + /// Egyszerű ping metódus - visszaadja a kapott üzenetet és egy timestampet. + /// + [SignalR(TestSignalRTags.PingTag)] + public Task Ping(string message) + { + return Task.FromResult(new TestPingResponse + { + Message = message, + ReceivedAt = DateTime.UtcNow, + ServerInfo = $"Sandbox Server - {Environment.MachineName}" + }); + } + + /// + /// Int paraméter teszt + /// + [SignalR(TestSignalRTags.SingleIntParam)] + public Task HandleSingleInt(int value) + { + return Task.FromResult($"Received: {value}"); + } + + /// + /// Két int paraméter teszt + /// + [SignalR(TestSignalRTags.TwoIntParams)] + public Task HandleTwoInts(int a, int b) + { + return Task.FromResult(a + b); + } + + /// + /// Bool paraméter teszt + /// + [SignalR(TestSignalRTags.BoolParam)] + public Task HandleBool(bool loadRelations) + { + return Task.FromResult(loadRelations); + } + + /// + /// String paraméter teszt + /// + [SignalR(TestSignalRTags.StringParam)] + public Task HandleString(string text) + { + return Task.FromResult($"Echo: {text}"); + } + + /// + /// Guid paraméter teszt + /// + [SignalR(TestSignalRTags.GuidParam)] + public Task HandleGuid(Guid id) + { + return Task.FromResult(id); + } + + /// + /// Enum paraméter teszt + /// + [SignalR(TestSignalRTags.EnumParam)] + public Task HandleEnum(TestStatus status) + { + return Task.FromResult(status); + } + + /// + /// Paraméter nélküli metódus teszt + /// + [SignalR(TestSignalRTags.NoParams)] + public Task HandleNoParams() + { + return Task.FromResult("OK"); + } + + /// + /// Több típusú paraméter teszt + /// + [SignalR(TestSignalRTags.MultipleTypesParams)] + public Task HandleMultipleTypes(bool flag, string text, int number) + { + return Task.FromResult($"{flag}-{text}-{number}"); + } + + /// + /// Decimal paraméter teszt + /// + [SignalR(TestSignalRTags.DecimalParam)] + public Task HandleDecimal(decimal value) + { + return Task.FromResult(value * 2); + } + + /// + /// DateTime paraméter teszt + /// + [SignalR(TestSignalRTags.DateTimeParam)] + public Task HandleDateTime(DateTime dateTime) + { + return Task.FromResult(dateTime); + } + + /// + /// Double paraméter teszt + /// + [SignalR(TestSignalRTags.DoubleParam)] + public Task HandleDouble(double value) + { + return Task.FromResult(value); + } + + /// + /// Long paraméter teszt + /// + [SignalR(TestSignalRTags.LongParam)] + public Task HandleLong(long value) + { + return Task.FromResult(value); + } + + #endregion + + #region Komplex Objektum Handlerek + + /// + /// Egyszerű echo metódus - visszaadja a kapott objektumot változtatás nélkül. + /// + [SignalR(TestSignalRTags.EchoTag)] + public Task Echo(TestEchoRequest request) + { + return Task.FromResult(new TestEchoResponse + { + Id = request?.Id ?? 0, + Name = request?.Name ?? "Unknown", + Timestamp = DateTime.UtcNow, + EchoedSuccessfully = true + }); + } + + /// + /// TestOrderItem komplex objektum teszt + /// + [SignalR(TestSignalRTags.TestOrderItemParam)] + public Task HandleTestOrderItem(TestOrderItem item) + { + return Task.FromResult(new TestOrderItem + { + Id = item.Id, + ProductName = $"Processed: {item.ProductName}", + Quantity = item.Quantity * 2, + UnitPrice = item.UnitPrice * 2, + }); + } + + /// + /// TestOrder komplex objektum teszt (beágyazott objektumokkal) + /// + [SignalR(TestSignalRTags.TestOrderParam)] + public Task HandleTestOrder(TestOrder order) + { + return Task.FromResult(order); + } + + /// + /// SharedTag komplex objektum teszt + /// + [SignalR(TestSignalRTags.SharedTagParam)] + public Task HandleSharedTag(SharedTag tag) + { + return Task.FromResult(tag); + } + + #endregion + + #region Kollekció Handlerek + + /// + /// Lista visszaadása teszthez. + /// + [SignalR(TestSignalRTags.GetTestItems)] + public Task> GetTestItems() + { + var items = new List + { + new() { Id = 1, Name = "Item 1", Value = 100.5m }, + new() { Id = 2, Name = "Item 2", Value = 200.75m }, + new() { Id = 3, Name = "Item 3", Value = 300.25m } + }; + return Task.FromResult(items); + } + + /// + /// Int tömb paraméter teszt + /// + [SignalR(TestSignalRTags.IntArrayParam)] + public Task HandleIntArray(int[] values) + { + return Task.FromResult(values.Select(x => x * 2).ToArray()); + } + + /// + /// Guid tömb paraméter teszt + /// + [SignalR(TestSignalRTags.GuidArrayParam)] + public Task HandleGuidArray(Guid[] ids) + { + return Task.FromResult(ids); + } + + /// + /// String lista paraméter teszt + /// + [SignalR(TestSignalRTags.StringListParam)] + public Task> HandleStringList(List items) + { + return Task.FromResult(items.Select(x => x.ToUpper()).ToList()); + } + + /// + /// TestOrderItem lista paraméter teszt + /// + [SignalR(TestSignalRTags.TestOrderItemListParam)] + public Task> HandleTestOrderItemList(List items) + { + return Task.FromResult(items); + } + + /// + /// Int lista paraméter teszt + /// + [SignalR(TestSignalRTags.IntListParam)] + public Task> HandleIntList(List numbers) + { + return Task.FromResult(numbers.Select(x => x * 2).ToList()); + } + + /// + /// Bool tömb paraméter teszt + /// + [SignalR(TestSignalRTags.BoolArrayParam)] + public Task HandleBoolArray(bool[] flags) + { + return Task.FromResult(flags); + } + + /// + /// Vegyes paraméterek tömbbel teszt + /// + [SignalR(TestSignalRTags.MixedWithArrayParam)] + public Task HandleMixedWithArray(bool flag, int[] numbers, string text) + { + return Task.FromResult($"{flag}-[{string.Join(",", numbers)}]-{text}"); + } + + /// + /// Beágyazott lista teszt + /// + [SignalR(TestSignalRTags.NestedListParam)] + public Task>> HandleNestedList(List> nestedList) + { + return Task.FromResult(nestedList); + } + + /// + /// Long tömb paraméter teszt + /// + [SignalR(TestSignalRTags.LongArrayParam)] + public Task HandleLongArray(long[] values) + { + return Task.FromResult(values); + } + + /// + /// Decimal tömb paraméter teszt + /// + [SignalR(TestSignalRTags.DecimalArrayParam)] + public Task HandleDecimalArray(decimal[] values) + { + return Task.FromResult(values); + } + + /// + /// DateTime tömb paraméter teszt + /// + [SignalR(TestSignalRTags.DateTimeArrayParam)] + public Task HandleDateTimeArray(DateTime[] values) + { + return Task.FromResult(values); + } + + /// + /// Enum tömb paraméter teszt + /// + [SignalR(TestSignalRTags.EnumArrayParam)] + public Task HandleEnumArray(TestStatus[] values) + { + return Task.FromResult(values); + } + + /// + /// Double tömb paraméter teszt + /// + [SignalR(TestSignalRTags.DoubleArrayParam)] + public Task HandleDoubleArray(double[] values) + { + return Task.FromResult(values); + } + + /// + /// SharedTag tömb paraméter teszt + /// + [SignalR(TestSignalRTags.SharedTagArrayParam)] + public Task HandleSharedTagArray(SharedTag[] tags) + { + return Task.FromResult(tags); + } + + /// + /// Dictionary paraméter teszt + /// + [SignalR(TestSignalRTags.DictionaryParam)] + public Task> HandleDictionary(Dictionary dict) + { + return Task.FromResult(dict); + } + + #endregion + + #region Vegyes Paraméter Handlerek + + /// + /// Int és DTO vegyes paraméter teszt + /// + [SignalR(TestSignalRTags.IntAndDtoParam)] + public Task HandleIntAndDto(int id, TestOrderItem item) + { + return Task.FromResult($"{id}-{item?.ProductName}"); + } + + /// + /// DTO és lista vegyes paraméter teszt + /// + [SignalR(TestSignalRTags.DtoAndListParam)] + public Task HandleDtoAndList(TestOrderItem item, List numbers) + { + return Task.FromResult($"{item?.ProductName}-[{string.Join(",", numbers ?? [])}]"); + } + + /// + /// Három komplex paraméter teszt + /// + [SignalR(TestSignalRTags.ThreeComplexParams)] + public Task HandleThreeComplexParams(TestOrderItem item, List tags, SharedTag sharedTag) + { + return Task.FromResult($"{item?.ProductName}-{tags?.Count}-{sharedTag?.Name}"); + } + + /// + /// Öt paraméter teszt + /// + [SignalR(TestSignalRTags.FiveParams)] + public Task HandleFiveParams(int a, string b, bool c, Guid d, decimal e) + { + return Task.FromResult($"{a}-{b}-{c}-{d}-{e.ToString(CultureInfo.InvariantCulture)}"); + } + + #endregion + + #region FruitBank Specifikus Metódusok + + /// + /// OrderDto lista visszaadása ID-k alapján + /// + [SignalR(SignalRTags.GetAllOrderDtoByIds)] + public Task> GetOrderDtoByIds(int[] orderIds) + { + return Task.FromResult(new List()); + } + + #endregion +} + +/// +/// Teszt SignalR Tags - egyszerű értékek a teszteléshez +/// +public static class TestSignalRTags +{ + // Eredeti tagok + public const int PingTag = SignalRTags.PingTag; + public const int EchoTag = SignalRTags.EchoTag; + public const int GetTestItems = 9003; + + // Primitív paraméterek + public const int SingleIntParam = 9010; + public const int TwoIntParams = 9011; + public const int BoolParam = 9012; + public const int StringParam = 9013; + public const int GuidParam = 9014; + public const int EnumParam = 9015; + public const int NoParams = 9016; + public const int MultipleTypesParams = 9017; + public const int DecimalParam = 9018; + public const int DateTimeParam = 9019; + public const int DoubleParam = 9020; + public const int LongParam = 9021; + + // Komplex objektumok + public const int TestOrderItemParam = 9030; + public const int TestOrderParam = 9031; + public const int SharedTagParam = 9032; + + // Kollekciók + public const int IntArrayParam = 9040; + public const int GuidArrayParam = 9041; + public const int StringListParam = 9042; + public const int TestOrderItemListParam = 9043; + public const int IntListParam = 9044; + public const int BoolArrayParam = 9045; + public const int MixedWithArrayParam = 9046; + public const int NestedListParam = 9047; + public const int LongArrayParam = 9048; + public const int DecimalArrayParam = 9049; + public const int DateTimeArrayParam = 9050; + public const int EnumArrayParam = 9051; + public const int DoubleArrayParam = 9052; + public const int SharedTagArrayParam = 9053; + public const int DictionaryParam = 9054; + + // Vegyes paraméterek + public const int IntAndDtoParam = 9060; + public const int DtoAndListParam = 9061; + public const int ThreeComplexParams = 9062; + public const int FiveParams = 9063; +} + +/// +/// Interface a TestSignalREndpoint-hoz +/// +public interface ITestSignalREndpointServer +{ + // Primitívek + Task Ping(string message); + Task HandleSingleInt(int value); + Task HandleTwoInts(int a, int b); + Task HandleBool(bool loadRelations); + Task HandleString(string text); + Task HandleGuid(Guid id); + Task HandleEnum(TestStatus status); + Task HandleNoParams(); + Task HandleMultipleTypes(bool flag, string text, int number); + Task HandleDecimal(decimal value); + Task HandleDateTime(DateTime dateTime); + Task HandleDouble(double value); + Task HandleLong(long value); + + // Komplex objektumok + Task Echo(TestEchoRequest request); + Task HandleTestOrderItem(TestOrderItem item); + Task HandleTestOrder(TestOrder order); + Task HandleSharedTag(SharedTag tag); + + // Kollekciók + Task> GetTestItems(); + Task HandleIntArray(int[] values); + Task HandleGuidArray(Guid[] ids); + Task> HandleStringList(List items); + Task> HandleTestOrderItemList(List items); + Task> HandleIntList(List numbers); + Task HandleBoolArray(bool[] flags); + Task HandleMixedWithArray(bool flag, int[] numbers, string text); + Task>> HandleNestedList(List> nestedList); + Task HandleLongArray(long[] values); + Task HandleDecimalArray(decimal[] values); + Task HandleDateTimeArray(DateTime[] values); + Task HandleEnumArray(TestStatus[] values); + Task HandleDoubleArray(double[] values); + Task HandleSharedTagArray(SharedTag[] tags); + Task> HandleDictionary(Dictionary dict); + + // Vegyes paraméterek + Task HandleIntAndDto(int id, TestOrderItem item); + Task HandleDtoAndList(TestOrderItem item, List numbers); + Task HandleThreeComplexParams(TestOrderItem item, List tags, SharedTag sharedTag); + Task HandleFiveParams(int a, string b, bool c, Guid d, decimal e); +} + +#region DTOs + +public class TestPingResponse +{ + public string Message { get; set; } = string.Empty; + public DateTime ReceivedAt { get; set; } + public string ServerInfo { get; set; } = string.Empty; +} + +public class TestEchoRequest +{ + public int Id { get; set; } + public string Name { get; set; } = string.Empty; +} + +public class TestEchoResponse +{ + public int Id { get; set; } + public string Name { get; set; } = string.Empty; + public DateTime Timestamp { get; set; } + public bool EchoedSuccessfully { get; set; } +} + +public class TestItem +{ + public int Id { get; set; } + public string Name { get; set; } = string.Empty; + public decimal Value { get; set; } +} + +/// +/// Teszt enum a különböző állapotok teszteléséhez +/// +public enum TestStatus +{ + Pending = 0, + Active = 1, + Completed = 2, + Cancelled = 3 +} + +/// +/// Teszt rendelési tétel komplex objektum teszteléshez +/// +public class TestOrderItem +{ + public int Id { get; set; } + + public string ProductName { get; set; } = string.Empty; + + public int Quantity { get; set; } + + public decimal UnitPrice { get; set; } + + public decimal TotalPrice => Quantity * UnitPrice; +} + +/// +/// Teszt rendelés beágyazott objektumokkal +/// +public class TestOrder +{ + public int Id { get; set; } + public string CustomerName { get; set; } = string.Empty; + public DateTime OrderDate { get; set; } + public TestStatus Status { get; set; } + public List Items { get; set; } = []; + public decimal TotalAmount => Items.Sum(x => x.TotalPrice); +} + +/// +/// Megosztott tag objektum teszteléshez +/// +public class SharedTag +{ + public int Id { get; set; } + public string Name { get; set; } = string.Empty; + public string? Description { get; set; } + public DateTime CreatedAt { get; set; } + public bool IsActive { get; set; } +} + +#endregion diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/appsettings.json b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/appsettings.json index 0032257..abf9e66 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/appsettings.json +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/appsettings.json @@ -1,13 +1,36 @@ { - "ConnectionStrings": { - "ConnectionString": "Data Source=195.26.231.218;Initial Catalog=FruitBank_DEV;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=v6f_?xNfg9N1;Trust Server Certificate=True" - }, - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning", - "Microsoft.AspNetCore.SignalR": "Debug" - } - }, - "AllowedHosts": "*" + "ConnectionStrings": { + "ConnectionString": "Data Source=195.26.231.218;Initial Catalog=FruitBank_DEV;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=v6f_?xNfg9N1;Trust Server Certificate=True" + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.SignalR": "Debug" + } + }, + "AyCode": { + "ProjectId": "f9f9383f-c459-4b9f-b0b5-201bd4a9c21b", + "Urls": { + "BaseUrl": "https://localhost:59579", + "ApiBaseUrl": "https://localhost:59579" + }, + "Logger": { + "AppType": "Server", + "LogLevel": "Detail", + "LogWriters": [ + { + "LogLevel": "Detail", + "LogWriterType": "FruitBank.Common.Server.Services.Loggers.ConsoleLogWriter, FruitBank.Common.Server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + }, + //{ + // "LogLevel": "Detail", + // "LogWriterType": "Mango.Nop.Services.Loggers.NopLogWriter, Mango.Nop.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + //} + ] + } + }, + "AllowedHosts": "*" + + } From 0dab07d2e8d887ef6ddeabe33f493ba1005a0c4e Mon Sep 17 00:00:00 2001 From: Loretta Date: Sat, 13 Dec 2025 00:16:58 +0100 Subject: [PATCH 4/6] Add SignalR binary serialization tests for CustomerDto lists - Add endpoints and tests for binary serialization of TestCustomerDto lists to reproduce and diagnose MessagePack interned string index errors - Update appsettings.json to use FruitBank_PROD database - Set AcBinarySerializerOptions in DevAdminSignalRHubSandbox - Extend TestSignalRTags and ITestSignalREndpointServer for new endpoints - Add TestCustomerDto class for serialization tests - Remove obsolete low-level SignalR/HTTP endpoint test files --- .../Nop.Web/App_Data/appsettings.json | 2 +- .../SignalRClientSandbox.cs | 16 +- .../SignalRClientToEndpointTest.cs | 45 ++++ .../SignalREndpointSimpleTests.cs | 210 ----------------- .../SignalREndpointWithNopEnvTests.cs | 218 ------------------ .../DevAdminSignalRHubSandbox.cs | 13 +- .../TestSignalREndpoint.cs | 92 ++++++++ 7 files changed, 154 insertions(+), 442 deletions(-) delete mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointSimpleTests.cs delete mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointWithNopEnvTests.cs diff --git a/Presentation/Nop.Web/App_Data/appsettings.json b/Presentation/Nop.Web/App_Data/appsettings.json index 3fe7c34..3081cc3 100644 --- a/Presentation/Nop.Web/App_Data/appsettings.json +++ b/Presentation/Nop.Web/App_Data/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "ConnectionString": "Data Source=195.26.231.218;Initial Catalog=FruitBank_DEV;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=v6f_?xNfg9N1;Trust Server Certificate=True", + "ConnectionString": "Data Source=195.26.231.218;Initial Catalog=FruitBank_PROD;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=v6f_?xNfg9N1;Trust Server Certificate=True", "DataProvider": "sqlserver", "SQLCommandTimeout": null, "WithNoLock": false diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientSandbox.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientSandbox.cs index 7b33e03..03e2970 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientSandbox.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientSandbox.cs @@ -1,6 +1,5 @@ using AyCode.Core.Loggers; using AyCode.Services.SignalRs; -using Mango.Sandbox.EndPoints; namespace Mango.Sandbox.EndPoints.Tests; @@ -15,12 +14,15 @@ public class SignalRClientSandbox : AcSignalRClientBase { } - protected override SignalResponseJsonMessage DeserializeResponseMsgPack(byte[] messageBytes) - { - var responseJsonMessage = base.DeserializeResponseMsgPack(messageBytes); - Console.WriteLine(responseJsonMessage.ResponseDataJson); - return responseJsonMessage; - } + //protected override ISignalResponseMessage DeserializeResponseMessage(byte[] messageBytes) + //{ + // var responseMessage = base.DeserializeResponseMessage(messageBytes); + // if (responseMessage is SignalResponseJsonMessage jsonMessage) + // { + // Console.WriteLine(jsonMessage.ResponseData); + // } + // return responseMessage; + //} protected override Task MessageReceived(int messageTag, byte[] messageBytes) { diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientToEndpointTest.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientToEndpointTest.cs index 0ba373e..73f4b86 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientToEndpointTest.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientToEndpointTest.cs @@ -454,4 +454,49 @@ public class SignalRClientToEndpointTest } #endregion + + #region Binary Serialization Tesztek - AcBinaryDeserializationException reprodukálása + + /// + /// Reprodukálja a GetMeasuringUsers hibát: AcBinaryDeserializationException: Invalid interned string index + /// A hiba akkor jelentkezik, amikor a szerver Binary formátumban kĂĽldi a választ (List), + /// de a kliens deszerializálásnál az interned string index hibás. + /// + [TestMethod] + public async Task GetAllAsync_CustomerDtoList_BinaryDeserialization_ThrowsInternedStringIndexError() + { + // Act - GetAllAsync>(tag) + // Ez a hĂ­vás a GetMeasuringUsers-höz hasonlĂł forgatĂłkönyvet reprodukál + var result = await _client.GetAllAsync>(TestSignalRTags.GetCustomerDtoList); + + // Assert + Assert.IsNotNull(result); + Assert.IsTrue(result.Count > 0, "Should return at least one CustomerDto"); + + // EllenĹ‘rizzĂĽk, hogy minden CustomerDto megfelelĹ‘en deszerializálĂłdott + foreach (var dto in result) + { + Assert.IsTrue(dto.Id > 0, $"CustomerDto.Id should be > 0, got {dto.Id}"); + Assert.IsFalse(string.IsNullOrEmpty(dto.Username), "CustomerDto.Username should not be empty"); + Assert.IsFalse(string.IsNullOrEmpty(dto.Email), "CustomerDto.Email should not be empty"); + Console.WriteLine($"[GetAllAsync_CustomerDtoList] Id={dto.Id}, Username={dto.Username}, Email={dto.Email}, FullName={dto.FullName}"); + } + } + + /// + /// Nagyobb CustomerDto lista tesztelĂ©se - több interned string a szerializáciĂłban + /// + [TestMethod] + public async Task GetAllAsync_LargeCustomerDtoList_BinaryDeserialization_Success() + { + // Act + var result = await _client.GetAllAsync>(TestSignalRTags.GetLargeCustomerDtoList); + + // Assert + Assert.IsNotNull(result); + Assert.IsTrue(result.Count >= 10, $"Should return at least 10 CustomerDtos, got {result.Count}"); + Console.WriteLine($"[GetAllAsync_LargeCustomerDtoList] Received {result.Count} items"); + } + + #endregion } \ No newline at end of file diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointSimpleTests.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointSimpleTests.cs deleted file mode 100644 index 1520649..0000000 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointSimpleTests.cs +++ /dev/null @@ -1,210 +0,0 @@ -using AyCode.Core.Extensions; -using AyCode.Services.SignalRs; -using FruitBank.Common.SignalRs; -using Mango.Sandbox.EndPoints; -using MessagePack; -using Microsoft.AspNetCore.SignalR.Client; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Text; -using MessagePack.Resolvers; - -namespace Mango.Sandbox.EndPoints.Tests; - -/// -/// Alacsony szintű SignalR tesztek - közvetlen HubConnection használatával. -/// FONTOS: A SANDBOX-ot manuálisan kell elindítani a tesztek futtatása előtt! -/// -[TestClass] -public class SignalREndpointSimpleTests -{ - private static readonly string SandboxUrl = "http://localhost:59579"; - private static readonly string HubUrl = $"{SandboxUrl}/fbHub"; - - [ClassInitialize] - public static async Task ClassInitialize(TestContext context) - { - using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) }; - try - { - var response = await httpClient.GetAsync($"{SandboxUrl}/health"); - Assert.IsTrue(response.IsSuccessStatusCode, - "SANDBOX not running! Start: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579"); - } - catch (Exception ex) - { - Assert.Fail($"SANDBOX not running! {ex.Message}"); - } - } - - #region HTTP Endpoint Tests - - [TestMethod] - public async Task HealthEndpoint_ReturnsSuccess() - { - using var httpClient = new HttpClient(); - var response = await httpClient.GetAsync($"{SandboxUrl}/health"); - Assert.IsTrue(response.IsSuccessStatusCode); - } - - [TestMethod] - public async Task RootEndpoint_ReturnsSandboxIsRunning() - { - using var httpClient = new HttpClient(); - var response = await httpClient.GetStringAsync(SandboxUrl); - Assert.AreEqual("SANDBOX is running!", response); - } - - #endregion - - #region SignalR Connection Tests - - [TestMethod] - public async Task SignalR_Negotiate_ReturnsSuccess() - { - using var httpClient = new HttpClient(); - var response = await httpClient.PostAsync($"{HubUrl}/negotiate?negotiateVersion=1", null); - Assert.IsTrue(response.IsSuccessStatusCode); - } - - [TestMethod] - public async Task SignalR_Connect_Succeeds() - { - var connection = new HubConnectionBuilder() - .WithUrl(HubUrl) - .Build(); - - try - { - await connection.StartAsync(); - Assert.AreEqual(HubConnectionState.Connected, connection.State); - } - finally - { - await connection.StopAsync(); - } - } - - #endregion - - #region Low-Level SignalR Tests - - [TestMethod] - public async Task SignalR_Ping_ReturnsResponse() - { - await SignalRClientHelper(TestSignalRTags.PingTag, "Hello SignalR!", "Ping", response => - { - Assert.IsNotNull(response); - var pingResponse = response.JsonTo(); - Assert.IsNotNull(pingResponse); - Console.WriteLine($"[Ping] Message: {pingResponse.Message}"); - }); - } - - [TestMethod] - public async Task SignalR_Echo_ReturnsEchoedData() - { - var request = new TestEchoRequest { Id = 42, Name = "TestName" }; - await SignalRClientHelper(TestSignalRTags.EchoTag, request, "Echo", response => - { - Assert.IsNotNull(response); - var echoResponse = response.JsonTo(); - Assert.IsNotNull(echoResponse); - Assert.AreEqual(42, echoResponse.Id); - }); - } - - [TestMethod] - public async Task SignalR_GetTestItems_ReturnsItemList() - { - await SignalRClientHelper(TestSignalRTags.GetTestItems, null, "GetTestItems", response => - { - Assert.IsNotNull(response); - var items = response.JsonTo>(); - Assert.IsNotNull(items); - Assert.IsTrue(items.Count > 0); - }); - } - - #endregion - - #region Helper Methods - - private async Task SignalRClientHelper(int tag, object? parameter, string endpointName, Action? validateResponse = null) - { - var connection = new HubConnectionBuilder() - .WithUrl(HubUrl) - .Build(); - - string? receivedJson = null; - var responseReceived = new TaskCompletionSource(); - - connection.On("OnReceiveMessage", (responseTag, data, requestId) => - { - if (data != null && data.Length > 0) - { - try - { - var options = MessagePack.Resolvers.ContractlessStandardResolver.Options; - var response = MessagePackSerializer.Deserialize(data, options); - receivedJson = response?.ResponseData; - } - catch - { - receivedJson = Encoding.UTF8.GetString(data); - } - } - responseReceived.TrySetResult(true); - }); - - try - { - await connection.StartAsync(); - Assert.AreEqual(HubConnectionState.Connected, connection.State); - - byte[]? requestData = CreateRequestData(parameter); - await connection.InvokeAsync("OnReceiveMessage", tag, requestData, (int?)null); - - var completed = await Task.WhenAny(responseReceived.Task, Task.Delay(5000)); - if (completed == responseReceived.Task) - { - validateResponse?.Invoke(receivedJson); - } - else - { - Assert.Fail($"[{endpointName}] Timeout"); - } - } - finally - { - if (connection.State == HubConnectionState.Connected) - await connection.StopAsync(); - } - } - - private static byte[]? CreateRequestData(object? parameter) - { - if (parameter == null) return null; - - var isPrimitive = parameter is string or int or long or double or float or decimal or bool or DateTime; - - if (isPrimitive) - { - var idMessage = new IdMessage(parameter); - return new SignalPostJsonDataMessage(idMessage).ToMessagePack(ContractlessStandardResolver.Options); - } - else - { - return new SignalPostJsonDataMessage(parameter).ToMessagePack(ContractlessStandardResolver.Options); - } - } - - #endregion -} - -/// -/// Wrapper a Task eredményekhez - a szerver Task-ot ad vissza {"Result":...} formátumban -/// -public class TaskResultWrapper -{ - public T? Result { get; set; } -} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointWithNopEnvTests.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointWithNopEnvTests.cs deleted file mode 100644 index 9c11f96..0000000 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalREndpointWithNopEnvTests.cs +++ /dev/null @@ -1,218 +0,0 @@ -using Microsoft.AspNetCore.SignalR.Client; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Diagnostics; -using System.Text; -using System.Text.Json; - -namespace Mango.Sandbox.EndPoints.Tests; - -/// -/// SignalR Endpoint tesztek. -/// FONTOS: A SANDBOX-ot manuálisan kell elindítani a tesztek futtatása előtt! -// Indítás: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579 -/// -[TestClass] -public class SignalREndpointWithNopEnvTests -{ - private static readonly string SandboxUrl = "http://localhost:59579"; - private static readonly string HubUrl = $"{SandboxUrl}/fbHub"; - - // SignalR Tags from FruitBank.Common.SignalRs.SignalRTags - private const int GetMeasuringUsersTag = 70; - private const int GetStockQuantityHistoryDtosTag = 40; - private const int GetStockQuantityHistoryDtosByProductIdTag = 41; - private const int GetShippingDocumentsByShippingIdTag = 60; - private const int GetOrderDtoByIdTag = 21; - private const int GetStockTakingItemsByIdTag = 81; - - //[ClassInitialize] - //public static async Task ClassInitialize(TestContext context) - //{ - // using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) }; - // try - // { - // var response = await httpClient.GetAsync($"{SandboxUrl}/health"); - // Assert.IsTrue(response.IsSuccessStatusCode, - // "SANDBOX is not running! Start it manually: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579"); - // } - // catch (Exception ex) - // { - // Assert.Fail($"SANDBOX is not running! Error: {ex.Message}\n" + - // "Start it manually: dotnet run --project Mango.Sandbox.EndPoints --urls http://localhost:59579"); - // } - //} - - //#region HTTP Endpoint Tests - - //[TestMethod] - //public async Task HealthEndpoint_ReturnsSuccess() - //{ - // using var httpClient = new HttpClient(); - // var response = await httpClient.GetAsync($"{SandboxUrl}/health"); - // Assert.IsTrue(response.IsSuccessStatusCode, $"Health endpoint returned {response.StatusCode}"); - //} - - //[TestMethod] - //public async Task RootEndpoint_ReturnsSandboxIsRunning() - //{ - // using var httpClient = new HttpClient(); - // var response = await httpClient.GetStringAsync(SandboxUrl); - // Assert.AreEqual("SANDBOX is running!", response); - //} - - //#endregion - - //#region SignalR Connection Tests - - //[TestMethod] - //public async Task SignalR_Negotiate_ReturnsSuccess() - //{ - // using var httpClient = new HttpClient(); - // var response = await httpClient.PostAsync($"{HubUrl}/negotiate?negotiateVersion=1", null); - // Assert.IsTrue(response.IsSuccessStatusCode, $"SignalR negotiate returned {response.StatusCode}"); - //} - - //[TestMethod] - //public async Task SignalR_Connect_Succeeds() - //{ - // var connection = new HubConnectionBuilder() - // .WithUrl(HubUrl) - // .Build(); - - // try - // { - // await connection.StartAsync(); - // Assert.AreEqual(HubConnectionState.Connected, connection.State); - // } - // finally - // { - // await connection.StopAsync(); - // } - //} - - //#endregion - - //#region SignalR Business Endpoint Tests - - //[TestMethod] - //public async Task SignalR_GetMeasuringUsers_ReturnsJson() - //{ - // await TestSignalREndpoint(GetMeasuringUsersTag, null, "GetMeasuringUsers"); - //} - - //[TestMethod] - //public async Task SignalR_GetStockQuantityHistoryDtos_ReturnsJson() - //{ - // await TestSignalREndpoint(GetStockQuantityHistoryDtosTag, null, "GetStockQuantityHistoryDtos"); - //} - - //[TestMethod] - //public async Task SignalR_GetStockQuantityHistoryDtosByProductId_ReturnsJson() - //{ - // // ProductId = 10 - // await TestSignalREndpoint(GetStockQuantityHistoryDtosByProductIdTag, 10, "GetStockQuantityHistoryDtosByProductId"); - //} - - //[TestMethod] - //public async Task SignalR_GetShippingDocumentsByShippingId_ReturnsJson() - //{ - // // ShippingId = 5 - // await TestSignalREndpoint(GetShippingDocumentsByShippingIdTag, 5, "GetShippingDocumentsByShippingId"); - //} - - //[TestMethod] - //public async Task SignalR_GetOrderDtoById_ReturnsJson() - //{ - // // OrderId = 15 - // await TestSignalREndpoint(GetOrderDtoByIdTag, 15, "GetOrderDtoById"); - //} - - //[TestMethod] - //public async Task SignalR_GetStockTakingItemsById_ReturnsJson() - //{ - // // StockTakingItemId = 200 - // await TestSignalREndpoint(GetStockTakingItemsByIdTag, 200, "GetStockTakingItemsById"); - //} - - //#endregion - - //#region Helper Methods - - //private async Task TestSignalREndpoint(int tag, object? parameter, string endpointName) - //{ - // var connection = new HubConnectionBuilder() - // .WithUrl(HubUrl) - // .Build(); - - // string? receivedJson = null; - // int receivedTag = -1; - // var responseReceived = new TaskCompletionSource(); - - // connection.On("ReceiveMessage", (responseTag, data) => - // { - // receivedTag = responseTag; - // if (data != null && data.Length > 0) - // { - // receivedJson = Encoding.UTF8.GetString(data); - // } - // responseReceived.TrySetResult(true); - // }); - - // try - // { - // await connection.StartAsync(); - // Assert.AreEqual(HubConnectionState.Connected, connection.State, $"Failed to connect to SignalR hub for {endpointName}"); - - // // Készítsük el a request data-t - // byte[] requestData = parameter != null - // ? Encoding.UTF8.GetBytes(JsonSerializer.Serialize(parameter)) - // : Array.Empty(); - - // await connection.InvokeAsync("ReceiveMessage", tag, requestData); - - // var completed = await Task.WhenAny(responseReceived.Task, Task.Delay(15000)); - - // if (completed == responseReceived.Task) - // { - // Console.WriteLine($"[{endpointName}] Response tag: {receivedTag}"); - // Console.WriteLine($"[{endpointName}] Response JSON: {receivedJson?.Substring(0, Math.Min(500, receivedJson?.Length ?? 0))}..."); - - // // Ellenőrizzük, hogy valid JSON-e (ha van adat) - // if (!string.IsNullOrEmpty(receivedJson)) - // { - // try - // { - // var jsonDoc = JsonDocument.Parse(receivedJson); - // Assert.IsTrue( - // jsonDoc.RootElement.ValueKind == JsonValueKind.Array || - // jsonDoc.RootElement.ValueKind == JsonValueKind.Object || - // jsonDoc.RootElement.ValueKind == JsonValueKind.Null, - // $"[{endpointName}] Response is not a valid JSON"); - // } - // catch (JsonException ex) - // { - // Assert.Fail($"[{endpointName}] Invalid JSON response: {ex.Message}"); - // } - // } - // } - // else - // { - // Assert.AreEqual(HubConnectionState.Connected, connection.State, - // $"[{endpointName}] Connection was closed - check SANDBOX logs for DI errors"); - // } - // } - // catch (Exception ex) - // { - // Assert.Fail($"[{endpointName}] SignalR error: {ex.Message}. Check SANDBOX logs for missing DI registrations."); - // } - // finally - // { - // if (connection.State == HubConnectionState.Connected) - // { - // await connection.StopAsync(); - // } - // } - //} - // - //#endregion -} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/DevAdminSignalRHubSandbox.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/DevAdminSignalRHubSandbox.cs index 97c4ab5..00adf64 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/DevAdminSignalRHubSandbox.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/DevAdminSignalRHubSandbox.cs @@ -1,4 +1,5 @@ using AyCode.Core.Enums; +using AyCode.Core.Extensions; using AyCode.Core.Loggers; using AyCode.Models.Server.DynamicMethods; using AyCode.Services.Server.SignalRs; @@ -23,16 +24,16 @@ public class DevAdminSignalRHubSandbox : AcWebSignalRHubWithSessionBase logWriters) : base(configuration, new Logger(logWriters.ToArray())) { + SerializerOptions = new AcBinarySerializerOptions(); DynamicMethodCallModels.Add(new AcDynamicMethodCallModel(testSignalREndpoint)); - } - protected override Task SendMessageToClient(IAcSignalRHubItemServer sendTo, int messageTag, ISignalRMessage message, int? requestId = null) - { - Console.WriteLine(((SignalResponseJsonMessage)message).ResponseDataJson); + //protected override Task SendMessageToClient(IAcSignalRHubItemServer sendTo, int messageTag, ISignalRMessage message, int? requestId = null) + //{ + // Console.WriteLine(((SignalResponseJsonMessage)message).ResponseDataJson); - return base.SendMessageToClient(sendTo, messageTag, message, requestId); - } + // return base.SendMessageToClient(sendTo, messageTag, message, requestId); + //} } // =========================================== diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/TestSignalREndpoint.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/TestSignalREndpoint.cs index 80fea18..3659e92 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/TestSignalREndpoint.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/TestSignalREndpoint.cs @@ -396,6 +396,75 @@ public class TestSignalREndpoint : ITestSignalREndpointServer } #endregion + + #region Binary Serialization Tesztek - CustomerDto reprodukálás + + /// + /// CustomerDto lista visszaadása - reprodukálja a GetMeasuringUsers forgatókönyvet + /// + [SignalR(TestSignalRTags.GetCustomerDtoList)] + public Task> GetCustomerDtoList() + { + var customers = new List + { + new() + { + Id = 1, + Username = "user1", + Email = "user1@test.com", + FirstName = "First1", + LastName = "Last1", + RegisteredInStoreId = 1, + Deleted = false + }, + new() + { + Id = 2, + Username = "user2", + Email = "user2@test.com", + FirstName = "First2", + LastName = "Last2", + RegisteredInStoreId = 1, + Deleted = false + }, + new() + { + Id = 3, + Username = "user3", + Email = "user3@test.com", + FirstName = "First3", + LastName = "Last3", + RegisteredInStoreId = 2, + Deleted = true + } + }; + return Task.FromResult(customers); + } + + /// + /// Nagyobb CustomerDto lista - több interned string a szerializációban + /// + [SignalR(TestSignalRTags.GetLargeCustomerDtoList)] + public Task> GetLargeCustomerDtoList() + { + var customers = new List(); + for (int i = 1; i <= 30; i++) + { + customers.Add(new TestCustomerDto + { + Id = i, + Username = $"user{i}", + Email = $"user{i}@test.com", + FirstName = $"FirstName{i}", + LastName = $"LastName{i}", + RegisteredInStoreId = (i % 3) + 1, + Deleted = i % 5 == 0 + }); + } + return Task.FromResult(customers); + } + + #endregion } /// @@ -449,6 +518,10 @@ public static class TestSignalRTags public const int DtoAndListParam = 9061; public const int ThreeComplexParams = 9062; public const int FiveParams = 9063; + + // Binary serialization tesztek - CustomerDto reprodukálás + public const int GetCustomerDtoList = 9070; + public const int GetLargeCustomerDtoList = 9071; } /// @@ -500,6 +573,10 @@ public interface ITestSignalREndpointServer Task HandleDtoAndList(TestOrderItem item, List numbers); Task HandleThreeComplexParams(TestOrderItem item, List tags, SharedTag sharedTag); Task HandleFiveParams(int a, string b, bool c, Guid d, decimal e); + + // Binary serialization tesztek - CustomerDto reprodukálás + Task> GetCustomerDtoList(); + Task> GetLargeCustomerDtoList(); } #region DTOs @@ -584,4 +661,19 @@ public class SharedTag public bool IsActive { get; set; } } +/// +/// Teszt CustomerDto a felhasználók teszteléséhez +/// +public class TestCustomerDto +{ + public int Id { get; set; } + public string Username { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; + public string FirstName { get; set; } = string.Empty; + public string LastName { get; set; } = string.Empty; + public string FullName => $"{LastName} {FirstName}"; + public int RegisteredInStoreId { get; set; } + public bool Deleted { get; set; } +} + #endregion From 4e672b4264715b78f57d8275b6ef2a4b542a6e2a Mon Sep 17 00:00:00 2001 From: Loretta Date: Sat, 13 Dec 2025 12:32:14 +0100 Subject: [PATCH 5/6] Remove SignalR test client and disable Null plugin managers - Deleted Mango.Sandbox.SignalRTestClient project and all related files from the solution. - Switched appsettings.json connection string to use FruitBank_DEV. - Cleaned up project references in Mango.Sandbox.EndPoints and its test project. - Commented out all Null* plugin manager/service classes in Mango.Sandbox.EndPoints.Services. --- FruitBank.sln | 15 ------ .../Nop.Web/App_Data/appsettings.json | 2 +- .../Mango.Sandbox.EndPoints.Tests.csproj | 48 +------------------ .../Mango.Sandbox.EndPoints.csproj | 4 -- .../NullAuthenticationPluginManager.cs | 38 +++++++-------- .../Services/NullDiscountPluginManager.cs | 28 +++++------ .../Services/NullExchangeRatePluginManager.cs | 36 +++++++------- .../NullExternalAuthenticationService.cs | 40 ++++++++-------- ...lMultiFactorAuthenticationPluginManager.cs | 42 ++++++++-------- .../Services/NullPaymentPluginManager.cs | 46 +++++++++--------- .../Services/NullPickupPluginManager.cs | 38 +++++++-------- .../Services/NullSearchPluginManager.cs | 38 +++++++-------- .../Services/NullShippingPluginManager.cs | 46 +++++++++--------- .../Services/NullTaxPluginManager.cs | 38 +++++++-------- .../Services/NullWidgetPluginManager.cs | 38 +++++++-------- .../Mango.Sandbox.SignalRTestClient.csproj | 11 ----- .../Program.cs | 48 ------------------- 17 files changed, 217 insertions(+), 339 deletions(-) delete mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Mango.Sandbox.SignalRTestClient.csproj delete mode 100644 Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Program.cs diff --git a/FruitBank.sln b/FruitBank.sln index 4220d61..7c62890 100644 --- a/FruitBank.sln +++ b/FruitBank.sln @@ -91,8 +91,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mango.Sandbox.EndPoints", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mango.Sandbox.EndPoints.Tests", "Tests\Mango.Sandbox\Mango.Sandbox.EndPoints.Tests\Mango.Sandbox.EndPoints.Tests.csproj", "{B8491E5C-DBB5-1594-052E-744D78D7A4DE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mango.Sandbox.SignalRTestClient", "Tests\Mango.Sandbox\Mango.Sandbox.SignalRTestClient\Mango.Sandbox.SignalRTestClient.csproj", "{B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -537,18 +535,6 @@ Global {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Release|Mixed Platforms.Build.0 = Release|Any CPU {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Release|x86.ActiveCfg = Release|Any CPU {B8491E5C-DBB5-1594-052E-744D78D7A4DE}.Release|x86.Build.0 = Release|Any CPU - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Debug|x86.ActiveCfg = Debug|Any CPU - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Debug|x86.Build.0 = Debug|Any CPU - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Release|Any CPU.Build.0 = Release|Any CPU - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Release|x86.ActiveCfg = Release|Any CPU - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -594,7 +580,6 @@ Global {EE44B558-F1DA-433A-BD4C-D275986A4679} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {D22DB269-2490-4A3D-B0B4-2CD2BB626F9C} = {E8FC6874-E230-468A-9685-4747354B92FF} {B8491E5C-DBB5-1594-052E-744D78D7A4DE} = {E8FC6874-E230-468A-9685-4747354B92FF} - {B2FBDB33-24F4-E0B1-0EA7-7939A387F88F} = {E8FC6874-E230-468A-9685-4747354B92FF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {EE72A8B2-332A-4175-9319-6726D36E9D25} diff --git a/Presentation/Nop.Web/App_Data/appsettings.json b/Presentation/Nop.Web/App_Data/appsettings.json index 3081cc3..3fe7c34 100644 --- a/Presentation/Nop.Web/App_Data/appsettings.json +++ b/Presentation/Nop.Web/App_Data/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "ConnectionString": "Data Source=195.26.231.218;Initial Catalog=FruitBank_PROD;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=v6f_?xNfg9N1;Trust Server Certificate=True", + "ConnectionString": "Data Source=195.26.231.218;Initial Catalog=FruitBank_DEV;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=v6f_?xNfg9N1;Trust Server Certificate=True", "DataProvider": "sqlserver", "SQLCommandTimeout": null, "WithNoLock": false diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/Mango.Sandbox.EndPoints.Tests.csproj b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/Mango.Sandbox.EndPoints.Tests.csproj index ce96e04..bfbf974 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/Mango.Sandbox.EndPoints.Tests.csproj +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/Mango.Sandbox.EndPoints.Tests.csproj @@ -19,62 +19,18 @@ + - + ..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Core.dll - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Core.Server.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Core.Tests.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Database.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Database.Tests.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Entities.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Entities.Server.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.Server.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Models.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Models.Server.dll - ..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Services.dll - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.Tests.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Services.Tests.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll - - - ..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Utils.Server.dll - ..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\FruitBank.Common.dll diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Mango.Sandbox.EndPoints.csproj b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Mango.Sandbox.EndPoints.csproj index a8a0166..57aa986 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Mango.Sandbox.EndPoints.csproj +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Mango.Sandbox.EndPoints.csproj @@ -84,10 +84,6 @@ - - - - diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullAuthenticationPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullAuthenticationPluginManager.cs index d65a42e..c449f9c 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullAuthenticationPluginManager.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullAuthenticationPluginManager.cs @@ -1,30 +1,30 @@ using Nop.Core.Domain.Customers; -using Nop.Services.Authentication.External; -using Nop.Services.Plugins; +//using Nop.Services.Authentication.External; +//using Nop.Services.Plugins; namespace Mango.Sandbox.EndPoints.Services; -public class NullAuthenticationPluginManager : IAuthenticationPluginManager -{ - public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +//public class NullAuthenticationPluginManager : IAuthenticationPluginManager +//{ +// public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public bool IsPluginActive(IExternalAuthenticationMethod plugin, List systemNames) => false; +// public bool IsPluginActive(IExternalAuthenticationMethod plugin, List systemNames) => false; - public bool IsPluginActive(IExternalAuthenticationMethod plugin) => false; +// public bool IsPluginActive(IExternalAuthenticationMethod plugin) => false; - public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(false); +// public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(false); - public Task GetPluginLogoUrlAsync(IExternalAuthenticationMethod plugin) - => Task.FromResult(string.Empty); -} +// public Task GetPluginLogoUrlAsync(IExternalAuthenticationMethod plugin) +// => Task.FromResult(string.Empty); +//} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullDiscountPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullDiscountPluginManager.cs index 5361a93..d33b4bb 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullDiscountPluginManager.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullDiscountPluginManager.cs @@ -1,26 +1,26 @@ using Nop.Core.Domain.Customers; using Nop.Core.Domain.Discounts; -using Nop.Services.Discounts; -using Nop.Services.Plugins; +//using Nop.Services.Discounts; +//using Nop.Services.Plugins; namespace Mango.Sandbox.EndPoints.Services; /// /// Null implementation of IDiscountPluginManager for SANDBOX /// -public class NullDiscountPluginManager : IDiscountPluginManager -{ - public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +//public class NullDiscountPluginManager : IDiscountPluginManager +//{ +// public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public bool IsPluginActive(IDiscountRequirementRule plugin, List systemNames) => false; +// public bool IsPluginActive(IDiscountRequirementRule plugin, List systemNames) => false; - public Task GetPluginLogoUrlAsync(IDiscountRequirementRule plugin) - => Task.FromResult(string.Empty); -} +// public Task GetPluginLogoUrlAsync(IDiscountRequirementRule plugin) +// => Task.FromResult(string.Empty); +//} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExchangeRatePluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExchangeRatePluginManager.cs index b87ed19..5bd7fe6 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExchangeRatePluginManager.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExchangeRatePluginManager.cs @@ -1,31 +1,31 @@ using Nop.Core.Domain.Customers; -using Nop.Core.Domain.Directory; -using Nop.Services.Directory; -using Nop.Services.Plugins; +//using Nop.Core.Domain.Directory; +//using Nop.Services.Directory; +//using Nop.Services.Plugins; namespace Mango.Sandbox.EndPoints.Services; /// /// Null implementation of IExchangeRatePluginManager for SANDBOX /// -public class NullExchangeRatePluginManager : IExchangeRatePluginManager -{ - public Task LoadPrimaryPluginAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +//public class NullExchangeRatePluginManager : IExchangeRatePluginManager +//{ +// public Task LoadPrimaryPluginAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public bool IsPluginActive(IExchangeRateProvider exchangeRateProvider) => false; +// public bool IsPluginActive(IExchangeRateProvider exchangeRateProvider) => false; - public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +// public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public bool IsPluginActive(IExchangeRateProvider plugin, List systemNames) => false; +// public bool IsPluginActive(IExchangeRateProvider plugin, List systemNames) => false; - public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task GetPluginLogoUrlAsync(IExchangeRateProvider plugin) - => Task.FromResult(string.Empty); -} +// public Task GetPluginLogoUrlAsync(IExchangeRateProvider plugin) +// => Task.FromResult(string.Empty); +//} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExternalAuthenticationService.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExternalAuthenticationService.cs index 5413328..a51e754 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExternalAuthenticationService.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullExternalAuthenticationService.cs @@ -1,35 +1,35 @@ using Microsoft.AspNetCore.Mvc; using Nop.Core.Domain.Customers; -using Nop.Services.Authentication.External; +//using Nop.Services.Authentication.External; namespace Mango.Sandbox.EndPoints.Services; /// /// Null implementation of IExternalAuthenticationService for SANDBOX /// -public class NullExternalAuthenticationService : IExternalAuthenticationService -{ - public Task AuthenticateAsync(ExternalAuthenticationParameters parameters, string returnUrl = null!) - => Task.FromResult(new NotFoundResult()); +//public class NullExternalAuthenticationService : IExternalAuthenticationService +//{ +// public Task AuthenticateAsync(ExternalAuthenticationParameters parameters, string returnUrl = null!) +// => Task.FromResult(new NotFoundResult()); - public Task GetExternalAuthenticationRecordByIdAsync(int externalAuthenticationRecordId) - => Task.FromResult(null); +// public Task GetExternalAuthenticationRecordByIdAsync(int externalAuthenticationRecordId) +// => Task.FromResult(null); - public Task> GetCustomerExternalAuthenticationRecordsAsync(Customer customer) - => Task.FromResult>(new List()); +// public Task> GetCustomerExternalAuthenticationRecordsAsync(Customer customer) +// => Task.FromResult>(new List()); - public Task DeleteExternalAuthenticationRecordAsync(ExternalAuthenticationRecord externalAuthenticationRecord) - => Task.CompletedTask; +// public Task DeleteExternalAuthenticationRecordAsync(ExternalAuthenticationRecord externalAuthenticationRecord) +// => Task.CompletedTask; - public Task GetExternalAuthenticationRecordByExternalAuthenticationParametersAsync(ExternalAuthenticationParameters parameters) - => Task.FromResult(null); +// public Task GetExternalAuthenticationRecordByExternalAuthenticationParametersAsync(ExternalAuthenticationParameters parameters) +// => Task.FromResult(null); - public Task AssociateExternalAccountWithUserAsync(Customer customer, ExternalAuthenticationParameters parameters) - => Task.CompletedTask; +// public Task AssociateExternalAccountWithUserAsync(Customer customer, ExternalAuthenticationParameters parameters) +// => Task.CompletedTask; - public Task GetUserByExternalAuthenticationParametersAsync(ExternalAuthenticationParameters parameters) - => Task.FromResult(null); +// public Task GetUserByExternalAuthenticationParametersAsync(ExternalAuthenticationParameters parameters) +// => Task.FromResult(null); - public Task RemoveAssociationAsync(ExternalAuthenticationParameters parameters) - => Task.CompletedTask; -} +// public Task RemoveAssociationAsync(ExternalAuthenticationParameters parameters) +// => Task.CompletedTask; +//} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullMultiFactorAuthenticationPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullMultiFactorAuthenticationPluginManager.cs index ed080be..922e4f5 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullMultiFactorAuthenticationPluginManager.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullMultiFactorAuthenticationPluginManager.cs @@ -1,36 +1,36 @@ using Nop.Core.Domain.Customers; -using Nop.Services.Authentication.MultiFactor; -using Nop.Services.Plugins; +//using Nop.Services.Authentication.MultiFactor; +//using Nop.Services.Plugins; namespace Mango.Sandbox.EndPoints.Services; /// /// Null implementation of IMultiFactorAuthenticationPluginManager for SANDBOX /// -public class NullMultiFactorAuthenticationPluginManager : IMultiFactorAuthenticationPluginManager -{ - public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +//public class NullMultiFactorAuthenticationPluginManager : IMultiFactorAuthenticationPluginManager +//{ +// public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task HasActivePluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult(false); +// public Task HasActivePluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult(false); - public bool IsPluginActive(IMultiFactorAuthenticationMethod plugin) => false; +// public bool IsPluginActive(IMultiFactorAuthenticationMethod plugin) => false; - public bool IsPluginActive(IMultiFactorAuthenticationMethod plugin, List systemNames) => false; +// public bool IsPluginActive(IMultiFactorAuthenticationMethod plugin, List systemNames) => false; - public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(false); +// public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(false); - public Task GetPluginLogoUrlAsync(IMultiFactorAuthenticationMethod plugin) - => Task.FromResult(string.Empty); -} +// public Task GetPluginLogoUrlAsync(IMultiFactorAuthenticationMethod plugin) +// => Task.FromResult(string.Empty); +//} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPaymentPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPaymentPluginManager.cs index 23db962..b17d96e 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPaymentPluginManager.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPaymentPluginManager.cs @@ -1,36 +1,36 @@ using Nop.Core.Domain.Customers; -using Nop.Services.Payments; -using Nop.Services.Plugins; +//using Nop.Services.Payments; +//using Nop.Services.Plugins; namespace Mango.Sandbox.EndPoints.Services; -public class NullPaymentPluginManager : IPaymentPluginManager -{ - public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +//public class NullPaymentPluginManager : IPaymentPluginManager +//{ +// public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, int filterByCountryId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, int filterByCountryId = 0) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public bool IsPluginActive(IPaymentMethod plugin, List systemNames) => false; +// public bool IsPluginActive(IPaymentMethod plugin, List systemNames) => false; - public bool IsPluginActive(IPaymentMethod plugin) => false; +// public bool IsPluginActive(IPaymentMethod plugin) => false; - public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(false); +// public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(false); - public Task GetPluginLogoUrlAsync(IPaymentMethod plugin) - => Task.FromResult(string.Empty); +// public Task GetPluginLogoUrlAsync(IPaymentMethod plugin) +// => Task.FromResult(string.Empty); - public Task> GetRestrictedCountryIdsAsync(IPaymentMethod paymentMethod) - => Task.FromResult>(new List()); +// public Task> GetRestrictedCountryIdsAsync(IPaymentMethod paymentMethod) +// => Task.FromResult>(new List()); - public Task SaveRestrictedCountriesAsync(IPaymentMethod paymentMethod, IList countryIds) - => Task.CompletedTask; -} +// public Task SaveRestrictedCountriesAsync(IPaymentMethod paymentMethod, IList countryIds) +// => Task.CompletedTask; +//} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPickupPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPickupPluginManager.cs index 6e375ad..7faa52e 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPickupPluginManager.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullPickupPluginManager.cs @@ -1,30 +1,30 @@ using Nop.Core.Domain.Customers; -using Nop.Services.Plugins; -using Nop.Services.Shipping.Pickup; +//using Nop.Services.Plugins; +//using Nop.Services.Shipping.Pickup; namespace Mango.Sandbox.EndPoints.Services; -public class NullPickupPluginManager : IPickupPluginManager -{ - public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +//public class NullPickupPluginManager : IPickupPluginManager +//{ +// public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, string filterByCountryId = null!) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, string filterByCountryId = null!) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public bool IsPluginActive(IPickupPointProvider plugin, List systemNames) => false; +// public bool IsPluginActive(IPickupPointProvider plugin, List systemNames) => false; - public bool IsPluginActive(IPickupPointProvider plugin) => false; +// public bool IsPluginActive(IPickupPointProvider plugin) => false; - public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(false); +// public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(false); - public Task GetPluginLogoUrlAsync(IPickupPointProvider plugin) - => Task.FromResult(string.Empty); -} +// public Task GetPluginLogoUrlAsync(IPickupPointProvider plugin) +// => Task.FromResult(string.Empty); +//} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullSearchPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullSearchPluginManager.cs index d9c496b..fa29bb1 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullSearchPluginManager.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullSearchPluginManager.cs @@ -1,33 +1,33 @@ using Nop.Core.Domain.Customers; -using Nop.Services.Catalog; -using Nop.Services.Plugins; +//using Nop.Services.Catalog; +//using Nop.Services.Plugins; namespace Mango.Sandbox.EndPoints.Services; /// /// Null implementation of ISearchPluginManager for SANDBOX /// -public class NullSearchPluginManager : ISearchPluginManager -{ - public Task LoadPrimaryPluginAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +//public class NullSearchPluginManager : ISearchPluginManager +//{ +// public Task LoadPrimaryPluginAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public bool IsPluginActive(ISearchProvider searchProvider) => false; +// public bool IsPluginActive(ISearchProvider searchProvider) => false; - public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(false); +// public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(false); - public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +// public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public bool IsPluginActive(ISearchProvider plugin, List systemNames) => false; +// public bool IsPluginActive(ISearchProvider plugin, List systemNames) => false; - public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task GetPluginLogoUrlAsync(ISearchProvider plugin) - => Task.FromResult(string.Empty); -} +// public Task GetPluginLogoUrlAsync(ISearchProvider plugin) +// => Task.FromResult(string.Empty); +//} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullShippingPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullShippingPluginManager.cs index d2980f5..ae36f18 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullShippingPluginManager.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullShippingPluginManager.cs @@ -1,36 +1,36 @@ using Nop.Core.Domain.Customers; -using Nop.Services.Plugins; -using Nop.Services.Shipping; +//using Nop.Services.Plugins; +//using Nop.Services.Shipping; namespace Mango.Sandbox.EndPoints.Services; -public class NullShippingPluginManager : IShippingPluginManager -{ - public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +//public class NullShippingPluginManager : IShippingPluginManager +//{ +// public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, string filterByCountryId = null!) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, string filterByCountryId = null!) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public bool IsPluginActive(IShippingRateComputationMethod plugin, List systemNames) => false; +// public bool IsPluginActive(IShippingRateComputationMethod plugin, List systemNames) => false; - public bool IsPluginActive(IShippingRateComputationMethod plugin) => false; +// public bool IsPluginActive(IShippingRateComputationMethod plugin) => false; - public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(false); +// public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(false); - public Task GetPluginLogoUrlAsync(IShippingRateComputationMethod plugin) - => Task.FromResult(string.Empty); +// public Task GetPluginLogoUrlAsync(IShippingRateComputationMethod plugin) +// => Task.FromResult(string.Empty); - public Task> GetRestrictedCountryIdsAsync(IShippingRateComputationMethod shippingMethod) - => Task.FromResult>(new List()); +// public Task> GetRestrictedCountryIdsAsync(IShippingRateComputationMethod shippingMethod) +// => Task.FromResult>(new List()); - public Task SaveRestrictedCountriesAsync(IShippingRateComputationMethod shippingMethod, IList countryIds) - => Task.CompletedTask; -} +// public Task SaveRestrictedCountriesAsync(IShippingRateComputationMethod shippingMethod, IList countryIds) +// => Task.CompletedTask; +//} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullTaxPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullTaxPluginManager.cs index f105bec..af3bd27 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullTaxPluginManager.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullTaxPluginManager.cs @@ -1,30 +1,30 @@ using Nop.Core.Domain.Customers; -using Nop.Services.Plugins; -using Nop.Services.Tax; +//using Nop.Services.Plugins; +//using Nop.Services.Tax; namespace Mango.Sandbox.EndPoints.Services; -public class NullTaxPluginManager : ITaxPluginManager -{ - public Task LoadPrimaryPluginAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +//public class NullTaxPluginManager : ITaxPluginManager +//{ +// public Task LoadPrimaryPluginAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +// public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public bool IsPluginActive(ITaxProvider plugin, List systemNames) => false; +// public bool IsPluginActive(ITaxProvider plugin, List systemNames) => false; - public bool IsPluginActive(ITaxProvider plugin) => false; +// public bool IsPluginActive(ITaxProvider plugin) => false; - public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(false); +// public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(false); - public Task GetPluginLogoUrlAsync(ITaxProvider plugin) - => Task.FromResult(string.Empty); -} +// public Task GetPluginLogoUrlAsync(ITaxProvider plugin) +// => Task.FromResult(string.Empty); +//} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullWidgetPluginManager.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullWidgetPluginManager.cs index c687b92..f9453a4 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullWidgetPluginManager.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints/Services/NullWidgetPluginManager.cs @@ -1,30 +1,30 @@ using Nop.Core.Domain.Customers; -using Nop.Services.Cms; -using Nop.Services.Plugins; +//using Nop.Services.Cms; +//using Nop.Services.Plugins; namespace Mango.Sandbox.EndPoints.Services; -public class NullWidgetPluginManager : IWidgetPluginManager -{ - public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, string widgetZone = null!) - => Task.FromResult>(new List()); +//public class NullWidgetPluginManager : IWidgetPluginManager +//{ +// public Task> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, string widgetZone = null!) +// => Task.FromResult>(new List()); - public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(null); +// public Task LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(null); - public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) - => Task.FromResult>(new List()); +// public Task> LoadActivePluginsAsync(List systemNames, Customer? customer = null, int storeId = 0) +// => Task.FromResult>(new List()); - public bool IsPluginActive(IWidgetPlugin plugin, List systemNames) => false; +// public bool IsPluginActive(IWidgetPlugin plugin, List systemNames) => false; - public bool IsPluginActive(IWidgetPlugin plugin) => false; +// public bool IsPluginActive(IWidgetPlugin plugin) => false; - public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) - => Task.FromResult(false); +// public Task IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0) +// => Task.FromResult(false); - public Task GetPluginLogoUrlAsync(IWidgetPlugin plugin) - => Task.FromResult(string.Empty); -} +// public Task GetPluginLogoUrlAsync(IWidgetPlugin plugin) +// => Task.FromResult(string.Empty); +//} diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Mango.Sandbox.SignalRTestClient.csproj b/Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Mango.Sandbox.SignalRTestClient.csproj deleted file mode 100644 index bd8e06d..0000000 --- a/Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Mango.Sandbox.SignalRTestClient.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - Exe - net9.0 - enable - enable - - - - - diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Program.cs b/Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Program.cs deleted file mode 100644 index a0dcd51..0000000 --- a/Tests/Mango.Sandbox/Mango.Sandbox.SignalRTestClient/Program.cs +++ /dev/null @@ -1,48 +0,0 @@ -// SignalR Test Client - teszteli a SANDBOX kapcsolatot -using Microsoft.AspNetCore.SignalR.Client; -using System.Text.Json; - -Console.WriteLine("=== SANDBOX SignalR Test Client ==="); - -var hubUrl = "http://localhost:59579/fbHub"; -Console.WriteLine($"Connecting to: {hubUrl}"); - -var connection = new HubConnectionBuilder() - .WithUrl(hubUrl) - .WithAutomaticReconnect() - .Build(); - -connection.On("ReceiveMessage", (tag, data) => -{ - Console.WriteLine($"Received message - Tag: {tag}, Data length: {data?.Length ?? 0}"); -}); - -try -{ - await connection.StartAsync(); - Console.WriteLine($"Connected! State: {connection.State}"); - - // Teszt: GetMeasuringUsers (tag 70) hívása - Console.WriteLine("\nTesting GetMeasuringUsers (tag 70)..."); - - // A SignalR metódus hívása - a szerver "ReceiveMessage" metódusát hívjuk - // MessagePack formátumban küldjük az adatot - var requestData = new { Tag = 70, Data = Array.Empty() }; - - await connection.InvokeAsync("ReceiveMessage", 70, Array.Empty()); - - Console.WriteLine("Message sent! Waiting for response..."); - await Task.Delay(3000); - - Console.WriteLine("\nTest completed!"); -} -catch (Exception ex) -{ - Console.WriteLine($"Error: {ex.Message}"); - Console.WriteLine($"Stack: {ex.StackTrace}"); -} -finally -{ - await connection.StopAsync(); - Console.WriteLine("Disconnected."); -} From e33fae85f3096161bca4c092e9e28915c85f2219 Mon Sep 17 00:00:00 2001 From: Loretta Date: Sun, 14 Dec 2025 01:45:06 +0100 Subject: [PATCH 6/6] Refactor tests to use GetResponseData for responses Update SignalRClientToEndpointTest to use the generic GetResponseData() method instead of directly accessing the ResponseData property. This improves type safety and ensures consistent handling of response data across all relevant test cases. --- .../SignalRClientToEndpointTest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientToEndpointTest.cs b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientToEndpointTest.cs index 73f4b86..5ffcad1 100644 --- a/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientToEndpointTest.cs +++ b/Tests/Mango.Sandbox/Mango.Sandbox.EndPoints.Tests/SignalRClientToEndpointTest.cs @@ -66,7 +66,7 @@ public class SignalRClientToEndpointTest // Act - GetAllAsync(tag, callback) await _client.GetAllAsync>(TestSignalRTags.GetTestItems, response => { - receivedItems = response.ResponseData; + receivedItems = response.GetResponseData>(); tcs.SetResult(true); return Task.CompletedTask; }); @@ -188,7 +188,7 @@ public class SignalRClientToEndpointTest // Act - GetByIdAsync(tag, callback, id) await _client.GetByIdAsync(TestSignalRTags.SingleIntParam, response => { - receivedResult = response.ResponseData; + receivedResult = response.GetResponseData(); tcs.SetResult(true); return Task.CompletedTask; }, 100); @@ -249,7 +249,7 @@ public class SignalRClientToEndpointTest // Act - GetByIdAsync(tag, callback, ids[]) await _client.GetByIdAsync(TestSignalRTags.TwoIntParams, response => { - receivedResult = response.ResponseData; + receivedResult = response.GetResponseData(); tcs.SetResult(true); return Task.CompletedTask; }, new object[] { 5, 7 }); @@ -297,7 +297,7 @@ public class SignalRClientToEndpointTest // Act - GetAllAsync(tag, callback, contextParams[]) await _client.GetAllAsync(TestSignalRTags.IntArrayParam, response => { - receivedResult = response.ResponseData; + receivedResult = response.GetResponseData(); tcs.SetResult(true); return Task.CompletedTask; }, new object[] { new[] { 5, 10, 15 } }); @@ -393,7 +393,7 @@ public class SignalRClientToEndpointTest // Act - PostDataAsync(tag, data, callback) await _client.PostDataAsync(TestSignalRTags.EchoTag, request, response => { - receivedResult = response.ResponseData; + receivedResult = response.GetResponseData(); tcs.SetResult(true); return Task.CompletedTask; });