Skip to content

Create integration tests#18

Merged
cjung95 merged 5 commits intodevelopfrom
create-integration-tests
Oct 9, 2025
Merged

Create integration tests#18
cjung95 merged 5 commits intodevelopfrom
create-integration-tests

Conversation

@cjung95
Copy link
Copy Markdown
Owner

@cjung95 cjung95 commented Oct 9, 2025

Add integration tests to the project that simulate a server and a client to test the connection and web socket upgrade process and the stability of the connection.
Improve race condition safety
Add ConfigureAwait with continueOnCapturedContext parameter set to false to all awaited methods in the library

cjung95 added 4 commits April 5, 2025 21:58
Improve race condition safety by using atomic methods
Improve dispose processes of the server and the client
Improve error handling
Add LogLevel property to the server options
@cjung95 cjung95 requested a review from Copilot October 9, 2025 13:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds integration tests to verify WebSocket connection stability and implements race condition safety improvements across the library. The main focus is on adding comprehensive integration testing capabilities while improving thread safety and async operation handling.

  • Added new integration test project with server and client test scenarios for connection stability
  • Improved race condition safety using atomic operations (Interlocked) for state management
  • Added ConfigureAwait(false) to all async operations in the library to prevent deadlocks

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Jung.SimpleWebSocket.sln Added integration test project to solution
tests/Jung.SimpleWebSocket.IntegrationTests/Jung.SimpleWebSocket.IntegrationTests.csproj New integration test project configuration
tests/Jung.SimpleWebSocket.IntegrationTests/Program.cs Main entry point for running integration tests
tests/Jung.SimpleWebSocket.IntegrationTests/ProcedureProvider.cs Test procedure discovery and execution framework
tests/Jung.SimpleWebSocket.IntegrationTests/TestProcedure.cs Test procedure definition class
tests/Jung.SimpleWebSocket.IntegrationTests/Tests/BaseTest.cs Base class for integration tests
tests/Jung.SimpleWebSocket.IntegrationTests/Tests/TestInformationAttribute.cs Attribute for test metadata
tests/Jung.SimpleWebSocket.IntegrationTests/Tests/DisplayEventsServerTest.cs Server-side event display test
tests/Jung.SimpleWebSocket.IntegrationTests/Tests/SendMessagesLoopTest.cs Client stability test with message sending
src/Jung.SimpleWebSocket/SimpleWebSocketServer.cs Enhanced thread safety and ConfigureAwait implementation
src/Jung.SimpleWebSocket/SimpleWebSocketClient.cs Enhanced thread safety and ConfigureAwait implementation
src/Jung.SimpleWebSocket/Models/SimpleWebSocketServerOptions.cs Added LogLevel configuration option
src/Jung.SimpleWebSocket/Models/EventArguments/ClientDisconnectedArgs.cs Updated to handle nullable closing status
src/Jung.SimpleWebSocket/Exceptions/WebSocketConnectionException.cs New exception for connection-specific errors
src/Jung.SimpleWebSocket/Flows/ClientHandlingFlow.cs Added ConfigureAwait to async operations
src/Jung.SimpleWebSocket/Utility/AsyncEventRaiser.cs Added ConfigureAwait to async operations
src/Jung.SimpleWebSocket/Wrappers/NetworkStreamWrapper.cs Added ConfigureAwait to async operations
src/Jung.SimpleWebSocket/Wrappers/TcpListenerWrapper.cs Added ConfigureAwait to async operations
src/Jung.SimpleWebSocket/Wrappers/WebSocketUpgradeHandler.cs Added ConfigureAwait to async operations
tests/Jung.SimpleWebSocket.UnitTests/SimpleWebSocketTest.cs Fixed logger type and null coalescing operator usage

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +102 to +108
/// <para>0 = false, 1 = true</para>s
/// </summary>
private int _disposed;

/// <summary>
/// A flag indicating whether the server is disposing.
/// <para>0 = false, 1 = true</para>s
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed extraneous 's' at the end of the comment.

Suggested change
/// <para>0 = false, 1 = true</para>s
/// </summary>
private int _disposed;
/// <summary>
/// A flag indicating whether the server is disposing.
/// <para>0 = false, 1 = true</para>s
/// <para>0 = false, 1 = true</para>
/// </summary>
private int _disposed;
/// <summary>
/// A flag indicating whether the server is disposing.
/// <para>0 = false, 1 = true</para>

Copilot uses AI. Check for mistakes.

/// <summary>
/// A flag indicating whether the server is disposing.
/// <para>0 = false, 1 = true</para>s
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed extraneous 's' at the end of the comment.

Suggested change
/// <para>0 = false, 1 = true</para>s
/// <para>0 = false, 1 = true</para>

Copilot uses AI. Check for mistakes.
await client.WebSocket.CloseAsync(WebSocketCloseStatus.EndpointUnavailable, "Server is shutting down", linkedTokenSource.Token);
ActiveClients.TryRemove(client.Id, out _);
client?.Dispose();
// Ignore the exception, because it's no the servers problem if a client does not close the connection
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected 'no' to 'not' in the comment.

Suggested change
// Ignore the exception, because it's no the servers problem if a client does not close the connection
// Ignore the exception, because it's not the server's problem if a client does not close the connection

Copilot uses AI. Check for mistakes.
{
try
{
if(!client.IsConnected)
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after 'if' keyword. Should be 'if (!client.IsConnected)' following C# coding conventions.

Suggested change
if(!client.IsConnected)
if (!client.IsConnected)

Copilot uses AI. Check for mistakes.
@cjung95 cjung95 merged commit 50b18f2 into develop Oct 9, 2025
@cjung95 cjung95 deleted the create-integration-tests branch October 9, 2025 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants