Skip to content

Fixes in several unit tests#409

Merged
josesimoes merged 3 commits into
nanoframework:mainfrom
josesimoes:fix-unit-tests
Jul 10, 2026
Merged

Fixes in several unit tests#409
josesimoes merged 3 commits into
nanoframework:mainfrom
josesimoes:fix-unit-tests

Conversation

@josesimoes

@josesimoes josesimoes commented Jul 10, 2026

Copy link
Copy Markdown
Member

Description

  • Fix exception in ProtocolNotSupported.
  • Fix address not available test.
  • Fixed wrong asserts.
  • Closing sockets from tests now so that pool is not starved before test group ends.
  • Fix cancelation token too large.

Motivation and Context

  • Fixes broken unit tests.

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Unit Tests (add new Unit Test(s) or improved existing one(s), has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist:

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).
  • I have added new tests to cover my changes.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Socket exception tests now accommodate additional platform error codes, use Assert.ThrowsException directly, manage temporary sockets outside assertion lambdas, and force unavailable-address validation during connection.

Changes

Socket exception tests

Layer / File(s) Summary
Exception assertion handling
Tests/SocketTests/SocketExceptionsTests.cs
Protocol tests accept ProtocolNotSupported and simplify unsupported-protocol verification with Assert.ThrowsException.
Socket lifecycle and address validation
Tests/SocketTests/SocketExceptionsTests.cs
Temporary sockets are closed after assertions, and the unavailable-address test binds an unassigned IP before connecting to trigger the exception.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the PR as fixes across multiple unit tests.
Description check ✅ Passed The description is directly related to the test fixes and socket cleanup changes in the PR.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Tests/SocketTests/SocketExceptionsTests.cs`:
- Around line 60-64: Restore specific ErrorCode validation in
SocketExceptionTest4_ProtocolNotSupported: capture the SocketException thrown by
the socket construction and assert its ErrorCode matches the expected
ProtocolNotSupported value, consistent with SocketExceptionTest3.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: nanoframework/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8c252bca-545d-414a-8976-1d5166df64ac

📥 Commits

Reviewing files that changed from the base of the PR and between 923b423 and 434eb6c.

📒 Files selected for processing (1)
  • Tests/SocketTests/SocketExceptionsTests.cs

Comment thread Tests/SocketTests/SocketExceptionsTests.cs Outdated
- Fix exception in ProtocolNotSupported.
- Fix address not available test.
- Fixed wrong asserts.
- Closing sockets from tests now so that pool is not starved before test group ends.
@josesimoes josesimoes enabled auto-merge (squash) July 10, 2026 15:51
@nanoframework nanoframework deleted a comment from nfbot Jul 10, 2026
@josesimoes josesimoes merged commit 7e0da48 into nanoframework:main Jul 10, 2026
7 checks passed
@josesimoes josesimoes deleted the fix-unit-tests branch July 10, 2026 15:57
josesimoes added a commit that referenced this pull request Jul 13, 2026
***NO_CI***

(cherry picked from commit 7e0da48)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants