7.2 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T03:51:24.502617+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 91da420b0b2120ea |
DTS.Common.Import.Tests
Documentation: DTS.Common.Import.Tests Unit Test Module
1. Purpose
This module contains unit tests for the DTS.Common.Import functionality, specifically validating the behavior of GroupHelper and CalibrationImport classes. Its role is to ensure correctness, robustness, and invariants of data import logic—particularly around group creation, channel ordering, sensor ID normalization, and calibration record handling—including edge cases such as null inputs and excitation voltage mismatches. It does not contain production logic itself but serves as the authoritative specification for expected behavior of the tested components.
2. Public Interface
The test file itself does not expose a public API; it tests public members of other modules. Based on test usage, the following public APIs are referenced:
GroupHelper.CreateEmptyGroup()
- Signature:
static Group CreateEmptyGroup()(inferred from usage) - Behavior: Creates a new
Groupinstance withLastModifiedByinitialized to"---".
GroupHelper.ReverseChannelOrder(TestTemplate, Dictionary<string, string>, List<SensorData>)
- Signature:
static List<T> ReverseChannelOrder<T>(TestTemplate testTemplate, Dictionary<string, string> channelMap, List<SensorData> sensors)(inferred from usage) - Behavior: Safely handles null inputs for
testTemplateandsensorsby returning an empty list. Otherwise, performs channel reordering based onchannelMap. (Exact implementation details not visible.)
GroupHelper.NormalizeSensorIds(List<SensorData>)
- Signature:
static List<SensorData> NormalizeSensorIds(List<SensorData> sensors)(inferred from usage) - Behavior: Safely handles null input by returning an empty list. Otherwise, normalizes sensor IDs in the list. (Exact normalization logic not visible.)
CalibrationImport.CheckForExcitationCalibration(SensorCalibration, int, ExcitationVoltageOptions.ExcitationVoltageOption, string)
- Signature:
SensorCalibration CheckForExcitationCalibration(SensorCalibration sensorCalibration, int channelIndex, ExcitationVoltageOptions.ExcitationVoltageOption expectedExcitation, string channelName) - Behavior:
- If the excitation voltage of the first calibration record matches
expectedExcitation, returns the originalsensorCalibrationunchanged. - If it does not match, returns a modified
SensorCalibrationwith an additional calibration record (resulting inRecords.Records.Count == 2). (Exact record duplication or cloning logic not visible.)
- If the excitation voltage of the first calibration record matches
CalibrationImport.AddLinearCalRecordIfNeeded(SensorCalibration, bool, bool)
- Signature:
SensorCalibration AddLinearCalRecordIfNeeded(SensorCalibration sensorCalibration, bool forceAdd, bool isZeroMethodRequired)(inferred from usage) - Behavior:
- If
sensorCalibration.Records.Records.Count != 1, returns the original unchanged. - If
Count == 1, returns a modifiedSensorCalibrationwhere:- The existing record’s
Poly.IsValidis set tofalse. - A second calibration record is added (resulting in
Count == 2).
(Exact record creation logic not visible.)
- The existing record’s
- If
CalibrationImport.AddLinearZeroMethodIfNeeded(SensorCalibration, ZeroMethodType, int, int)
- Signature:
SensorCalibration AddLinearZeroMethodIfNeeded(SensorCalibration sensorCalibration, ZeroMethodType zeroMethodType, int channelIndex, int sensorIndex)(inferred from usage) - Behavior:
- If
sensorCalibration.Records.Records.Count != 1, returns the original unchanged. - If
Count == 1, returns a modifiedSensorCalibrationwithZeroMethods.Methods.Count == 2. (Exact zero method addition logic not visible.)
- If
3. Invariants
GroupHelper.CreateEmptyGroup()always produces aGroupwithLastModifiedBy == "---".GroupHelper.ReverseChannelOrder()andGroupHelper.NormalizeSensorIds()must never throw exceptions when passednullforsensorsortestTemplate; they must return empty lists instead.CalibrationImport.CheckForExcitationCalibration():- When the first calibration record’s
Excitationmatches the expected value, the returned object is identical (reference equality not tested, but no modification is performed). - When mismatched, the returned
SensorCalibrationhas exactly two calibration records.
- When the first calibration record’s
CalibrationImport.AddLinearCalRecordIfNeeded():- Only modifies the calibration when there is exactly one record.
- In that case, it invalidates the existing record (
Poly.IsValid == false) and adds a second record.
CalibrationImport.AddLinearZeroMethodIfNeeded():- Only modifies the calibration when there is exactly one record.
- In that case, it ensures
ZeroMethods.Methods.Count == 2.
4. Dependencies
Test Module Dependencies:
DTS.Common.Import.Testsreferences:DTS.Common.Interface.TestSetups.TestSetupsList(forTestTemplate, inferred)DTS.SensorDB(forSensorData)DataPROWin7.DataModel(forGroup, inferred)NUnit.Framework(test framework)NSubstitute(mocking library)DTS.Common.Enums(forExcitationVoltageOptions,ZeroMethodType)DTS.Common.Interface.Sensors(forICalibrationRecords,ICalibrationRecord)Classes.Sensors.LinearizationFormula(fromDTS.SensorDBorDataPROWin7.DataModel, inferred)
Tested Components’ Dependencies (inferred):
GroupHelper,CalibrationImportlikely depend on:DTS.SensorDB(sensor data models)DTS.Common.Interface.Sensors(calibration interfaces)DTS.Common.Enums(enum types)- Possibly
DataPROWin7.DataModel(e.g.,Group,TestTemplate)
Dependents:
- This test module is consumed by the test runner (NUnit) and likely part of a CI pipeline. No runtime dependents are visible.
5. Gotchas
- Typos in test names: Tests use
"ShouldNotThorwException"(missing 'w' in "Throw")—likely a typo in test method names, but does not affect behavior. - Ambiguity in record duplication logic: In
CheckForExcitationCalibration, when excitation mismatches, a second record is added—but it is unclear whether this is a copy of the first record, a new placeholder, or a modified record. The tests only assert count, not content. - Zero method vs. calibration record distinction:
AddLinearZeroMethodIfNeededmodifiesZeroMethods.Methods, whileAddLinearCalRecordIfNeededmodifiesRecords.Records. The interaction between these two mechanisms is not tested—potential for confusion or overlap. - No tests for
AddLinearCalRecordIfNeededwithforceAdd == trueorisZeroMethodRequired == true: Only default (false,false) cases are tested. - No tests for non-null, non-empty inputs in
GroupHelpermethods: All tests forReverseChannelOrderandNormalizeSensorIdsonly verify null-safety; behavior on valid inputs is not specified here.
No other obvious tech debt or quirks identified from source alone.