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.
This commit is contained in:
Loretta 2025-12-11 23:46:35 +01:00
parent 9a3720f053
commit c8fa8d1c4c
12 changed files with 1732 additions and 896 deletions

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
@ -10,10 +10,74 @@
<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="..\Mango.Sandbox.EndPoints\Mango.Sandbox.EndPoints.csproj" />
</ItemGroup>
<ItemGroup>
<!-- AyCode DLL-ek a ToJson() <20>s JsonTo<T>() extension met<65>dusokhoz -->
<Reference Include="AyCode.Core">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Core.dll</HintPath>
</Reference>
<Reference Include="AyCode.Core.Server">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Core.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Core.Tests">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Core.Tests.dll</HintPath>
</Reference>
<Reference Include="AyCode.Database">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Database.dll</HintPath>
</Reference>
<Reference Include="AyCode.Database.Tests">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Database.Tests.dll</HintPath>
</Reference>
<Reference Include="AyCode.Entities">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Entities.dll</HintPath>
</Reference>
<Reference Include="AyCode.Entities.Server">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Entities.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Interfaces">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.dll</HintPath>
</Reference>
<Reference Include="AyCode.Interfaces.Server">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Models">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Models.dll</HintPath>
</Reference>
<Reference Include="AyCode.Models.Server">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Models.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services">
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Services.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services.Server">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services.Server.Tests">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.Tests.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services.Tests">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Services.Tests.dll</HintPath>
</Reference>
<Reference Include="AyCode.Utils">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Utils.dll</HintPath>
</Reference>
<Reference Include="AyCode.Utils.Server">
<HintPath>..\..\..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server.Tests\bin\FruitBank\Debug\net9.0\AyCode.Utils.Server.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,30 @@
using AyCode.Core.Loggers;
using AyCode.Services.SignalRs;
using Mango.Sandbox.EndPoints;
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 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;
}
}

View File

@ -0,0 +1,457 @@
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.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<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.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<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.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<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.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<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.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<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
}

View File

