Skip to content

Lab 5: NetArchTest dependency and naming rules#22

Open
nik-bykoff wants to merge 6 commits intolenagrin:masterfrom
nik-bykoff:lab-05-arch-rules
Open

Lab 5: NetArchTest dependency and naming rules#22
nik-bykoff wants to merge 6 commits intolenagrin:masterfrom
nik-bykoff:lab-05-arch-rules

Conversation

@nik-bykoff
Copy link
Copy Markdown

Summary

Encode architectural conventions as executable tests. PR has two commits on purpose:

  1. Lab 5 (red) introduces NetSdrClient.ArchTests (NUnit + NetArchTest.Rules 1.3.2) with four rules. CI is intentionally red: NetworkingWrappers_ShouldBeSealed flags TcpClientWrapper.
  2. Lab 5 (green) seals TcpClientWrapper and UdpClientWrapper and moves UdpClientWrapper / IUdpClient into the NetSdrClientApp.Networking namespace so they are in scope of the rules. CI turns green again.

Architecture rules

Rule What it asserts
Messages_ShouldNotDependOn_Networking Domain (NetSdrClientApp.Messages) cannot reference transport.
Networking_ShouldNotDependOn_Messages Transport stays domain-agnostic.
Interfaces_InNetworking_ShouldStartWithI I* interface naming convention.
NetworkingWrappers_ShouldBeSealed *Wrapper types in transport are sealed.

Why two commits

The lab explicitly asks to demonstrate that ArchTest catches a real violation (red CI), then is fixed (green CI). Final state of the PR is green; both runs are visible in the Actions tab.

Test plan

  • dotnet test NetSdrClient.ArchTests/... reports 4/4 passing on lab-05-arch-rules HEAD.
  • dotnet test NetSdrClient.sln -c Release reports 18 unit tests + 4 arch tests all passing.
  • First commit alone reproduces the red state for any future regression test.

Discipline / Author

  • Subject: Реінжиніринг програмного забезпечення
  • Student: Биков Нікіта Вячеславович, group ПЗС-1

nik-bykoff added 6 commits May 4, 2026 21:31
- Move SONAR_PROJECT_KEY/SONAR_ORGANIZATION into workflow env block with explicit setup instructions for fork-based usage.

- Update README with student header, fork/upstream links and a table of all eight lab reports.

- Replace SonarCloud badges with placeholders for nik-bykoff fork.

- Add docs/labs/lab-01.md report describing manual SonarCloud steps, CI workflow layout and verification checklist.

- Ignore local .env files to prevent accidental token leaks.
- Rename NetSdrClient.Disconect to Disconnect (typo) and update callers/tests.

- Remove stray semicolon in StartIQAsync and unused JSType using-statics.

- Make responseTaskSource thread-safe via Interlocked.Exchange + TrySetResult.

- Replace Aggregate-on-empty-may-throw log formatting with string.Join in three places.

- Rewrite GetSamples from O(n^2) IEnumerable.Count loop to O(n) for-loop with reusable byte[4] buffer.

- Replace MD5-based UdpClientWrapper.GetHashCode with HashCode.Combine and add Equals override.

- Make TcpClientWrapper._cts nullable, mark _host/_port readonly, drop unused exception variable names.

- All eight existing unit tests still pass; compiler warnings dropped from 18 to 15 (rest are EchoTcpServer or NuGet).
- Add coverlet.msbuild to NetSdrClientAppTests with PrivateAssets=all.

- Add four NetSdrClient tests (ChangeFrequency, idempotent IQ flag, listener startup, no-op when disconnected).

- Add six NetSdrMessageHelper tests covering control-item/data-item roundtrip and GetSamples edge cases (8/16 bit, empty body, oversized width).

- Fix latent bug in TranslateMessage where Enum.IsDefined was called with ushort while ControlItemCodes underlying type is int.

- Re-enable Tests with coverage step in CI workflow with opencover output and Program exclusion.

- 18/18 tests passing locally; coverage of NetSdrClientApp module: line 45.86%, branch 26.92%, method 48.48%.
- Add internal HexFormatter.ToSpaceSeparatedHex used by TCP send log, TCP receive log and UDP samples log.

- Replace TcpClientWrapper.SendMessageAsync(byte[]) and SendMessageAsync(string) overloads with thin wrappers around private SendCoreAsync(byte[]).

- Collapse identical UdpClientWrapper.StopListening and Exit into StopCore via thin delegating wrappers.

- 18/18 tests still pass; behavior unchanged.
- Add NetSdrClient.ArchTests project (NUnit + NetArchTest.Rules 1.3.2) with reference to NetSdrClientApp.

- Encode four architecture rules:

    * Messages namespace must not depend on Networking.

    * Networking namespace must not depend on Messages.

    * Interfaces in Networking namespace start with I.

    * Wrapper classes in Networking namespace are sealed.

- Run is intentionally red on this commit (TcpClientWrapper is not sealed) to demonstrate ArchTest catching a real violation; the green fix follows in the next commit.
- Mark TcpClientWrapper and UdpClientWrapper as sealed to satisfy NetworkingWrappers_ShouldBeSealed.

- Move UdpClientWrapper and IUdpClient into the NetSdrClientApp.Networking namespace so they are scoped by the architectural rules.

- All four ArchTests now pass; existing 18 unit tests remain green.

- Adds docs/labs/lab-05.md describing the red-then-green CI demo.
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