Skip to content

Lab8#44

Open
slavik22 wants to merge 34 commits into
lenagrin:masterfrom
slavik22:lab8
Open

Lab8#44
slavik22 wants to merge 34 commits into
lenagrin:masterfrom
slavik22:lab8

Conversation

@slavik22
Copy link
Copy Markdown

@slavik22 slavik22 commented May 24, 2026

Screenshot 2026-05-24 at 15 03 30 Screenshot 2026-05-24 at 15 03 22 Screenshot 2026-05-24 at 15 03 11 Screenshot 2026-05-24 at 15 03 34

slavik22 added 30 commits May 24, 2026 11:37
…for testability

- Add ITcpListener interface and TcpListenerWrapper to decouple TcpListener
- Extract EchoServer into EchoServer.cs with injected ITcpListener and logger
- Extract UdpTimedSender into its own file; move Random to field to avoid per-call allocation
- Make HandleClientAsync public and accept Stream for direct unit testing
- Reduce Program.cs to entry-point only
…r and UdpTimedSender

- EchoServerTests: StartAsync lifecycle, HandleClientAsync echo logic,
  cancellation, stream exception handling, client connect/disconnect logging
- UdpTimedSenderTests: double-start guard, stop without start, restart
  after stop, dispose lifecycle
…pression, replace O(n) Count() loop in GetSamples with index-based iteration
slavik22 added 4 commits May 24, 2026 14:07
- Wrap independent asserts in Assert.Multiple across test files
- Replace Has.Count / .Count() on IEnumerable with Has.Exactly(n).Items
- Switch ReadAsync/WriteAsync to Memory-based overloads (S4583)
- Make _cts readonly in TcpClientWrapper; fix null-forgiving operator
- Split GetSamples into guard + private iterator (S3972)
- Fix IDisposable pattern in UdpTimedSender with Dispose(bool)
- Make _udpClient_MessageReceived static (S2325)
- Remove TODO comment; fix empty while block in Program.cs
- Add ErrorStream helper replacing Mock<Stream> for exception tests
…s; add coverlet.msbuild to EchoTcpServerTests

- Replace same-argument GetHashCode assertion with captured variable (NUnit2009)
- Use Is.EqualTo/Is.Not.EqualTo on objects directly instead of .Equals()+Is.True/False
- Replace Is.Not.EqualTo("string") with new object() to avoid NUnit2021 (incompatible types)
- Add coverlet.msbuild to EchoTcpServerTests.csproj so /p:CollectCoverage=true produces
  an OpenCover report; without it EchoTcpServer coverage was silently absent from SonarCloud
Integration tests spin up a local TcpListener on a random port so the
wrapper's SendBytesAsync (WriteAsync(data.AsMemory())) and
StartListeningAsync (ReadAsync(buffer.AsMemory(), token)) paths are
exercised — the three new lines changed in lab8 that had 0% coverage.

Also adds disconnect-when-not-connected and send-when-not-connected
edge-case tests to cover the guard branches.
SonarCloud rule S3903 flags types not in a named namespace. File-scoped
namespace syntax (namespace X;) is not recognized by older SonarCloud
C# plugin versions. Converted all EchoTcpServer and EchoTcpServerTests
files to block-style namespaces to resolve the two open issues.
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.

1 participant