@ -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;
/// <summary>
/// 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!
/// </summary>
[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<TestPingResponse>();
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<TestEchoResponse>();
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<List<TestItem>>();
Assert.IsNotNull(items);
Assert.IsTrue(items.Count > 0);
});
}
#endregion
#region Helper Methods
private async Task SignalRClientHelper(int tag, object? parameter, string endpointName, Action<string?>? validateResponse = null)
{
var connection = new HubConnectionBuilder()
.WithUrl(HubUrl)
.Build();
string? receivedJson = null;
var responseReceived = new TaskCompletionSource<bool>();
connection.On<int, byte[], int?>("OnReceiveMessage", (responseTag, data, requestId) =>
{
if (data != null && data.Length > 0)
{
try
{
var options = MessagePack.Resolvers.ContractlessStandardResolver.Options;
var response = MessagePackSerializer.Deserialize<SignalResponseJsonMessage>(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>(idMessage).ToMessagePack(ContractlessStandardResolver.Options);
}
else
{
return new SignalPostJsonDataMessage<object>(parameter).ToMessagePack(ContractlessStandardResolver.Options);
}
}
#endregion
}
/// <summary>
/// Wrapper a Task eredményekhez - a szerver Task-ot ad vissza {"Result":...} formátumban
/// </summary>
public class TaskResultWrapper<T>
{
public T? Result { get; set; }
}

View File

@ -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;
/// <summary>
/// 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
/// </summary>
[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<bool>();
connection.On<int, byte[]>("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<byte>();
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
}

View File

@ -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;
/// <summary>
/// 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
/// </summary>
[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<bool>();
// connection.On<int, byte[]>("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<byte>();
// 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
}

View File

@ -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;
/// <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()))
{
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

@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Ne generáljon duplikált assembly info-t -->
<!-- Ne gener<EFBFBD>ljon duplik<69>lt assembly info-t -->
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<!--
Projekt helye: H:\Applications\Mango\Source\FruitBank\Tests\Mango.Sandbox\Mango.Sandbox.EndPoints
@ -14,23 +14,25 @@
<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áltatásokhoz szükséges
NuGet Packages - SANDBOX specifikus + NopCommerce szolg<EFBFBD>ltat<EFBFBD>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álja) -->
<!-- FluentValidation (Nop.Web.Framework haszn<EFBFBD>lja) -->
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<!-- WebOptimizer (Nop.Web.Framework használja) -->
<!-- WebOptimizer (Nop.Web.Framework haszn<EFBFBD>lja) -->
<PackageReference Include="LigerShark.WebOptimizer.Core" Version="3.0.426" />
<!-- WebMarkupMin (Nop.Web.Framework használja) -->
<!-- WebMarkupMin (Nop.Web.Framework haszn<EFBFBD>lja) -->
<PackageReference Include="WebMarkupMin.AspNetCoreLatest" Version="2.18.0" />
<PackageReference Include="WebMarkupMin.NUglify" Version="2.18.0" />
@ -76,63 +78,57 @@
</ItemGroup>
<!-- ===========================================
NopCommerce projekt referenciák - TELJES INFRASTRUKTÚRA
NopCommerce projekt referenci<EFBFBD>k - TELJES INFRASTRUKT<4B>RA
=========================================== -->
<ItemGroup>
<!-- Nop.Web - Admin Model Factories, Controllers, stb. -->
<ProjectReference Include="$(FruitBankRoot)Presentation\Nop.Web\Nop.Web.csproj" />
<!-- Nop.Web.Framework - MVC infrastruktúra, Themes, stb. -->
<ProjectReference Include="$(FruitBankRoot)Presentation\Nop.Web.Framework\Nop.Web.Framework.csproj" />
<!-- Nop.Web.Framework - MVC infrastrukt<6B>ra, Themes, stb. -->
<ProjectReference Include="..\..\..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\Mango.Nop.Core.csproj" />
<ProjectReference Include="..\..\..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Data\Mango.Nop.Data.csproj" />
<ProjectReference Include="..\..\..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Services\Mango.Nop.Services.csproj" />
<ProjectReference Include="..\..\..\Libraries\Nop.Core\Nop.Core.csproj" />
<ProjectReference Include="..\..\..\Libraries\Nop.Data\Nop.Data.csproj" />
</ItemGroup>
<!-- FruitBank Plugin és kapcsolódó DLL-ek a PROD build output-ból -->
<ItemGroup>
<Reference Include="Nop.Plugin.Misc.FruitBankPlugin">
<HintPath>$(PluginOutputDir)Nop.Plugin.Misc.FruitBankPlugin.dll</HintPath>
</Reference>
<Reference Include="Mango.Nop.Core">
<HintPath>$(PluginOutputDir)Mango.Nop.Core.dll</HintPath>
</Reference>
<Reference Include="Mango.Nop.Services">
<HintPath>$(PluginOutputDir)Mango.Nop.Services.dll</HintPath>
</Reference>
</ItemGroup>
<!-- FruitBank Plugin <20>s kapcsol<6F>d<EFBFBD> DLL-ek a PROD build output-b<EFBFBD>l -->
<!-- FruitBank DLL referenciák -->
<!-- FruitBank DLL referenci<63>k -->
<ItemGroup>
<!-- AyCode DLL-ek az AyCode.Core solution-b<EFBFBD>l (FruitBank configuration) -->
<Reference Include="AyCode.Core">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Core.dll</HintPath>
<HintPath>$(AyCodeRoot)AyCode.Core\bin\FruitBank\Debug\net9.0\AyCode.Core.dll</HintPath>
</Reference>
<Reference Include="AyCode.Core.Server">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Core.Server.dll</HintPath>
<HintPath>$(AyCodeRoot)AyCode.Core.Server\bin\FruitBank\Debug\net9.0\AyCode.Core.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Database">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Database.dll</HintPath>
<HintPath>$(AyCodeRoot)AyCode.Database\bin\FruitBank\Debug\net9.0\AyCode.Database.dll</HintPath>
</Reference>
<Reference Include="AyCode.Entities">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Entities.dll</HintPath>
<HintPath>$(AyCodeRoot)AyCode.Entities\bin\FruitBank\Debug\net9.0\AyCode.Entities.dll</HintPath>
</Reference>
<Reference Include="AyCode.Entities.Server">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Entities.Server.dll</HintPath>
<HintPath>$(AyCodeRoot)AyCode.Entities.Server\bin\FruitBank\Debug\net9.0\AyCode.Entities.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Interfaces">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Interfaces.dll</HintPath>
<HintPath>$(AyCodeRoot)AyCode.Interfaces\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.dll</HintPath>
</Reference>
<Reference Include="AyCode.Interfaces.Server">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Interfaces.Server.dll</HintPath>
<HintPath>$(AyCodeRoot)AyCode.Interfaces.Server\bin\FruitBank\Debug\net9.0\AyCode.Interfaces.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Models.Server">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Models.Server.dll</HintPath>
<HintPath>$(AyCodeRoot)AyCode.Models.Server\bin\FruitBank\Debug\net9.0\AyCode.Models.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Services.dll</HintPath>
<HintPath>$(AyCodeRoot)AyCode.Services\bin\FruitBank\Debug\net9.0\AyCode.Services.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services.Server">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Services.Server.dll</HintPath>
<HintPath>$(AyCodeRoot)AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Utils">
<HintPath>$(FruitBankHybridRoot)FruitBank.Common.Server\bin\Debug\net9.0\AyCode.Utils.dll</HintPath>
<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>

View File

@ -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<ITypeFinder>.Instance = typeFinder;
builder.Services.AddSingleton<ITypeFinder>(typeFinder);
Console.WriteLine("[SANDBOX] TypeFinder registered");
// ===========================================
// === ENGINE ===
// ===========================================
var engine = new NopEngine();
Singleton<IEngine>.Instance = engine;
builder.Services.AddSingleton<IEngine>(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<IActionContextAccessor, ActionContextAccessor>();
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<AppSettings>.Instance = appSettings;
// ===========================================
// === FILE PROVIDER (DI) ===
// ===========================================
builder.Services.AddScoped<INopFileProvider, NopFileProvider>();
// ===========================================
// === ADATBÁZIS ÉS REPOSITORY ===
// ===========================================
builder.Services.AddScoped<INopDataProvider, MsSqlNopDataProvider>();
builder.Services.AddScoped(typeof(IRepository<>), typeof(EntityRepository<>));
// ===========================================
// === CACHE SZOLGÁLTATÁSOK ===
// ===========================================
builder.Services.AddTransient(typeof(IConcurrentCollection<>), typeof(ConcurrentTrie<>));
builder.Services.AddSingleton<ICacheKeyManager, CacheKeyManager>();
builder.Services.AddScoped<IShortTermCacheManager, PerRequestCacheManager>();
builder.Services.AddSingleton<ILocker, MemoryCacheLocker>();
builder.Services.AddSingleton<IStaticCacheManager, MemoryCacheManager>();
builder.Services.AddScoped<ICacheKeyService, MemoryCacheManager>();
// ===========================================
// === EVENT PUBLISHER ===
// ===========================================
builder.Services.AddSingleton<IEventPublisher, EventPublisher>();
// ===========================================
// === 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<IWebHelper, WebHelper>();
builder.Services.AddScoped<IUserAgentHelper, UserAgentHelper>();
builder.Services.AddScoped<IDateTimeHelper, DateTimeHelper>();
// Context
builder.Services.AddScoped<IWorkContext, WebWorkContext>();
builder.Services.AddScoped<IStoreContext, WebStoreContext>();
// Plugins
builder.Services.AddScoped<IPluginService, PluginService>();
builder.Services.AddScoped<OfficialFeedManager>();
// Settings & Config
builder.Services.AddScoped<ISettingService, SettingService>();
// Security & Permission
builder.Services.AddScoped<IPermissionService, PermissionService>();
builder.Services.AddScoped<IAclService, AclService>();
builder.Services.AddScoped<IEncryptionService, EncryptionService>();
// Authentication
builder.Services.AddScoped<IAuthenticationService, CookieAuthenticationService>();
builder.Services.AddScoped<IExternalAuthenticationService, NullExternalAuthenticationService>();
// Store
builder.Services.AddScoped<IStoreService, StoreService>();
builder.Services.AddScoped<IStoreMappingService, StoreMappingService>();
// Localization
builder.Services.AddScoped<ILanguageService, LanguageService>();
builder.Services.AddScoped<ILocalizationService, LocalizationService>();
builder.Services.AddScoped<ILocalizedEntityService, LocalizedEntityService>();
// Currency & Directory
builder.Services.AddScoped<ICurrencyService, CurrencyService>();
builder.Services.AddScoped<ICountryService, CountryService>();
builder.Services.AddScoped<IStateProvinceService, StateProvinceService>();
builder.Services.AddScoped<IMeasureService, MeasureService>();
builder.Services.AddScoped<IGeoLookupService, GeoLookupService>();
// Customer
builder.Services.AddScoped<ICustomerService, CustomerService>();
builder.Services.AddScoped<ICustomerRegistrationService, CustomerRegistrationService>();
builder.Services.AddScoped<ICustomerReportService, CustomerReportService>();
builder.Services.AddScoped<ICustomerActivityService, CustomerActivityService>();
builder.Services.AddScoped<INewsLetterSubscriptionService, NewsLetterSubscriptionService>();
// Address & Vendor & Affiliate
builder.Services.AddScoped<IAddressService, AddressService>();
builder.Services.AddScoped<IVendorService, VendorService>();
builder.Services.AddScoped<IAffiliateService, AffiliateService>();
// Generic Attribute
builder.Services.AddScoped<IGenericAttributeService, GenericAttributeService>();
// Maintenance
builder.Services.AddScoped<IMaintenanceService, MaintenanceService>();
// Catalog
builder.Services.AddScoped<IBackInStockSubscriptionService, BackInStockSubscriptionService>();
builder.Services.AddScoped<ICategoryService, CategoryService>();
builder.Services.AddScoped<ICompareProductsService, CompareProductsService>();
builder.Services.AddScoped<IRecentlyViewedProductsService, RecentlyViewedProductsService>();
builder.Services.AddScoped<IManufacturerService, ManufacturerService>();
builder.Services.AddScoped<IProductAttributeFormatter, ProductAttributeFormatter>();
builder.Services.AddScoped<IProductAttributeParser, ProductAttributeParser>();
builder.Services.AddScoped<IProductAttributeService, ProductAttributeService>();
builder.Services.AddScoped<IProductService, ProductService>();
builder.Services.AddScoped<ICopyProductService, CopyProductService>();
builder.Services.AddScoped<ISpecificationAttributeService, SpecificationAttributeService>();
builder.Services.AddScoped<IProductTemplateService, ProductTemplateService>();
builder.Services.AddScoped<ICategoryTemplateService, CategoryTemplateService>();
builder.Services.AddScoped<IManufacturerTemplateService, ManufacturerTemplateService>();
builder.Services.AddScoped<IProductTagService, ProductTagService>();
builder.Services.AddScoped<IReviewTypeService, ReviewTypeService>();
// Pricing (CustomPriceCalculationService a FruitBank-ból)
builder.Services.AddScoped<IPriceCalculationService, CustomPriceCalculationService>();
builder.Services.AddScoped<PriceCalculationService, CustomPriceCalculationService>();
builder.Services.AddScoped<IPriceFormatter, PriceFormatter>();
// Search
builder.Services.AddScoped<ISearchTermService, SearchTermService>();
// Orders
builder.Services.AddScoped<IOrderService, OrderService>();
builder.Services.AddScoped<IOrderReportService, OrderReportService>();
builder.Services.AddScoped<IOrderProcessingService, OrderProcessingService>();
builder.Services.AddScoped<IOrderTotalCalculationService, OrderTotalCalculationService>();
builder.Services.AddScoped<IShoppingCartService, ShoppingCartService>();
builder.Services.AddScoped<ICheckoutAttributeFormatter, CheckoutAttributeFormatter>();
builder.Services.AddScoped<IGiftCardService, GiftCardService>();
builder.Services.AddScoped<IReturnRequestService, ReturnRequestService>();
builder.Services.AddScoped<IRewardPointService, RewardPointService>();
builder.Services.AddScoped<ICustomNumberFormatter, CustomNumberFormatter>();
// Shipping
builder.Services.AddScoped<IShipmentService, ShipmentService>();
builder.Services.AddScoped<IShippingService, ShippingService>();
builder.Services.AddScoped<IDateRangeService, DateRangeService>();
// Tax
builder.Services.AddScoped<ITaxCategoryService, TaxCategoryService>();
builder.Services.AddScoped<ICheckVatService, CheckVatService>();
builder.Services.AddScoped<ITaxService, TaxService>();
// Payment
builder.Services.AddScoped<IPaymentService, PaymentService>();
// Discounts
builder.Services.AddScoped<IDiscountService, DiscountService>();
// Media
builder.Services.AddScoped<IDownloadService, DownloadService>();
builder.Services.AddScoped<IPictureService, PictureService>();
builder.Services.AddScoped<IVideoService, VideoService>();
// Messages & Notifications
builder.Services.AddScoped<IMessageTemplateService, MessageTemplateService>();
builder.Services.AddScoped<IQueuedEmailService, QueuedEmailService>();
builder.Services.AddScoped<ICampaignService, CampaignService>();
builder.Services.AddScoped<IEmailAccountService, EmailAccountService>();
builder.Services.AddScoped<IWorkflowMessageService, WorkflowMessageService>();
builder.Services.AddScoped<IMessageTokenProvider, MessageTokenProvider>();
builder.Services.AddScoped<ITokenizer, Tokenizer>();
builder.Services.AddScoped<ISmtpBuilder, SmtpBuilder>();
builder.Services.AddScoped<IEmailSender, EmailSender>();
builder.Services.AddScoped<INotificationService, NotificationService>();
// SEO & HTML
builder.Services.AddScoped<IUrlRecordService, UrlRecordService>();
builder.Services.AddScoped<IBBCodeHelper, BBCodeHelper>();
builder.Services.AddScoped<IHtmlFormatter, HtmlFormatter>();
builder.Services.AddScoped<INopUrlHelper, NopUrlHelper>();
// Logging
builder.Services.AddScoped<Nop.Services.Logging.ILogger, DefaultLogger>();
// Topics & Content
builder.Services.AddScoped<ITopicService, TopicService>();
builder.Services.AddScoped<ITopicTemplateService, TopicTemplateService>();
builder.Services.AddScoped<IBlogService, BlogService>();
builder.Services.AddScoped<INewsService, NewsService>();
builder.Services.AddScoped<IForumService, ForumService>();
builder.Services.AddScoped<IPollService, PollService>();
// GDPR
builder.Services.AddScoped<IGdprService, GdprService>();
// Export/Import
builder.Services.AddScoped<IExportManager, ExportManager>();
builder.Services.AddScoped<IImportManager, ImportManager>();
builder.Services.AddScoped<IPdfService, PdfService>();
builder.Services.AddScoped<IUploadService, UploadService>();
// Themes
builder.Services.AddScoped<IThemeProvider, ThemeProvider>();
builder.Services.AddScoped<IThemeContext, ThemeContext>();
// Schedule Tasks
builder.Services.AddSingleton<ITaskScheduler, Nop.Services.ScheduleTasks.TaskScheduler>();
builder.Services.AddTransient<IScheduleTaskRunner, ScheduleTaskRunner>();
builder.Services.AddScoped<IScheduleTaskService, ScheduleTaskService>();
// Installation
builder.Services.AddScoped<IInstallationService, InstallationService>();
builder.Services.AddScoped<IInstallationLocalizationService, InstallationLocalizationService>();
// Slug Route Transformer (ha van adatbázis)
builder.Services.AddScoped<SlugRouteTransformer>();
// Routing
builder.Services.AddSingleton<IRoutePublisher, RoutePublisher>();
// Roxy File Manager
builder.Services.AddScoped<IRoxyFilemanService, RoxyFilemanService>();
builder.Services.AddScoped<IRoxyFilemanFileProvider, RoxyFilemanFileProvider>();
// Web Framework
builder.Services.AddScoped<INopHtmlHelper, NopHtmlHelper>();
builder.Services.AddScoped<Nop.Web.Framework.Factories.IWidgetModelFactory, Nop.Web.Framework.Factories.WidgetModelFactory>();
builder.Services.AddScoped<IAdminMenu, AdminMenu>();
// 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<IExchangeRatePluginManager, NullExchangeRatePluginManager>();
builder.Services.AddScoped<ISearchPluginManager, NullSearchPluginManager>();
builder.Services.AddScoped<IDiscountPluginManager, NullDiscountPluginManager>();
builder.Services.AddScoped<IMultiFactorAuthenticationPluginManager, NullMultiFactorAuthenticationPluginManager>();
builder.Services.AddScoped<IWidgetPluginManager, NullWidgetPluginManager>();
builder.Services.AddScoped<IPaymentPluginManager, NullPaymentPluginManager>();
builder.Services.AddScoped<IPickupPluginManager, NullPickupPluginManager>();
builder.Services.AddScoped<IShippingPluginManager, NullShippingPluginManager>();
builder.Services.AddScoped<ITaxPluginManager, NullTaxPluginManager>();
builder.Services.AddScoped<IAuthenticationPluginManager, NullAuthenticationPluginManager>();
// ===========================================
// === NOP.WEB COMMON FACTORIES (Nop.Web\Infrastructure\NopStartup.cs) ===
// ===========================================
builder.Services.AddScoped<IDiscountSupportedModelFactory, DiscountSupportedModelFactory>();
builder.Services.AddScoped<ILocalizedModelFactory, LocalizedModelFactory>();
builder.Services.AddScoped<IStoreMappingSupportedModelFactory, StoreMappingSupportedModelFactory>();
// ===========================================
// === NOP.WEB ADMIN MODEL FACTORIES (Nop.Web\Infrastructure\NopStartup.cs) ===
// ===========================================
builder.Services.AddScoped<IAclSupportedModelFactory, AclSupportedModelFactory>();
builder.Services.AddScoped<IBaseAdminModelFactory, BaseAdminModelFactory>();
builder.Services.AddScoped<IActivityLogModelFactory, ActivityLogModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.IAddressModelFactory, Nop.Web.Areas.Admin.Factories.AddressModelFactory>();
builder.Services.AddScoped<IAddressAttributeModelFactory, AddressAttributeModelFactory>();
builder.Services.AddScoped<IAffiliateModelFactory, AffiliateModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.IBlogModelFactory, Nop.Web.Areas.Admin.Factories.BlogModelFactory>();
builder.Services.AddScoped<ICampaignModelFactory, CampaignModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.ICategoryModelFactory, Nop.Web.Areas.Admin.Factories.CategoryModelFactory>();
builder.Services.AddScoped<ICheckoutAttributeModelFactory, CheckoutAttributeModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.ICommonModelFactory, Nop.Web.Areas.Admin.Factories.CommonModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.ICountryModelFactory, Nop.Web.Areas.Admin.Factories.CountryModelFactory>();
builder.Services.AddScoped<ICurrencyModelFactory, CurrencyModelFactory>();
builder.Services.AddScoped<ICustomerAttributeModelFactory, CustomerAttributeModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.ICustomerModelFactory, Nop.Web.Areas.Admin.Factories.CustomerModelFactory>();
builder.Services.AddScoped<ICustomerRoleModelFactory, CustomerRoleModelFactory>();
builder.Services.AddScoped<IDiscountModelFactory, DiscountModelFactory>();
builder.Services.AddScoped<IEmailAccountModelFactory, EmailAccountModelFactory>();
builder.Services.AddScoped<IExternalAuthenticationMethodModelFactory, ExternalAuthenticationMethodModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.IForumModelFactory, Nop.Web.Areas.Admin.Factories.ForumModelFactory>();
builder.Services.AddScoped<IGiftCardModelFactory, GiftCardModelFactory>();
builder.Services.AddScoped<IHomeModelFactory, HomeModelFactory>();
builder.Services.AddScoped<ILanguageModelFactory, LanguageModelFactory>();
builder.Services.AddScoped<ILogModelFactory, LogModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.IManufacturerModelFactory, Nop.Web.Areas.Admin.Factories.ManufacturerModelFactory>();
builder.Services.AddScoped<IMeasureModelFactory, MeasureModelFactory>();
builder.Services.AddScoped<IMessageTemplateModelFactory, MessageTemplateModelFactory>();
builder.Services.AddScoped<IMultiFactorAuthenticationMethodModelFactory, MultiFactorAuthenticationMethodModelFactory>();
builder.Services.AddScoped<INewsletterSubscriptionModelFactory, NewsletterSubscriptionModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.INewsModelFactory, Nop.Web.Areas.Admin.Factories.NewsModelFactory>();
// IOrderModelFactory - FruitBank CustomOrderModelFactory felülírja!
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.IOrderModelFactory, CustomOrderModelFactory>();
builder.Services.AddScoped<IPaymentModelFactory, PaymentModelFactory>();
builder.Services.AddScoped<IPluginModelFactory, PluginModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.IPollModelFactory, Nop.Web.Areas.Admin.Factories.PollModelFactory>();
// IProductModelFactory - FruitBank CustomProductModelFactory felülírja!
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.IProductModelFactory, CustomProductModelFactory>();
builder.Services.AddScoped<IProductAttributeModelFactory, ProductAttributeModelFactory>();
builder.Services.AddScoped<IProductReviewModelFactory, ProductReviewModelFactory>();
builder.Services.AddScoped<IReportModelFactory, ReportModelFactory>();
builder.Services.AddScoped<IQueuedEmailModelFactory, QueuedEmailModelFactory>();
builder.Services.AddScoped<IRecurringPaymentModelFactory, RecurringPaymentModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.IReturnRequestModelFactory, Nop.Web.Areas.Admin.Factories.ReturnRequestModelFactory>();
builder.Services.AddScoped<IReviewTypeModelFactory, ReviewTypeModelFactory>();
builder.Services.AddScoped<IScheduleTaskModelFactory, ScheduleTaskModelFactory>();
builder.Services.AddScoped<ISecurityModelFactory, SecurityModelFactory>();
builder.Services.AddScoped<ISettingModelFactory, SettingModelFactory>();
builder.Services.AddScoped<IShippingModelFactory, ShippingModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.IShoppingCartModelFactory, Nop.Web.Areas.Admin.Factories.ShoppingCartModelFactory>();
builder.Services.AddScoped<ISpecificationAttributeModelFactory, SpecificationAttributeModelFactory>();
builder.Services.AddScoped<IStoreModelFactory, StoreModelFactory>();
builder.Services.AddScoped<ITaxModelFactory, TaxModelFactory>();
builder.Services.AddScoped<ITemplateModelFactory, TemplateModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.ITopicModelFactory, Nop.Web.Areas.Admin.Factories.TopicModelFactory>();
builder.Services.AddScoped<IVendorAttributeModelFactory, VendorAttributeModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.IVendorModelFactory, Nop.Web.Areas.Admin.Factories.VendorModelFactory>();
builder.Services.AddScoped<Nop.Web.Areas.Admin.Factories.IWidgetModelFactory, Nop.Web.Areas.Admin.Factories.WidgetModelFactory>();
// ===========================================
// === NOP.WEB PUBLIC FACTORIES (Nop.Web\Infrastructure\NopStartup.cs) ===
// ===========================================
builder.Services.AddScoped<Nop.Web.Factories.IAddressModelFactory, Nop.Web.Factories.AddressModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.IBlogModelFactory, Nop.Web.Factories.BlogModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.ICatalogModelFactory, Nop.Web.Factories.CatalogModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.ICheckoutModelFactory, Nop.Web.Factories.CheckoutModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.ICommonModelFactory, Nop.Web.Factories.CommonModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.ICountryModelFactory, Nop.Web.Factories.CountryModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.ICustomerModelFactory, Nop.Web.Factories.CustomerModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.IForumModelFactory, Nop.Web.Factories.ForumModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.IExternalAuthenticationModelFactory, Nop.Web.Factories.ExternalAuthenticationModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.IJsonLdModelFactory, Nop.Web.Factories.JsonLdModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.INewsModelFactory, Nop.Web.Factories.NewsModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.INewsletterModelFactory, Nop.Web.Factories.NewsletterModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.IOrderModelFactory, Nop.Web.Factories.OrderModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.IPollModelFactory, Nop.Web.Factories.PollModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.IPrivateMessagesModelFactory, Nop.Web.Factories.PrivateMessagesModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.IProductModelFactory, Nop.Web.Factories.ProductModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.IProfileModelFactory, Nop.Web.Factories.ProfileModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.IReturnRequestModelFactory, Nop.Web.Factories.ReturnRequestModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.IShoppingCartModelFactory, Nop.Web.Factories.ShoppingCartModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.ISitemapModelFactory, Nop.Web.Factories.SitemapModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.ITopicModelFactory, Nop.Web.Factories.TopicModelFactory>();
builder.Services.AddScoped<Nop.Web.Factories.IVendorModelFactory, Nop.Web.Factories.VendorModelFactory>();
// ===========================================
// === NOP.WEB HELPERS ===
// ===========================================
builder.Services.AddScoped<ITinyMceHelper, TinyMceHelper>();
// ===========================================
// === FRUITBANK PLUGIN SZOLGÁLTATÁSOK (PluginNopStartup-ból) ===
// ===========================================;
// Logger
builder.Services.AddScoped<IAcLogWriterBase, ConsoleLogWriter>();
builder.Services.AddTransient<INopLoggerMsSqlNopDataProvider, NopLoggerMsSqlNopDataProvider>();
builder.Services.AddScoped<IAcLogWriterBase, NopLogWriter>();
builder.Services.AddSingleton<LoggerToLoggerApiController>();
// Core
builder.Services.AddSingleton<ILockService, LockService>();
builder.Services.AddScoped<FruitBankAttributeService>();
// ===========================================
// === TESZT ENDPOINT ===
// ===========================================
// Event Consumer
builder.Services.AddScoped<IConsumer<OrderPlacedEvent>, EventConsumer>();
// Business Services
builder.Services.AddScoped<IOrderMeasurementService, OrderMeasurementService>();
builder.Services.AddScoped<MeasurementService>();
builder.Services.AddScoped<InnVoiceApiService>();
builder.Services.AddScoped<InnVoiceOrderService>();
builder.Services.AddScoped<CerebrasAPIService>();
builder.Services.AddScoped<OpenAIApiService>();
builder.Services.AddScoped<AICalculationService>();
builder.Services.AddScoped<PdfToImageService>();
// ReplicateService with HttpClient
builder.Services.AddScoped<ReplicateService>();
builder.Services.AddHttpClient<ReplicateService>(client =>
{
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", "r8_MUApXYIE5mRjxqy20tsGLehWBJkCzNj0Cwvrh");
});
// DbTable Services
builder.Services.AddScoped<ProductDtoDbTable>();
builder.Services.AddScoped<OrderDtoDbTable>();
builder.Services.AddScoped<OrderItemDtoDbTable>();
builder.Services.AddScoped<OrderItemPalletDbTable>();
builder.Services.AddScoped<PartnerDbTable>();
builder.Services.AddScoped<ShippingDbTable>();
builder.Services.AddScoped<ShippingDocumentDbTable>();
builder.Services.AddScoped<ShippingItemDbTable>();
builder.Services.AddScoped<ShippingItemPalletDbTable>();
builder.Services.AddScoped<FilesDbTable>();
builder.Services.AddScoped<ShippingDocumentToFilesDbTable>();
builder.Services.AddScoped<StockQuantityHistoryDtoDbTable>();
builder.Services.AddScoped<StockTakingDbTable>();
builder.Services.AddScoped<StockTakingItemDbTable>();
builder.Services.AddScoped<StockTakingItemPalletDbTable>();
// DbContext Services
builder.Services.AddScoped<StockTakingDbContext>();
builder.Services.AddScoped<FruitBankDbContext>();
// SignalR Services
builder.Services.AddScoped<SignalRSendToClientService>();
builder.Services.AddScoped<IFruitBankDataControllerServer, FruitBankDataController>();
builder.Services.AddScoped<ICustomOrderSignalREndpointServer, CustomOrderSignalREndpoint>();
builder.Services.AddScoped<IStockSignalREndpointServer, StockSignalREndpointServer>();
builder.Services.AddScoped<ITestSignalREndpointServer, TestSignalREndpoint>();
// ===========================================
// === 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<DevAdminSignalRHub>(fruitBankHubEndPoint, options =>
// 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);
@ -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}");

View File

@ -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;
/// <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
}
/// <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;
}
/// <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);
}
#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; }
}
#endregion

View File

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