diff --git a/.gitea/workflows/publish-nugets.yaml b/.gitea/workflows/publish-nugets.yaml index c92dc17..cbb6e48 100644 --- a/.gitea/workflows/publish-nugets.yaml +++ b/.gitea/workflows/publish-nugets.yaml @@ -25,7 +25,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.x + dotnet-version: 10.x - name: Restore dependencies run: dotnet restore diff --git a/TestClient.csx b/TestClient.csx deleted file mode 100644 index 549d685..0000000 --- a/TestClient.csx +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env dotnet-script -#r "nuget: Grpc.Net.Client, 2.70.0" -#r "nuget: Google.Protobuf, 3.28.3" -#r "nuget: Grpc.Tools, 2.70.0" - -using Grpc.Net.Client; -using Grpc.Core; -using System; -using System.Threading.Tasks; - -// We'll use reflection/dynamic to call the gRPC service -// This is a simple HTTP/2 test - -var handler = new HttpClientHandler -{ - ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator -}; - -using var channel = GrpcChannel.ForAddress("http://localhost:5000", new GrpcChannelOptions -{ - HttpHandler = handler -}); - -Console.WriteLine("Connected to gRPC server at http://localhost:5000"); -Console.WriteLine("Channel state: " + channel.State); - -// Test basic connectivity -try -{ - await channel.ConnectAsync(); - Console.WriteLine("Successfully connected!"); -} -catch (Exception ex) -{ - Console.WriteLine($"Connection failed: {ex.Message}"); -} diff --git a/TestGrpcClient/Program.cs b/TestGrpcClient/Program.cs deleted file mode 100644 index 1180f3a..0000000 --- a/TestGrpcClient/Program.cs +++ /dev/null @@ -1,100 +0,0 @@ -using Grpc.Core; -using Grpc.Net.Client; -using Svrnty.CQRS.Grpc.Sample.Grpc; - -Console.WriteLine("=== gRPC Client Validation Test ==="); -Console.WriteLine(); - -// Create a gRPC channel -using var channel = GrpcChannel.ForAddress("http://localhost:5000"); - -// Create the gRPC client -var client = new CommandService.CommandServiceClient(channel); - -// Test 1: Valid request -Console.WriteLine("Test 1: Valid AddUser request..."); -var validRequest = new AddUserCommandRequest -{ - Name = "John Doe", - Email = "john.doe@example.com", - Age = 30 -}; - -try -{ - var response = await client.AddUserAsync(validRequest); - Console.WriteLine($"✓ Success! User added with ID: {response.Result}"); -} -catch (RpcException ex) -{ - Console.WriteLine($"✗ Unexpected error: {ex.Status.Detail}"); -} - -Console.WriteLine(); - -// Test 2: Invalid email (empty) -Console.WriteLine("Test 2: Invalid email (empty)..."); -var invalidEmailRequest = new AddUserCommandRequest -{ - Name = "Jane Doe", - Email = "", - Age = 25 -}; - -try -{ - var response = await client.AddUserAsync(invalidEmailRequest); - Console.WriteLine($"✗ Unexpected success! Validation should have failed."); -} -catch (RpcException ex) -{ - Console.WriteLine($"✓ Validation caught! Status: {ex.StatusCode}"); - Console.WriteLine($" Message: {ex.Status.Detail}"); -} - -Console.WriteLine(); - -// Test 3: Invalid email format -Console.WriteLine("Test 3: Invalid email format..."); -var badEmailRequest = new AddUserCommandRequest -{ - Name = "Bob Smith", - Email = "not-an-email", - Age = 40 -}; - -try -{ - var response = await client.AddUserAsync(badEmailRequest); - Console.WriteLine($"✗ Unexpected success! Validation should have failed."); -} -catch (RpcException ex) -{ - Console.WriteLine($"✓ Validation caught! Status: {ex.StatusCode}"); - Console.WriteLine($" Message: {ex.Status.Detail}"); -} - -Console.WriteLine(); - -// Test 4: Invalid age (0) -Console.WriteLine("Test 4: Invalid age (0)..."); -var invalidAgeRequest = new AddUserCommandRequest -{ - Name = "Alice Brown", - Email = "alice@example.com", - Age = 0 -}; - -try -{ - var response = await client.AddUserAsync(invalidAgeRequest); - Console.WriteLine($"✗ Unexpected success! Validation should have failed."); -} -catch (RpcException ex) -{ - Console.WriteLine($"✓ Validation caught! Status: {ex.StatusCode}"); - Console.WriteLine($" Message: {ex.Status.Detail}"); -} - -Console.WriteLine(); -Console.WriteLine("All tests completed!"); diff --git a/TestGrpcClient/Protos/cqrs_services.proto b/TestGrpcClient/Protos/cqrs_services.proto deleted file mode 100644 index 1857eeb..0000000 --- a/TestGrpcClient/Protos/cqrs_services.proto +++ /dev/null @@ -1,58 +0,0 @@ -syntax = "proto3"; - -option csharp_namespace = "Svrnty.CQRS.Grpc.Sample.Grpc"; - -package cqrs; - -// Command service for CQRS operations -service CommandService { - // Adds a new user and returns the user ID - rpc AddUser (AddUserCommandRequest) returns (AddUserCommandResponse); - - // Removes a user - rpc RemoveUser (RemoveUserCommandRequest) returns (RemoveUserCommandResponse); -} - -// Query service for CQRS operations -service QueryService { - // Fetches a user by ID - rpc FetchUser (FetchUserQueryRequest) returns (FetchUserQueryResponse); -} - -// Request message for adding a user -message AddUserCommandRequest { - string name = 1; - string email = 2; - int32 age = 3; -} - -// Response message containing the added user ID -message AddUserCommandResponse { - int32 result = 1; -} - -// Request message for removing a user -message RemoveUserCommandRequest { - int32 user_id = 1; -} - -// Response message for remove user (empty) -message RemoveUserCommandResponse { -} - -// Request message for fetching a user -message FetchUserQueryRequest { - int32 user_id = 1; -} - -// Response message containing the user -message FetchUserQueryResponse { - User result = 1; -} - -// User entity -message User { - int32 id = 1; - string name = 2; - string email = 3; -} diff --git a/TestGrpcClient/TestGrpcClient.csproj b/TestGrpcClient/TestGrpcClient.csproj deleted file mode 100644 index d7a801f..0000000 --- a/TestGrpcClient/TestGrpcClient.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - Exe - net10.0 - enable - enable - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - -