This commit is contained in:
Adam 2025-12-14 13:37:37 +01:00
commit 996d0794de
26 changed files with 2113 additions and 8 deletions

View File

@ -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,10 @@ 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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -507,6 +511,30 @@ 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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -550,6 +578,8 @@ 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}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EE72A8B2-332A-4175-9319-6726D36E9D25}

View File

@ -19,10 +19,10 @@
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Keys" Version="1.2.4" />
<PackageReference Include="Azure.Identity" Version="1.13.1" />
<PackageReference Include="Humanizer" Version="2.14.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="9.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="9.0.11" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.11" />
<PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="9.0.11" />
<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.3" />

View File

@ -19,7 +19,7 @@
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="MySqlConnector" Version="2.4.0" />
<PackageReference Include="Npgsql" Version="9.0.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.11" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
</ItemGroup>

View File

@ -58,7 +58,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="9.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="9.0.11" />
</ItemGroup>
<!-- This target execute after "Build" target -->

View File

@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="MessagePack" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
</ItemGroup>
<!-- Projekt referencia a Mango.Sandbox.EndPoints-ra -->
<ItemGroup>
<ProjectReference Include="..\..\..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\Mango.Nop.Core.csproj" />
<ProjectReference Include="..\Mango.Sandbox.EndPoints\Mango.Sandbox.EndPoints.csproj" />
</ItemGroup>
<ItemGroup>
<!-- Csak a ténylegesen használt AyCode DLL-ek -->
<Reference Include="AyCode.Core">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Core.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Services.dll</HintPath>
</Reference>
<Reference Include="FruitBank.Common">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\FruitBank.Common.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@ -0,0 +1,32 @@
using AyCode.Core.Loggers;
using AyCode.Services.SignalRs;
namespace Mango.Sandbox.EndPoints.Tests;
/// <summary>
/// SignalR kliens a Sandbox teszteléshez.
/// Az AcSignalRClientBase-bõl származik, a GetByIdAsync, GetAllAsync, PostDataAsync, GetAllIntoAsync metódusokat örökli.
/// </summary>
public class SignalRClientSandbox : AcSignalRClientBase
{
public SignalRClientSandbox(string hubUrl)
: base(hubUrl, new Logger<SignalRClientSandbox>())
{
}
//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)
{
Console.WriteLine($"[SignalRClientSandbox] Push message received: tag={messageTag}");
return Task.CompletedTask;
}
}

View File

