4.2 KiB
4.2 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-17T16:11:56.447984+00:00 | zai-org/GLM-5-FP8 | 1 | f407d582ab87c155 |
SensorDB.Test
Purpose
This module serves as the unit test suite for the DTS.SensorDB namespace. It validates the business logic of sensor data handling, calibration compatibility, and ISO code formatting. It uses NUnit as the test framework and NSubstitute for mocking dependencies.
Public Interface
Class: SensorDataShould
void GetInitialEUValue_ShouldThrowException(): Test method verifying thatSensorData.GetInitialEUValuethrows aNullReferenceExceptionwith a specific message when no calibration record matches the provided excitation voltage.
Class: IsoCodeShould
void TestObject_ShouldReturnQuestionMark_WhenSetToNull(): Test method verifying that theIsoCode.TestObjectproperty normalizesnullinputs to"?".void TestObject_ShouldReturnQuestionMark_WhenSetToEmpty(): Test method verifying that theIsoCode.TestObjectproperty normalizes empty string inputs to"?".void StringRepresentation_ShouldReturnISOCode(): Test method verifying thatIsoCode.StringRepresentationreturns the full code when the object is initialized with a full string.void StringRepresentation_ShouldReturnISOCode_WithAppendedQuestionMark(): Test method verifying thatIsoCode.StringRepresentationpads shorter codes with trailing question marks (e.g.,"??RIBS0200HF"becomes"??RIBS0200HF????").
Class: SensorCalibrationShould
void IsCompatibleWithIEPE_ShouldReturnFalse_WhenSensorProportionalIsTrue(): VerifiesSensorCalibration.IsCompatibleWithIEPE()returnsfalseifIsProportionalis true.void IsCompatibleWithIEPE_ShouldReturnFalse_WhenSensorIsNonLinear(): VerifiesSensorCalibration.IsCompatibleWithIEPE()returnsfalseifNonLinearis true.void IsCompatibleWithIEPE_ShouldReturnTrue(): VerifiesSensorCalibration.IsCompatibleWithIEPE()returnstrueifNonLinearandIsProportionalare false.void ToNonLinearDisplayString_ShouldReturnEmpty_WhenNonLinearIsFalse(): VerifiesSensorCalibration.ToNonLinearDisplayString(string, bool)returns empty string ifNonLinearis false.void ToNonLinearDisplayString_ShouldReturnEmpty_WhenNonLinearFormatIsNull(): VerifiesSensorCalibration.ToNonLinearDisplayString(string, bool)returns empty string if the format argument is null.void CompareTo_ShouldReturn1_ComparedWithNull(): VerifiesSensorCalibration.CompareTo(object)returns 1 when comparing againstnull.void CompareTo_ShouldReturn0_WhenObjectsHaveSameCalibrationDates(): VerifiesSensorCalibration.CompareTo(object)returns 0 whenCalibrationDateproperties are equal.void CompareTo_ShouldReturnNegative_WhenObjectsHaveDifferentCalibrationDates(): VerifiesSensorCalibration.CompareTo(object)returns non-zero for different dates.
Invariants
- IsoCode Normalization: The
IsoCode.TestObjectproperty appears to enforce a non-empty constraint, convertingnullor empty strings to"?". - ISO String Length: The
IsoCode.StringRepresentationimplies a fixed-length format where missing characters are padded with"?". - IEPE Compatibility: A sensor is compatible with IEPE only if it is neither
NonLinearnorIsProportional. - Comparison Logic:
SensorCalibrationobjects are compared based on theirCalibrationDateproperty.
Dependencies
- Internal Dependencies:
DTS.SensorDB,DTS.Common.Interface.Sensors,DTS.Common.Enums,DTS.Common.Classes.Sensors,DTS.Common.Enums.Sensors. - External Packages:
NUnit.Framework,NSubstitute.
Gotchas
- Exception Type Choice: The test
GetInitialEUValue_ShouldThrowExceptionexpects aNullReferenceExceptionfor a "record not found" scenario. Typically, a specific domain exception orKeyNotFoundExceptionwould be preferred over aNullReferenceException, which usually indicates a bug (null dereference). The test explicitly checks for a custom message, suggesting the code might be throwing this exception deliberately, which is unusual.