--- source_files: - DataPRO/SensorDB.Test/SensorDataShould.cs - DataPRO/SensorDB.Test/IsoCodeShould.cs - DataPRO/SensorDB.Test/SensorCalibrationShould.cs generated_at: "2026-04-17T16:11:56.447984+00:00" model: "zai-org/GLM-5-FP8" schema_version: 1 sha256: "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 that `SensorData.GetInitialEUValue` throws a `NullReferenceException` with a specific message when no calibration record matches the provided excitation voltage. **Class: `IsoCodeShould`** * `void TestObject_ShouldReturnQuestionMark_WhenSetToNull()`: Test method verifying that the `IsoCode.TestObject` property normalizes `null` inputs to `"?"`. * `void TestObject_ShouldReturnQuestionMark_WhenSetToEmpty()`: Test method verifying that the `IsoCode.TestObject` property normalizes empty string inputs to `"?"`. * `void StringRepresentation_ShouldReturnISOCode()`: Test method verifying that `IsoCode.StringRepresentation` returns the full code when the object is initialized with a full string. * `void StringRepresentation_ShouldReturnISOCode_WithAppendedQuestionMark()`: Test method verifying that `IsoCode.StringRepresentation` pads shorter codes with trailing question marks (e.g., `"??RIBS0200HF"` becomes `"??RIBS0200HF????"`). **Class: `SensorCalibrationShould`** * `void IsCompatibleWithIEPE_ShouldReturnFalse_WhenSensorProportionalIsTrue()`: Verifies `SensorCalibration.IsCompatibleWithIEPE()` returns `false` if `IsProportional` is true. * `void IsCompatibleWithIEPE_ShouldReturnFalse_WhenSensorIsNonLinear()`: Verifies `SensorCalibration.IsCompatibleWithIEPE()` returns `false` if `NonLinear` is true. * `void IsCompatibleWithIEPE_ShouldReturnTrue()`: Verifies `SensorCalibration.IsCompatibleWithIEPE()` returns `true` if `NonLinear` and `IsProportional` are false. * `void ToNonLinearDisplayString_ShouldReturnEmpty_WhenNonLinearIsFalse()`: Verifies `SensorCalibration.ToNonLinearDisplayString(string, bool)` returns empty string if `NonLinear` is false. * `void ToNonLinearDisplayString_ShouldReturnEmpty_WhenNonLinearFormatIsNull()`: Verifies `SensorCalibration.ToNonLinearDisplayString(string, bool)` returns empty string if the format argument is null. * `void CompareTo_ShouldReturn1_ComparedWithNull()`: Verifies `SensorCalibration.CompareTo(object)` returns 1 when comparing against `null`. * `void CompareTo_ShouldReturn0_WhenObjectsHaveSameCalibrationDates()`: Verifies `SensorCalibration.CompareTo(object)` returns 0 when `CalibrationDate` properties are equal. * `void CompareTo_ShouldReturnNegative_WhenObjectsHaveDifferentCalibrationDates()`: Verifies `SensorCalibration.CompareTo(object)` returns non-zero for different dates. ### Invariants * **IsoCode Normalization:** The `IsoCode.TestObject` property appears to enforce a non-empty constraint, converting `null` or empty strings to `"?"`. * **ISO String Length:** The `IsoCode.StringRepresentation` implies a fixed-length format where missing characters are padded with `"?"`. * **IEPE Compatibility:** A sensor is compatible with IEPE only if it is neither `NonLinear` nor `IsProportional`. * **Comparison Logic:** `SensorCalibration` objects are compared based on their `CalibrationDate` property. ### 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_ShouldThrowException` expects a `NullReferenceException` for a "record not found" scenario. Typically, a specific domain exception or `KeyNotFoundException` would be preferred over a `NullReferenceException`, 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.