Skip to content

test(common): pin UnixTime module for Stryker mutation coverage - #243

Draft
ottobolyos wants to merge 1 commit into
TrakHound:masterfrom
ottobolyos:test/common-unixtime-mutation-coverage
Draft

test(common): pin UnixTime module for Stryker mutation coverage#243
ottobolyos wants to merge 1 commit into
TrakHound:masterfrom
ottobolyos:test/common-unixtime-mutation-coverage

Conversation

@ottobolyos

Copy link
Copy Markdown
Contributor

Summary

Refs #242 — first module targeted under the Stryker.NET mutation-coverage campaign for MTConnect.NET-Common. Adds a focused NUnit fixture that pins every mutation-visible constant, branch, and arithmetic step in the UnixTime module.

  • Adds `UnixTimeTests` (24 [Test] methods, 285 LOC) covering `UnixDateTime.Now`, `UnixTimeExtensions.EpochTime`, `UnixTimeExtensions.EpochTicks`, and the six extension methods on `DateTime` / `long` (`ToUnixTime`, `ToUnixUtcTime`, `ToUnixUTCTime`, `FromUnixTime`, `ToDateTime`, `ToLocalDateTime`).
  • Pins the `EpochTime` constant field-by-field (year / month / day / hour / minute / second / millisecond / Kind) so a constant-substitution mutation is killed on every one.
  • Pins the `EpochTicks` literal both against the raw `621355968000000000` value and against a BCL-computed `new DateTime(1970,1,1,0,0,0,Utc).Ticks`, so a numeric-substitution mutation on the constant is killed.
  • Covers every DateTimeKind arm of `ToUnixTime` and `ToUnixUtcTime` — Utc no-op, Local branch, Unspecified branch — plus the explicit `Utc` / `Local` / `Unspecified` `unspecifiedAssume` arms of `ToUnixUtcTime`.
  • Local-branch assertions use `TimeZoneInfo.ConvertTimeToUtc(local, TimeZoneInfo.Local)` for the expected value so the tests hold in every timezone including UTC-offset-zero hosts (CI matrix + bluefin).
  • Pins the `ToUnixUTCTime` alias to `ToUnixUtcTime` across every Kind + assumption combination, killing a "return literal / drop the delegation" mutation on the alias body.
  • Pins boundary values (`+1 tick`, `-1 tick` around epoch) and pre-epoch instants on `ToUnixTime` and `FromUnixTime`, killing off-by-one and sign-swap arithmetic mutations.
  • Pins the `ToDateTime` and `ToLocalDateTime` long-extension aliases against `FromUnixTime` across six tick samples (0, +/-1, +/- epoch-ticks, contemporary).
  • Adds round-trip identity assertions on Utc DateTimes across five spread instants (epoch, pre-epoch, y2000, contemporary, y2099) and preservation-of-ticks on Unspecified DateTimes.
  • Pins `UnixDateTime.Now` to a two-second window around `DateTime.UtcNow.ToUnixTime()` (kills every constant-return mutation including `Now → 0`, `Now → 1`, and off-by-epoch mutations without ever spanning the epoch-offset a mutation could introduce) and asserts two consecutive reads are monotone non-decreasing.

Zero production-code changes — test additions only.

Depends on

(no in-flight PR dependencies — merges cleanly against master or the head of the train.)

ottobolyos added a commit to ottobolyos/mtconnect.net that referenced this pull request Aug 20, 2026
ottobolyos added a commit to ottobolyos/mtconnect.net that referenced this pull request Aug 20, 2026
ottobolyos added a commit to ottobolyos/mtconnect.net that referenced this pull request Aug 21, 2026
… into integration/up-to-pr-243

Cascade rebuild after integration/up-to-pr-249 refresh — PR TrakHound#241 cycle-3
propagated through the queue-head merge; the PR TrakHound#243 test coverage
addition merges cleanly onto the new int-249 tip because its diff
touches disjoint UnixTime test files only.
@ottobolyos
ottobolyos force-pushed the test/common-unixtime-mutation-coverage branch from 5fb6057 to 6d61d64 Compare August 21, 2026 08:34
Adds 22 focused NUnit tests covering the UnixTime module (114 LOC,
zero prior test references) — the first module targeted under the
Stryker mutation-coverage-raising campaign for MTConnect.NET-Common
(TrakHound#242).

Coverage surface (every mutation-visible constant, branch, and
arithmetic step):

- EpochTime constant: year/month/day/hour/minute/second/Kind pinned.
- EpochTicks constant: pinned against a BCL-computed epoch tick count
  and against the literal 621355968000000000.
- ToUnixTime: epoch → 0, +/-1 tick boundaries, Utc arithmetic,
  Local-branch conversion via TimeZoneInfo (timezone-independent),
  Unspecified-treated-as-Utc semantics.
- ToUnixUtcTime: Utc no-op, Local-branch conversion, default Utc
  assumption for Unspecified, explicit Utc/Local/Unspecified
  assumptions for the unspecifiedAssume argument (each arm hit).
- ToUnixUTCTime: alias parity with ToUnixUtcTime for every
  Kind + assumption combination.
- FromUnixTime: 0 → epoch, positive ticks, negative ticks.
- ToDateTime (long extension): alias parity with FromUnixTime across
  6 tick samples including both epoch offsets.
- ToLocalDateTime: Kind=Local + instant-equality parity with
  FromUnixTime(t).ToLocalTime().
- Round-trip invariants: ToUnixTime ∘ FromUnixTime = identity on Utc
  across 5 spread instants (epoch, pre-epoch, y2000, contemporary,
  y2099); Unspecified round-trip preserves ticks with Kind
  normalising to Utc.
- UnixDateTime.Now: bounded to a two-second window around BCL
  UtcNow (kills every constant-return and off-by-epoch mutant);
  two consecutive reads are monotone non-decreasing.

Local-branch tests use TimeZoneInfo.ConvertTimeToUtc so the
assertions hold in every timezone including UTC hosts.

Refs TrakHound#242
@ottobolyos
ottobolyos force-pushed the test/common-unixtime-mutation-coverage branch from 6d61d64 to cb9222c Compare August 21, 2026 16:07
ottobolyos added a commit to ottobolyos/mtconnect.net that referenced this pull request Aug 21, 2026
ottobolyos added a commit to ottobolyos/mtconnect.net that referenced this pull request Aug 21, 2026
ottobolyos added a commit to ottobolyos/mtconnect.net that referenced this pull request Aug 21, 2026
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