7.3 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||
|---|---|---|---|---|---|---|---|---|---|
|
2026-04-17T15:36:48.677576+00:00 | zai-org/GLM-5-FP8 | 1 | ea00a32036ad9490 |
DTS.Common.Tests Module Documentation
1. Purpose
This module contains unit tests for the DTS.Common library, which provides core utility classes and data structures for sensor configuration, network connection handling, signal linearization, and filter class management. The tests validate parsing logic, mathematical transformations, and mapping behaviors for sensor-related domain concepts including channel types, network connection strings, linearization formulas, and ISO-compliant filter classifications.
2. Public Interface
The following classes and methods are under test (the actual production interfaces being validated):
ChannelTypeUtility (inferred from DTS.Common.Classes.Sensors)
static string ParseSensorKnownChannelType(string sensorName)- Parses a sensor name string to extract a known channel type tag. Returns the channel type as a string matching aKnownChannelTypesenum value, or an empty string if parsing fails.
NetworkUtils (inferred from DTS.Common.Utils)
static bool TryParseConnectionString(string connectionString, out string ipAddress)- Attempts to extract an IP address from a connection string. Returnstrueand populatesipAddressif successful; returnsfalseotherwise. Handles formats: bare IP, IP:port, and protocol-prefixed URLs (e.g.,udp://,http://).
LinearizationFormula (inferred from DTS.Common.Classes.Sensors)
double GetLinearizedValue(double input, int coefficientCount, bool? isProportional)- Computes a linearized engineering unit value using polynomial coefficients. TheisProportionalparameter affects the calculation behavior.double[] PolynomialCoefficients- Property containing the polynomial coefficients for linearization.NonLinearStyles NonLinearStyle- Property indicating the linearization style; defaults toNonLinearStyles.Polynomial.
GroupChannel (inferred from DTS.Common.Classes.Groups)
GroupChannel(bool flag, string groupName, IGroup group, IChannelSetting[] settings)- Constructor accepting a boolean flag, group name, group interface, and channel settings array.FilterClass GetFilterClassFromISOCode(ISoftwareFilter[] filters, string isoCodeString)- Maps an ISO code (extracted from position 15 of the input string) to aFilterClassobject containingFClassandFrequencyproperties.
FilterClass (inferred from DTS.Common.Classes.Sensors)
static FilterClass GetFilterClassFromString(string filterString)- Parses a filter class string (e.g.,"CFC 1000","1700Hz","None") into aFilterClassobject.static FilterClass GetDefaultFilterClass(List<ISoftwareFilter> softwareFilters)- Returns the default filter class by examining theIsDefaultproperty on eachISoftwareFilterin the list.static double GetFrequencyFromFilterClassType(FilterClassType filterClassType)- Returns the associated frequency for a givenFilterClassType.FilterClassType FClass- Property indicating the filter class type.double Frequency- Property indicating the filter frequency in Hz.
3. Invariants
ChannelTypeUtility
ParseSensorKnownChannelTypealways returns a non-null string (empty string on failure).- Valid channel type prefixes are exactly 2 characters and must match a
KnownChannelTypesenum value. - Input strings shorter than 2 characters always return empty string.
NetworkUtils
TryParseConnectionStringreturnsfalsefor null input without throwing.- USB device paths (format
\\?\usb#...) are not parsed as IP addresses. - Protocol prefixes (
udp://,http://) are stripped before IP extraction. - Port numbers are stripped from the output
ipAddress.
LinearizationFormula
NonLinearStyledefaults toNonLinearStyles.Polynomialwhen not explicitly set.isProportionalvalues oftrueandnullproduce equivalent (non-proportional) behavior based on test assertions.
GroupChannel
- ISO code is extracted from character index 15 (16th character) of the input string.
- Unknown ISO codes default to
FilterClassType.CFC1000.
FilterClass
GetFilterClassFromStringreturnsFilterClassType.Unfilteredfor null, empty, or invalid inputs.GetDefaultFilterClassreturnsFilterClassType.CFC1000when the input list is null or empty.GetFrequencyFromFilterClassTypethrowsExceptionforFilterClassType.AdHoc(AdHoc filters require explicit frequency).
ISO Code to FilterClassType Mapping
| ISO Code | FilterClassType | Frequency |
|---|---|---|
| 'A' | CFC1000 | 1650 Hz |
| 'B' | CFC600 | 1000 Hz |
| 'C' | CFC180 | 300 Hz |
| 'D' | CFC60 | 100 Hz |
| '0' | Unfiltered | -2 |
| 'P' | None | 0 |
| 'S' | AdHoc | Variable (from filter) |
4. Dependencies
This module depends on:
- NUnit.Framework - Testing framework for assertions and test attributes.
- NSubstitute - Mocking library for interface substitution.
- DTS.Common.Classes.Sensors - Contains
ChannelTypeUtility,LinearizationFormula,FilterClass,KnownChannelTypes. - DTS.Common.Utils - Contains
NetworkUtils. - DTS.Common.Enums.Sensors - Contains
FilterClassType,NonLinearStyles. - DTS.Common.Interface.Sensors - Contains
ISoftwareFilter. - DTS.Common.Interface.Channels - Contains
IChannelSetting. - DTS.Common.Interface.Groups.GroupList - Contains
IGroup.
What depends on this module:
- This is a test project; no production code depends on it.
5. Gotchas
-
Typo in test method name:
ParseSensorKnownChannelType_ShouldRetuenEmpty_WhenPassedNull(and similar methods) misspells "Return" as "Retuen". This is a naming issue only but may cause confusion when searching for test methods. -
Missing
[Test]attribute: The methodGetFilterClassFromISOCode_ShouldReturnNoneWhenIsoIsPinGroupChannelShould.cslacks a[Test]attribute and will not execute as a test. -
ISO code position assumption:
GetFilterClassFromISOCodeassumes the ISO code is always at index 15 of the input string. The test uses"???????????????X"patterns (15 question marks + code) to validate this, but the source does not document what the preceding characters represent. -
AdHoc frequency exception: Calling
GetFrequencyFromFilterClassType(FilterClassType.AdHoc)throws an exception. Consumers must handle AdHoc filters separately by reading theFrequencyproperty directly. -
Unfiltered frequency value:
FilterClassType.Unfilteredmaps to frequency-2, not0. This is a sentinel value and may affect logic that assumes non-negative frequencies. -
Proportional flag behavior: The test
GetLinearizedValue_ShouldReturnCorrectEU_OnNonLinearAndProportionalSpecifiedAsNullindicates thatnullandtruefor theisProportionalparameter produce the same result, which is counterintuitive. The expected behavior fornullvstruevsfalseis not clearly documented in the tests.