Files

46 lines
2.7 KiB
Markdown
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.Common.Tests/ChannelTypeUtilityShould.cs
- Common/DTS.Common.Tests/NetworkUtilsShould.cs
- Common/DTS.Common.Tests/LinearizationFormulaShould.cs
- Common/DTS.Common.Tests/GroupChannelShould.cs
- Common/DTS.Common.Tests/FilterClassShould.cs
generated_at: "2026-04-16T14:12:11.899792+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "6d6fac19105f4e74"
---
# DTS.Common.Tests
## Purpose
This module contains the unit test suite for the `DTS.Common` library, which provides core utilities and domain logic for sensor management, signal processing, and network configuration. Specifically, it validates the behavior of sensor channel type parsing, linearization formulas for engineering unit conversion, ISO-compliant filter class resolution, and network connection string parsing.
## Public Interface
The following classes and methods are tested by this module. The actual implementations reside in `DTS.Common.Classes.Sensors`, `DTS.Common.Utils`, and `DTS.Common.Classes.Groups`.
### `DTS.Common.Classes.Sensors.ChannelTypeUtility`
* `string ParseSensorKnownChannelType(string sensorName)`
* Extracts a known channel type identifier from the beginning of a sensor name string.
* Returns `string.Empty` if the input is null, empty, has fewer than 2 characters, or starts with an unknown 2-character prefix.
* Returns the string representation of a `KnownChannelTypes` enum value if the prefix is valid.
### `DTS.Common.Utils.NetworkUtils`
* `bool TryParseConnectionString(string connectionString, out string ipAddress)`
* Attempts to extract an IP address from a connection string.
* Returns `true` and populates `ipAddress` (stripped of port and protocol) if a valid IP is found.
* Returns `false` for null inputs, empty strings, or non-IP connection strings (e.g., USB device paths).
* Supports formats: `IP`, `IP:Port`, `protocol://IP:Port` (e.g., `http`, `udp`).
### `DTS.Common.Classes.Sensors.LinearizationFormula`
* `double GetLinearizedValue(double input, int decimalPlaces, bool? proportional)`
* Calculates the engineering unit value from a raw input using polynomial coefficients defined in `PolynomialCoefficients`.
* Behavior changes based on the `proportional` flag:
* `false`: Uses a specific calculation logic (implied "NonLinear" path).
* `true` or `null`: Uses a different calculation logic. Note that passing `null` behaves identically to `true`.
* `NonLinearStyles NonLinearStyle` (Property)
* Defaults to `NonLinearStyles.Polynomial` if not explicitly set.
### `DTS.Common.Classes.Groups.GroupChannel`
* `FilterClass GetFilterClassFromISOCode(ISoftwareFilter[] filters, string isoCodeString)`