@ -0,0 +1,502 @@
using AyCode.Services.SignalRs;
using Mango.Sandbox.EndPoints;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Mango.Sandbox.EndPoints.Tests;
/// <summary>
/// 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!
/// </summary>
[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<T>(tag)
var result = await _client.GetAllAsync<List<TestItem>>(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<TestItem>? receivedItems = null;
var tcs = new TaskCompletionSource<bool>();
// Act - GetAllAsync<T>(tag, callback)
await _client.GetAllAsync<List<TestItem>>(TestSignalRTags.GetTestItems, response =>
{
receivedItems = response.GetResponseData<List<TestItem>>();
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<string>(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<T>(tag, id)
var result = await _client.GetByIdAsync<string>(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<string>(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<bool>(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<Guid>(TestSignalRTags.GuidParam, guid);
// Assert
Assert.AreEqual(guid, result);
}
[TestMethod]
public async Task GetByIdAsync_Decimal_ReturnsDoubled()
{
// Act
var result = await _client.GetByIdAsync<decimal>(TestSignalRTags.DecimalParam, 123.45m);
// Assert
Assert.AreEqual(246.90m, result);
}
[TestMethod]
public async Task GetByIdAsync_Long_ReturnsSameLong()
{
// Act
var result = await _client.GetByIdAsync<long>(TestSignalRTags.LongParam, 9223372036854775807L);
// Assert
Assert.AreEqual(9223372036854775807L, result);
}
[TestMethod]
public async Task GetByIdAsync_Double_ReturnsSameDouble()
{
// Act
var result = await _client.GetByIdAsync<double>(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<TestStatus>(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<bool>();
// Act - GetByIdAsync<T>(tag, callback, id)
await _client.GetByIdAsync<string>(TestSignalRTags.SingleIntParam, response =>
{
receivedResult = response.GetResponseData<string>();
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<T>(tag, ids[])
var result = await _client.GetByIdAsync<int>(TestSignalRTags.TwoIntParams, new object[] { 10, 20 });
// Assert
Assert.AreEqual(30, result);
}
[TestMethod]
public async Task GetByIdAsync_MultipleTypes_ReturnsFormattedString()
{
// Act
var result = await _client.GetByIdAsync<string>(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<string>(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<bool>();
// Act - GetByIdAsync<T>(tag, callback, ids[])
await _client.GetByIdAsync<int>(TestSignalRTags.TwoIntParams, response =>
{
receivedResult = response.GetResponseData<int>();
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<T>(tag, contextParams[])
var result = await _client.GetAllAsync<int[]>(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<List<string>>(TestSignalRTags.StringListParam, new object[] { new List<string> { "apple", "banana" } });
// Assert
Assert.IsNotNull(result);
CollectionAssert.AreEqual(new List<string> { "APPLE", "BANANA" }, result);
}
[TestMethod]
public async Task GetAllAsync_WithContextParams_Callback_IntArray()
{
// Arrange
int[]? receivedResult = null;
var tcs = new TaskCompletionSource<bool>();
// Act - GetAllAsync<T>(tag, callback, contextParams[])
await _client.GetAllAsync<int[]>(TestSignalRTags.IntArrayParam, response =>
{
receivedResult = response.GetResponseData<int[]>();
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<TPost, TResponse>(tag, data)
var result = await _client.PostDataAsync<TestEchoRequest, TestEchoResponse>(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<TestOrder, TestOrder>(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<SharedTag, SharedTag>(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<bool>();
// Act - PostDataAsync<TPost, TResponse>(tag, data, callback)
await _client.PostDataAsync<TestEchoRequest, TestEchoResponse>(TestSignalRTags.EchoTag, request, response =>
{
receivedResult = response.GetResponseData<TestEchoResponse>();
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<string>(TestSignalRTags.StringParam, "");
// Assert
Assert.IsNotNull(result);
Assert.AreEqual("Echo: ", result);
}
[TestMethod]
public async Task GetByIdAsync_Zero_ReturnsFormattedString()
{
// Act
var result = await _client.GetByIdAsync<string>(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<string>(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<int[]>(TestSignalRTags.IntArrayParam, new object[] { Array.Empty<int>() });
// Assert
Assert.IsNotNull(result);
Assert.AreEqual(0, result.Length);
}
#endregion
#region Binary Serialization Tesztek - AcBinaryDeserializationException reprodukálása
/// <summary>
/// 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<CustomerDto>),
/// de a kliens deszerializálásnál az interned string index hibás.
/// </summary>
[TestMethod]
public async Task GetAllAsync_CustomerDtoList_BinaryDeserialization_ThrowsInternedStringIndexError()
{
// Act - GetAllAsync<List<TestCustomerDto>>(tag)
// Ez a hívás a GetMeasuringUsers-höz hasonló forgatókönyvet reprodukál
var result = await _client.GetAllAsync<List<TestCustomerDto>>(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}");
}
}
/// <summary>
/// Nagyobb CustomerDto lista tesztelése - több interned string a szerializációban
/// </summary>
[TestMethod]
public async Task GetAllAsync_LargeCustomerDtoList_BinaryDeserialization_Success()
{
// Act
var result = await _client.GetAllAsync<List<TestCustomerDto>>(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
}

View File

@ -0,0 +1,43 @@
using AyCode.Core.Enums;
using AyCode.Core.Extensions;
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;
/// <summary>
/// Egyszerûsített SignalR Hub a teszteléshez.
/// Ez a Hub nem függ a 3 eredeti endpoint-tól (IFruitBankDataControllerServer, ICustomOrderSignalREndpointServer, IStockSignalREndpointServer).
/// </summary>
public class DevAdminSignalRHubSandbox : AcWebSignalRHubWithSessionBase<SignalRTags, Logger<DevAdminSignalRHubSandbox>>
{
public DevAdminSignalRHubSandbox(IConfiguration configuration, ITestSignalREndpointServer testSignalREndpoint, IEnumerable<IAcLogWriterBase> logWriters)
: base(configuration, new Logger<DevAdminSignalRHubSandbox>(logWriters.ToArray()))
{
SerializerOptions = new AcBinarySerializerOptions();
DynamicMethodCallModels.Add(new AcDynamicMethodCallModel<SignalRAttribute>(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.

View File

@ -0,0 +1,40 @@
using AyCode.Core.Enums;
using AyCode.Core.Loggers;
namespace Mango.Sandbox.EndPoints;
public interface ILogger<TCategory> : ILogger
{
}
public interface ILogger : IAcLoggerBase
{
}
public class Logger<TCategory> : Logger, ILogger<TCategory>
{
//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)
{ }
}

View File

@ -0,0 +1,136 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Ne gener<65>ljon duplik<69>lt assembly info-t -->
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<!--
Projekt helye: H:\Applications\Mango\Source\FruitBank\Tests\Mango.Sandbox\Mango.Sandbox.EndPoints
FruitBank helye: H:\Applications\Mango\Source\FruitBank
-->
<FruitBankRoot>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\..\..\..'))\</FruitBankRoot>
<SourceRoot>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\..\..\..\..'))\</SourceRoot>
<PluginOutputDir>$(FruitBankRoot)Presentation\Nop.Web\Plugins\Misc.FruitBankPlugin\</PluginOutputDir>
<FruitBankHybridRoot>$(SourceRoot)FruitBankHybridApp\</FruitBankHybridRoot>
<!-- AyCode.Core solution output - INNEN OLVASSUK AZ AYCODE DLL-EKET -->
<AyCodeRoot>H:\Applications\Aycode\Source\AyCode.Core\</AyCodeRoot>
</PropertyGroup>
<!-- ===========================================
NuGet Packages - SANDBOX specifikus + NopCommerce szolg<6C>ltat<61>sokhoz sz<73>ks<6B>ges
=========================================== -->
<ItemGroup>
<!-- SignalR -->
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" Version="9.0.11" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="9.0.11" />
<!-- FluentValidation (Nop.Web.Framework haszn<7A>lja) -->
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<!-- WebOptimizer (Nop.Web.Framework haszn<7A>lja) -->
<PackageReference Include="LigerShark.WebOptimizer.Core" Version="3.0.426" />
<!-- WebMarkupMin (Nop.Web.Framework haszn<7A>lja) -->
<PackageReference Include="WebMarkupMin.AspNetCoreLatest" Version="2.18.0" />
<PackageReference Include="WebMarkupMin.NUglify" Version="2.18.0" />
<!-- Nop.Services - Azure, Mail, PDF, stb. -->
<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" />
<PackageReference Include="ClosedXML" Version="0.104.2" />
<PackageReference Include="Google.Apis.Auth" Version="1.68.0" />
<PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.5" />
<PackageReference Include="MailKit" Version="4.5.0" />
<PackageReference Include="MaxMind.GeoIP2" Version="5.2.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.66.2" />
<PackageReference Include="QuestPDF" Version="2022.12.15" />
<PackageReference Include="System.ServiceModel.Http" Version="8.1.2" />
<PackageReference Include="SkiaSharp" Version="2.88.9" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.9" />
<PackageReference Include="Svg.Skia" Version="2.0.0.4" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.9" />
<!-- Nop.Data - Database, Migration -->
<PackageReference Include="FluentMigrator" Version="6.2.0" />
<PackageReference Include="FluentMigrator.Runner" Version="6.2.0" />
<PackageReference Include="linq2db" Version="5.4.1" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="MySqlConnector" Version="2.4.0" />
<PackageReference Include="Npgsql" Version="9.0.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.11" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<!-- Nop.Core - Autofac, AutoMapper, Redis, stb. -->
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Blobs" Version="1.3.4" />
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Keys" Version="1.2.4" />
<PackageReference Include="Azure.Identity" Version="1.13.1" />
<PackageReference Include="Humanizer" Version="2.14.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="9.0.11" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.11" />
<PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="9.0.11" />
<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.3" />
</ItemGroup>
<!-- ===========================================
NopCommerce projekt referenci<63>k - TELJES INFRASTRUKT<4B>RA
=========================================== -->
<ItemGroup>
<!-- Nop.Web - Admin Model Factories, Controllers, stb. -->
<!-- Nop.Web.Framework - MVC infrastrukt<6B>ra, Themes, stb. -->
<ProjectReference Include="..\..\..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\Mango.Nop.Core.csproj" />
</ItemGroup>
<!-- FruitBank Plugin <20>s kapcsol<6F>d<EFBFBD> DLL-ek a PROD build output-b<EFBFBD>l -->
<!-- FruitBank DLL referenci<63>k -->
<ItemGroup>
<!-- AyCode DLL-ek az AyCode.Core solution-b<EFBFBD>l (FruitBank configuration) -->
<Reference Include="AyCode.Core">
<HintPath>$(AyCodeRoot)AyCode.Core\bin\FruitBank\Debug\net9.0\AyCode.Core.dll</HintPath>
</Reference>
<Reference Include="AyCode.Core.Server">
<HintPath>$(AyCodeRoot)AyCode.Core.Server\bin\FruitBank\Debug\net9.0\AyCode.Core.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Database">
<HintPath>$(AyCodeRoot)AyCode.Database\bin\FruitBank\Debug\net9.0\AyCode.Database.dll</HintPath>
</Reference>
<Reference Include="AyCode.Entities">
<HintPath>$(AyCodeRoot)AyCode.Entities\bin\FruitBank\Debug\net9.0\AyCode.Entities.dll</HintPath>
</Reference>
<Reference Include="AyCode.Entities.Server">
<HintPath>$(AyCodeRoot)AyCode.Entities.Server\bin\FruitBank\Debug\net9.0\AyCode.Entities.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Interfaces">
<HintPath>$(AyCodeRoot)AyCode.Interfaces\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.dll</HintPath>
</Reference>
<Reference Include="AyCode.Interfaces.Server">
<HintPath>$(AyCodeRoot)AyCode.Interfaces.Server\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Models.Server">
<HintPath>$(AyCodeRoot)AyCode.Models.Server\bin\FruitBank\Debug\net9.0\AyCode.Models.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services">
<HintPath>$(AyCodeRoot)AyCode.Services\bin\FruitBank\Debug\net9.0\AyCode.Services.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services.Server">
<HintPath>$(AyCodeRoot)AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Utils">
<HintPath>$(AyCodeRoot)AyCode.Utils\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll</HintPath>
</Reference>
<!-- FruitBank DLL-ek a FruitBankHybridApp-b<EFBFBD>l -->
<Reference Include="FruitBank.Common">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\FruitBank.Common.dll</HintPath>
</Reference>
<Reference Include="FruitBank.Common.Server">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\FruitBank.Common.Server.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@ -0,0 +1,126 @@
using AyCode.Core.Loggers;
using FruitBank.Common;
using FruitBank.Common.Server.Services.Loggers;
using FruitBank.Common.Server.Services.SignalRs;
using Mango.Sandbox.EndPoints;
using Microsoft.AspNetCore.Http.Connections;
var builder = WebApplication.CreateBuilder(args);
// ===========================================
// === MINIMÁLIS KONFIGURÁCIÓ A SIGNALR HUB TESZTELÉSÉHEZ ===
// ===========================================
Console.WriteLine("[SANDBOX] Starting minimal SignalR Hub test configuration...");
// ===========================================
// === 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;
});
// ===========================================
// === ALAPVETÕ INFRASTRUKTÚRA ===
// ===========================================
builder.Services.AddHttpContextAccessor();
builder.Services.AddMemoryCache();
builder.Services.AddDistributedMemoryCache(); // IDistributedCache a Session-höz
builder.Services.AddSession();
// ===========================================
// === LOGGER - Csak ConsoleLogWriter a teszteléshez ===
// ===========================================
builder.Services.AddScoped<IAcLogWriterBase, ConsoleLogWriter>();
// ===========================================
// === TESZT ENDPOINT ===
// ===========================================
builder.Services.AddScoped<ITestSignalREndpointServer, TestSignalREndpoint>();
// ===========================================
// === 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();
// ===========================================
// === SIGNALR HUB REGISZTRÁCIÓ ===
// ===========================================
var fruitBankHubEndPoint = $"/{FruitBankConstClient.DefaultHubName}";
// SANDBOX TESZT HUB - egyszerûsített, nincs Nop függõség
app.MapHub<DevAdminSignalRHubSandbox>(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<LoggerSignalRHub>(loggerHubEndPoint, options =>
{
options.AllowStatefulReconnects = false;
});
app.MapGet("/", () => "SANDBOX is running!");
app.MapGet("/health", () => Results.Ok(new { status = "healthy", timestamp = DateTime.UtcNow }));
// ===========================================
// === CONSOLE OUTPUT ===
// ===========================================
Console.Title = "[SB] - SignalR Test";
Console.WriteLine("===========================================");
Console.WriteLine(" FRUITBANK SANDBOX - SignalR Test Mode");
Console.WriteLine("===========================================");
Console.WriteLine($" Base URL: http://localhost:59579");
Console.WriteLine($" SignalR Hub: {fruitBankHubEndPoint}");
Console.WriteLine($" Logger Hub: {loggerHubEndPoint}");
Console.WriteLine("===========================================");
app.Run();

View File

@ -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<IExternalAuthenticationMethod?> LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IExternalAuthenticationMethod?>(null);
// public Task<IList<IExternalAuthenticationMethod>> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IExternalAuthenticationMethod>>(new List<IExternalAuthenticationMethod>());
// public Task<IList<IExternalAuthenticationMethod>> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IExternalAuthenticationMethod>>(new List<IExternalAuthenticationMethod>());
// public Task<IList<IExternalAuthenticationMethod>> LoadActivePluginsAsync(List<string> systemNames, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IExternalAuthenticationMethod>>(new List<IExternalAuthenticationMethod>());
// public bool IsPluginActive(IExternalAuthenticationMethod plugin, List<string> systemNames) => false;
// public bool IsPluginActive(IExternalAuthenticationMethod plugin) => false;
// public Task<bool> IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult(false);
// public Task<string> GetPluginLogoUrlAsync(IExternalAuthenticationMethod plugin)
// => Task.FromResult(string.Empty);
//}

View File

@ -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;
/// <summary>
/// Null implementation of IDiscountPluginManager for SANDBOX
/// </summary>
//public class NullDiscountPluginManager : IDiscountPluginManager
//{
// public Task<IDiscountRequirementRule?> LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IDiscountRequirementRule?>(null);
// public Task<IList<IDiscountRequirementRule>> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IDiscountRequirementRule>>(new List<IDiscountRequirementRule>());
// public Task<IList<IDiscountRequirementRule>> LoadActivePluginsAsync(List<string> systemNames, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IDiscountRequirementRule>>(new List<IDiscountRequirementRule>());
// public bool IsPluginActive(IDiscountRequirementRule plugin, List<string> systemNames) => false;
// public Task<string> GetPluginLogoUrlAsync(IDiscountRequirementRule plugin)
// => Task.FromResult(string.Empty);
//}

View File

@ -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;
/// <summary>
/// Null implementation of IExchangeRatePluginManager for SANDBOX
/// </summary>
//public class NullExchangeRatePluginManager : IExchangeRatePluginManager
//{
// public Task<IExchangeRateProvider?> LoadPrimaryPluginAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IExchangeRateProvider?>(null);
// public bool IsPluginActive(IExchangeRateProvider exchangeRateProvider) => false;
// public Task<IExchangeRateProvider?> LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IExchangeRateProvider?>(null);
// public Task<IList<IExchangeRateProvider>> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IExchangeRateProvider>>(new List<IExchangeRateProvider>());
// public bool IsPluginActive(IExchangeRateProvider plugin, List<string> systemNames) => false;
// public Task<IList<IExchangeRateProvider>> LoadActivePluginsAsync(List<string> systemNames, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IExchangeRateProvider>>(new List<IExchangeRateProvider>());
// public Task<string> GetPluginLogoUrlAsync(IExchangeRateProvider plugin)
// => Task.FromResult(string.Empty);
//}

View File

@ -0,0 +1,35 @@
using Microsoft.AspNetCore.Mvc;
using Nop.Core.Domain.Customers;
//using Nop.Services.Authentication.External;
namespace Mango.Sandbox.EndPoints.Services;
/// <summary>
/// Null implementation of IExternalAuthenticationService for SANDBOX
/// </summary>
//public class NullExternalAuthenticationService : IExternalAuthenticationService
//{
// public Task<IActionResult> AuthenticateAsync(ExternalAuthenticationParameters parameters, string returnUrl = null!)
// => Task.FromResult<IActionResult>(new NotFoundResult());
// public Task<ExternalAuthenticationRecord?> GetExternalAuthenticationRecordByIdAsync(int externalAuthenticationRecordId)
// => Task.FromResult<ExternalAuthenticationRecord?>(null);
// public Task<IList<ExternalAuthenticationRecord>> GetCustomerExternalAuthenticationRecordsAsync(Customer customer)
// => Task.FromResult<IList<ExternalAuthenticationRecord>>(new List<ExternalAuthenticationRecord>());
// public Task DeleteExternalAuthenticationRecordAsync(ExternalAuthenticationRecord externalAuthenticationRecord)
// => Task.CompletedTask;
// public Task<ExternalAuthenticationRecord?> GetExternalAuthenticationRecordByExternalAuthenticationParametersAsync(ExternalAuthenticationParameters parameters)
// => Task.FromResult<ExternalAuthenticationRecord?>(null);
// public Task AssociateExternalAccountWithUserAsync(Customer customer, ExternalAuthenticationParameters parameters)
// => Task.CompletedTask;
// public Task<Customer?> GetUserByExternalAuthenticationParametersAsync(ExternalAuthenticationParameters parameters)
// => Task.FromResult<Customer?>(null);
// public Task RemoveAssociationAsync(ExternalAuthenticationParameters parameters)
// => Task.CompletedTask;
//}

View File

@ -0,0 +1,36 @@
using Nop.Core.Domain.Customers;
//using Nop.Services.Authentication.MultiFactor;
//using Nop.Services.Plugins;
namespace Mango.Sandbox.EndPoints.Services;
/// <summary>
/// Null implementation of IMultiFactorAuthenticationPluginManager for SANDBOX
/// </summary>
//public class NullMultiFactorAuthenticationPluginManager : IMultiFactorAuthenticationPluginManager
//{
// public Task<IMultiFactorAuthenticationMethod?> LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IMultiFactorAuthenticationMethod?>(null);
// public Task<IList<IMultiFactorAuthenticationMethod>> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IMultiFactorAuthenticationMethod>>(new List<IMultiFactorAuthenticationMethod>());
// public Task<IList<IMultiFactorAuthenticationMethod>> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IMultiFactorAuthenticationMethod>>(new List<IMultiFactorAuthenticationMethod>());
// public Task<IList<IMultiFactorAuthenticationMethod>> LoadActivePluginsAsync(List<string> systemNames, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IMultiFactorAuthenticationMethod>>(new List<IMultiFactorAuthenticationMethod>());
// public Task<bool> HasActivePluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult(false);
// public bool IsPluginActive(IMultiFactorAuthenticationMethod plugin) => false;
// public bool IsPluginActive(IMultiFactorAuthenticationMethod plugin, List<string> systemNames) => false;
// public Task<bool> IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult(false);
// public Task<string> GetPluginLogoUrlAsync(IMultiFactorAuthenticationMethod plugin)
// => Task.FromResult(string.Empty);
//}

View File

@ -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<IPaymentMethod?> LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IPaymentMethod?>(null);
// public Task<IList<IPaymentMethod>> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IPaymentMethod>>(new List<IPaymentMethod>());
// public Task<IList<IPaymentMethod>> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, int filterByCountryId = 0)
// => Task.FromResult<IList<IPaymentMethod>>(new List<IPaymentMethod>());
// public Task<IList<IPaymentMethod>> LoadActivePluginsAsync(List<string> systemNames, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IPaymentMethod>>(new List<IPaymentMethod>());
// public bool IsPluginActive(IPaymentMethod plugin, List<string> systemNames) => false;
// public bool IsPluginActive(IPaymentMethod plugin) => false;
// public Task<bool> IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult(false);
// public Task<string> GetPluginLogoUrlAsync(IPaymentMethod plugin)
// => Task.FromResult(string.Empty);
// public Task<IList<int>> GetRestrictedCountryIdsAsync(IPaymentMethod paymentMethod)
// => Task.FromResult<IList<int>>(new List<int>());
// public Task SaveRestrictedCountriesAsync(IPaymentMethod paymentMethod, IList<int> countryIds)
// => Task.CompletedTask;
//}

View File

@ -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<IPickupPointProvider?> LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IPickupPointProvider?>(null);
// public Task<IList<IPickupPointProvider>> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IPickupPointProvider>>(new List<IPickupPointProvider>());
// public Task<IList<IPickupPointProvider>> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, string filterByCountryId = null!)
// => Task.FromResult<IList<IPickupPointProvider>>(new List<IPickupPointProvider>());
// public Task<IList<IPickupPointProvider>> LoadActivePluginsAsync(List<string> systemNames, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IPickupPointProvider>>(new List<IPickupPointProvider>());
// public bool IsPluginActive(IPickupPointProvider plugin, List<string> systemNames) => false;
// public bool IsPluginActive(IPickupPointProvider plugin) => false;
// public Task<bool> IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult(false);
// public Task<string> GetPluginLogoUrlAsync(IPickupPointProvider plugin)
// => Task.FromResult(string.Empty);
//}

View File

@ -0,0 +1,33 @@
using Nop.Core.Domain.Customers;
//using Nop.Services.Catalog;
//using Nop.Services.Plugins;
namespace Mango.Sandbox.EndPoints.Services;
/// <summary>
/// Null implementation of ISearchPluginManager for SANDBOX
/// </summary>
//public class NullSearchPluginManager : ISearchPluginManager
//{
// public Task<ISearchProvider?> LoadPrimaryPluginAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<ISearchProvider?>(null);
// public bool IsPluginActive(ISearchProvider searchProvider) => false;
// public Task<bool> IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult(false);
// public Task<ISearchProvider?> LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult<ISearchProvider?>(null);
// public Task<IList<ISearchProvider>> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<ISearchProvider>>(new List<ISearchProvider>());
// public bool IsPluginActive(ISearchProvider plugin, List<string> systemNames) => false;
// public Task<IList<ISearchProvider>> LoadActivePluginsAsync(List<string> systemNames, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<ISearchProvider>>(new List<ISearchProvider>());
// public Task<string> GetPluginLogoUrlAsync(ISearchProvider plugin)
// => Task.FromResult(string.Empty);
//}

View File

@ -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<IShippingRateComputationMethod?> LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IShippingRateComputationMethod?>(null);
// public Task<IList<IShippingRateComputationMethod>> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IShippingRateComputationMethod>>(new List<IShippingRateComputationMethod>());
// public Task<IList<IShippingRateComputationMethod>> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, string filterByCountryId = null!)
// => Task.FromResult<IList<IShippingRateComputationMethod>>(new List<IShippingRateComputationMethod>());
// public Task<IList<IShippingRateComputationMethod>> LoadActivePluginsAsync(List<string> systemNames, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IShippingRateComputationMethod>>(new List<IShippingRateComputationMethod>());
// public bool IsPluginActive(IShippingRateComputationMethod plugin, List<string> systemNames) => false;
// public bool IsPluginActive(IShippingRateComputationMethod plugin) => false;
// public Task<bool> IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult(false);
// public Task<string> GetPluginLogoUrlAsync(IShippingRateComputationMethod plugin)
// => Task.FromResult(string.Empty);
// public Task<IList<int>> GetRestrictedCountryIdsAsync(IShippingRateComputationMethod shippingMethod)
// => Task.FromResult<IList<int>>(new List<int>());
// public Task SaveRestrictedCountriesAsync(IShippingRateComputationMethod shippingMethod, IList<int> countryIds)
// => Task.CompletedTask;
//}

View File

@ -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<ITaxProvider?> LoadPrimaryPluginAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<ITaxProvider?>(null);
// public Task<ITaxProvider?> LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult<ITaxProvider?>(null);
// public Task<IList<ITaxProvider>> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<ITaxProvider>>(new List<ITaxProvider>());
// public Task<IList<ITaxProvider>> LoadActivePluginsAsync(List<string> systemNames, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<ITaxProvider>>(new List<ITaxProvider>());
// public bool IsPluginActive(ITaxProvider plugin, List<string> systemNames) => false;
// public bool IsPluginActive(ITaxProvider plugin) => false;
// public Task<bool> IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult(false);
// public Task<string> GetPluginLogoUrlAsync(ITaxProvider plugin)
// => Task.FromResult(string.Empty);
//}

View File

@ -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<IList<IWidgetPlugin>> LoadActivePluginsAsync(Customer? customer = null, int storeId = 0, string widgetZone = null!)
// => Task.FromResult<IList<IWidgetPlugin>>(new List<IWidgetPlugin>());
// public Task<IWidgetPlugin?> LoadPluginBySystemNameAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IWidgetPlugin?>(null);
// public Task<IList<IWidgetPlugin>> LoadAllPluginsAsync(Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IWidgetPlugin>>(new List<IWidgetPlugin>());
// public Task<IList<IWidgetPlugin>> LoadActivePluginsAsync(List<string> systemNames, Customer? customer = null, int storeId = 0)
// => Task.FromResult<IList<IWidgetPlugin>>(new List<IWidgetPlugin>());
// public bool IsPluginActive(IWidgetPlugin plugin, List<string> systemNames) => false;
// public bool IsPluginActive(IWidgetPlugin plugin) => false;
// public Task<bool> IsPluginActiveAsync(string systemName, Customer? customer = null, int storeId = 0)
// => Task.FromResult(false);
// public Task<string> GetPluginLogoUrlAsync(IWidgetPlugin plugin)
// => Task.FromResult(string.Empty);
//}

View File

@ -0,0 +1,679 @@
using AyCode.Services.SignalRs;
using FruitBank.Common.Dtos;
using FruitBank.Common.SignalRs;
using System.Globalization;
using System.Text.Json.Serialization;
namespace Mango.Sandbox.EndPoints;
/// <summary>
/// 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.
/// </summary>
public class TestSignalREndpoint : ITestSignalREndpointServer
{
#region Primitív Paraméter Handlerek
/// <summary>
/// Egyszerû ping metódus - visszaadja a kapott üzenetet és egy timestampet.
/// </summary>
[SignalR(TestSignalRTags.PingTag)]
public Task<TestPingResponse> Ping(string message)
{
return Task.FromResult(new TestPingResponse
{
Message = message,
ReceivedAt = DateTime.UtcNow,
ServerInfo = $"Sandbox Server - {Environment.MachineName}"
});
}
/// <summary>
/// Int paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.SingleIntParam)]
public Task<string> HandleSingleInt(int value)
{
return Task.FromResult($"Received: {value}");
}
/// <summary>
/// Két int paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.TwoIntParams)]
public Task<int> HandleTwoInts(int a, int b)
{
return Task.FromResult(a + b);
}
/// <summary>
/// Bool paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.BoolParam)]
public Task<bool> HandleBool(bool loadRelations)
{
return Task.FromResult(loadRelations);
}
/// <summary>
/// String paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.StringParam)]
public Task<string> HandleString(string text)
{
return Task.FromResult($"Echo: {text}");
}
/// <summary>
/// Guid paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.GuidParam)]
public Task<Guid> HandleGuid(Guid id)
{
return Task.FromResult(id);
}
/// <summary>
/// Enum paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.EnumParam)]
public Task<TestStatus> HandleEnum(TestStatus status)
{
return Task.FromResult(status);
}
/// <summary>
/// Paraméter nélküli metódus teszt
/// </summary>
[SignalR(TestSignalRTags.NoParams)]
public Task<string> HandleNoParams()
{
return Task.FromResult("OK");
}
/// <summary>
/// Több típusú paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.MultipleTypesParams)]
public Task<string> HandleMultipleTypes(bool flag, string text, int number)
{
return Task.FromResult($"{flag}-{text}-{number}");
}
/// <summary>
/// Decimal paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.DecimalParam)]
public Task<decimal> HandleDecimal(decimal value)
{
return Task.FromResult(value * 2);
}
/// <summary>
/// DateTime paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.DateTimeParam)]
public Task<DateTime> HandleDateTime(DateTime dateTime)
{
return Task.FromResult(dateTime);
}
/// <summary>
/// Double paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.DoubleParam)]
public Task<double> HandleDouble(double value)
{
return Task.FromResult(value);
}
/// <summary>
/// Long paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.LongParam)]
public Task<long> HandleLong(long value)
{
return Task.FromResult(value);
}
#endregion
#region Komplex Objektum Handlerek
/// <summary>
/// Egyszerû echo metódus - visszaadja a kapott objektumot változtatás nélkül.
/// </summary>
[SignalR(TestSignalRTags.EchoTag)]
public Task<TestEchoResponse> Echo(TestEchoRequest request)
{
return Task.FromResult(new TestEchoResponse
{
Id = request?.Id ?? 0,
Name = request?.Name ?? "Unknown",
Timestamp = DateTime.UtcNow,
EchoedSuccessfully = true
});
}
/// <summary>
/// TestOrderItem komplex objektum teszt
/// </summary>
[SignalR(TestSignalRTags.TestOrderItemParam)]
public Task<TestOrderItem> HandleTestOrderItem(TestOrderItem item)
{
return Task.FromResult(new TestOrderItem
{
Id = item.Id,
ProductName = $"Processed: {item.ProductName}",
Quantity = item.Quantity * 2,
UnitPrice = item.UnitPrice * 2,
});
}
/// <summary>
/// TestOrder komplex objektum teszt (beágyazott objektumokkal)
/// </summary>
[SignalR(TestSignalRTags.TestOrderParam)]
public Task<TestOrder> HandleTestOrder(TestOrder order)
{
return Task.FromResult(order);
}
/// <summary>
/// SharedTag komplex objektum teszt
/// </summary>
[SignalR(TestSignalRTags.SharedTagParam)]
public Task<SharedTag> HandleSharedTag(SharedTag tag)
{
return Task.FromResult(tag);
}
#endregion
#region Kollekció Handlerek
/// <summary>
/// Lista visszaadása teszthez.
/// </summary>
[SignalR(TestSignalRTags.GetTestItems)]
public Task<List<TestItem>> GetTestItems()
{
var items = new List<TestItem>
{
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);
}
/// <summary>
/// Int tömb paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.IntArrayParam)]
public Task<int[]> HandleIntArray(int[] values)
{
return Task.FromResult(values.Select(x => x * 2).ToArray());
}
/// <summary>
/// Guid tömb paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.GuidArrayParam)]
public Task<Guid[]> HandleGuidArray(Guid[] ids)
{
return Task.FromResult(ids);
}
/// <summary>
/// String lista paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.StringListParam)]
public Task<List<string>> HandleStringList(List<string> items)
{
return Task.FromResult(items.Select(x => x.ToUpper()).ToList());
}
/// <summary>
/// TestOrderItem lista paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.TestOrderItemListParam)]
public Task<List<TestOrderItem>> HandleTestOrderItemList(List<TestOrderItem> items)
{
return Task.FromResult(items);
}
/// <summary>
/// Int lista paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.IntListParam)]
public Task<List<int>> HandleIntList(List<int> numbers)
{
return Task.FromResult(numbers.Select(x => x * 2).ToList());
}
/// <summary>
/// Bool tömb paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.BoolArrayParam)]
public Task<bool[]> HandleBoolArray(bool[] flags)
{
return Task.FromResult(flags);
}
/// <summary>
/// Vegyes paraméterek tömbbel teszt
/// </summary>
[SignalR(TestSignalRTags.MixedWithArrayParam)]
public Task<string> HandleMixedWithArray(bool flag, int[] numbers, string text)
{
return Task.FromResult($"{flag}-[{string.Join(",", numbers)}]-{text}");
}
/// <summary>
/// Beágyazott lista teszt
/// </summary>
[SignalR(TestSignalRTags.NestedListParam)]
public Task<List<List<int>>> HandleNestedList(List<List<int>> nestedList)
{
return Task.FromResult(nestedList);
}
/// <summary>
/// Long tömb paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.LongArrayParam)]
public Task<long[]> HandleLongArray(long[] values)
{
return Task.FromResult(values);
}
/// <summary>
/// Decimal tömb paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.DecimalArrayParam)]
public Task<decimal[]> HandleDecimalArray(decimal[] values)
{
return Task.FromResult(values);
}
/// <summary>
/// DateTime tömb paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.DateTimeArrayParam)]
public Task<DateTime[]> HandleDateTimeArray(DateTime[] values)
{
return Task.FromResult(values);
}
/// <summary>
/// Enum tömb paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.EnumArrayParam)]
public Task<TestStatus[]> HandleEnumArray(TestStatus[] values)
{
return Task.FromResult(values);
}
/// <summary>
/// Double tömb paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.DoubleArrayParam)]
public Task<double[]> HandleDoubleArray(double[] values)
{
return Task.FromResult(values);
}
/// <summary>
/// SharedTag tömb paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.SharedTagArrayParam)]
public Task<SharedTag[]> HandleSharedTagArray(SharedTag[] tags)
{
return Task.FromResult(tags);
}
/// <summary>
/// Dictionary paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.DictionaryParam)]
public Task<Dictionary<string, int>> HandleDictionary(Dictionary<string, int> dict)
{
return Task.FromResult(dict);
}
#endregion
#region Vegyes Paraméter Handlerek
/// <summary>
/// Int és DTO vegyes paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.IntAndDtoParam)]
public Task<string> HandleIntAndDto(int id, TestOrderItem item)
{
return Task.FromResult($"{id}-{item?.ProductName}");
}
/// <summary>
/// DTO és lista vegyes paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.DtoAndListParam)]
public Task<string> HandleDtoAndList(TestOrderItem item, List<int> numbers)
{
return Task.FromResult($"{item?.ProductName}-[{string.Join(",", numbers ?? [])}]");
}
/// <summary>
/// Három komplex paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.ThreeComplexParams)]
public Task<string> HandleThreeComplexParams(TestOrderItem item, List<string> tags, SharedTag sharedTag)
{
return Task.FromResult($"{item?.ProductName}-{tags?.Count}-{sharedTag?.Name}");
}
/// <summary>
/// Öt paraméter teszt
/// </summary>
[SignalR(TestSignalRTags.FiveParams)]
public Task<string> 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
/// <summary>
/// OrderDto lista visszaadása ID-k alapján
/// </summary>
[SignalR(SignalRTags.GetAllOrderDtoByIds)]
public Task<List<OrderDto>> GetOrderDtoByIds(int[] orderIds)
{
return Task.FromResult(new List<OrderDto>());
}
#endregion
#region Binary Serialization Tesztek - CustomerDto reprodukálás
/// <summary>
/// CustomerDto lista visszaadása - reprodukálja a GetMeasuringUsers forgatókönyvet
/// </summary>
[SignalR(TestSignalRTags.GetCustomerDtoList)]
public Task<List<TestCustomerDto>> GetCustomerDtoList()
{
var customers = new List<TestCustomerDto>
{
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);
}
/// <summary>
/// Nagyobb CustomerDto lista - több interned string a szerializációban
/// </summary>
[SignalR(TestSignalRTags.GetLargeCustomerDtoList)]
public Task<List<TestCustomerDto>> GetLargeCustomerDtoList()
{
var customers = new List<TestCustomerDto>();
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
}
/// <summary>
/// Teszt SignalR Tags - egyszerû értékek a teszteléshez
/// </summary>
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;
// Binary serialization tesztek - CustomerDto reprodukálás
public const int GetCustomerDtoList = 9070;
public const int GetLargeCustomerDtoList = 9071;
}
/// <summary>
/// Interface a TestSignalREndpoint-hoz
/// </summary>
public interface ITestSignalREndpointServer
{
// Primitívek
Task<TestPingResponse> Ping(string message);
Task<string> HandleSingleInt(int value);
Task<int> HandleTwoInts(int a, int b);
Task<bool> HandleBool(bool loadRelations);
Task<string> HandleString(string text);
Task<Guid> HandleGuid(Guid id);
Task<TestStatus> HandleEnum(TestStatus status);
Task<string> HandleNoParams();
Task<string> HandleMultipleTypes(bool flag, string text, int number);
Task<decimal> HandleDecimal(decimal value);
Task<DateTime> HandleDateTime(DateTime dateTime);
Task<double> HandleDouble(double value);
Task<long> HandleLong(long value);
// Komplex objektumok
Task<TestEchoResponse> Echo(TestEchoRequest request);
Task<TestOrderItem> HandleTestOrderItem(TestOrderItem item);
Task<TestOrder> HandleTestOrder(TestOrder order);
Task<SharedTag> HandleSharedTag(SharedTag tag);
// Kollekciók
Task<List<TestItem>> GetTestItems();
Task<int[]> HandleIntArray(int[] values);
Task<Guid[]> HandleGuidArray(Guid[] ids);
Task<List<string>> HandleStringList(List<string> items);
Task<List<TestOrderItem>> HandleTestOrderItemList(List<TestOrderItem> items);
Task<List<int>> HandleIntList(List<int> numbers);
Task<bool[]> HandleBoolArray(bool[] flags);
Task<string> HandleMixedWithArray(bool flag, int[] numbers, string text);
Task<List<List<int>>> HandleNestedList(List<List<int>> nestedList);
Task<long[]> HandleLongArray(long[] values);
Task<decimal[]> HandleDecimalArray(decimal[] values);
Task<DateTime[]> HandleDateTimeArray(DateTime[] values);
Task<TestStatus[]> HandleEnumArray(TestStatus[] values);
Task<double[]> HandleDoubleArray(double[] values);
Task<SharedTag[]> HandleSharedTagArray(SharedTag[] tags);
Task<Dictionary<string, int>> HandleDictionary(Dictionary<string, int> dict);
// Vegyes paraméterek
Task<string> HandleIntAndDto(int id, TestOrderItem item);
Task<string> HandleDtoAndList(TestOrderItem item, List<int> numbers);
Task<string> HandleThreeComplexParams(TestOrderItem item, List<string> tags, SharedTag sharedTag);
Task<string> HandleFiveParams(int a, string b, bool c, Guid d, decimal e);
// Binary serialization tesztek - CustomerDto reprodukálás
Task<List<TestCustomerDto>> GetCustomerDtoList();
Task<List<TestCustomerDto>> GetLargeCustomerDtoList();
}
#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; }
}
/// <summary>
/// Teszt enum a különbözõ állapotok teszteléséhez
/// </summary>
public enum TestStatus
{
Pending = 0,
Active = 1,
Completed = 2,
Cancelled = 3
}
/// <summary>
/// Teszt rendelési tétel komplex objektum teszteléshez
/// </summary>
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;
}
/// <summary>
/// Teszt rendelés beágyazott objektumokkal
/// </summary>
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<TestOrderItem> Items { get; set; } = [];
public decimal TotalAmount => Items.Sum(x => x.TotalPrice);
}
/// <summary>
/// Megosztott tag objektum teszteléshez
/// </summary>
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; }
}
/// <summary>
/// Teszt CustomerDto a felhasználók teszteléséhez
/// </summary>
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

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +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"
}
},
"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": "*"
}

View File

@ -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