Files
DP44/enriched-qwen3-coder-next/DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestMetaData.md

97 lines
6.0 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestMetaData/LabratoryDetails.cs
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestMetaData/CustomerDetails.cs
- DataPRO/Modules/DatabaseImporter/DatabaseImport/Classes/TestMetaData/TestEngineerDetails.cs
generated_at: "2026-04-16T04:31:55.181756+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "6aa688c6b66d13f9"
---
# TestMetaData
## Documentation: Test Metadata Wrappers Module
---
### 1. Purpose
This module provides thin managed wrappers around low-level `ISO.*` data entities (`LabratoryDetails`, `CustomerDetails`, `TestEngineerDetails`) to support database import operations within the DataPRO system. It exposes simplified, namespaced access to metadata entities used during test configuration and reporting, including CRUD-like operations (e.g., `DeleteAll`) and instance management (e.g., singleton list for engineers). The module exists to decouple the import pipeline from direct dependencies on the `ISO` layer, enabling testability and future flexibility in metadata handling.
---
### 2. Public Interface
#### `LabratoryDetails`
- **`public string Name { get; set; }`**
Gets or sets the laboratory name by delegating to the underlying `_lab.Name` field.
#### `LabratoryDetailsList`
- **`public static void DeleteAll()`**
Invokes `ISO.LabratoryDetails.DeleteLabratoryDetails()` to remove all laboratory detail records from persistent storage.
#### `CustomerDetails`
- **`public string Name { get; set; }`**
Gets or sets the customer name by delegating to `_customerDetails.Name`.
#### `CustomerDetailsList`
- **`public static void DeleteAll()`**
Invokes `ISO.CustomerDetails.DeleteCustomerDetails()` to delete all customer detail records.
#### `TestEngineerDetails`
- **`public TestEngineerDetails()`**
Default constructor initializes `_testEngineerDetails` to a new `ISO.TestEngineerDetails` instance with `Name` set to `"(none)"`.
- **`public TestEngineerDetails(ISO.TestEngineerDetails testEngineerDetails)`**
Copy constructor: initializes `_testEngineerDetails` by constructing a new `ISO.TestEngineerDetails` from the provided instance.
- **`public string Name { get; set; }`**
Gets or sets the engineers name via `_testEngineerDetails.Name`.
#### `TestEngineerDetailsList`
- **`public static TestEngineerDetailsList TestEngineerList { get; }`**
Static singleton accessor for the single `TestEngineerDetailsList` instance.
- **`public void ReloadAll()`**
Thread-safely repopulates the internal `_testEngineers` dictionary by calling `GetAllTestEngineers()` and caching entries keyed by `Name`.
- **`public static void DeleteAll()`**
Clears the in-memory `_testEngineers` dictionary and invokes `ISO.TestEngineerDetails.DeleteAllTestEngineerDetails()` to purge persisted records.
- **`private TestEngineerDetails[] GetAllTestEngineers()`**
Returns an array of `TestEngineerDetails` objects: first a sentinel `"(none)"` entry (via default constructor), then one entry per record returned by `ISO.TestEngineerDetails.GetAllTestEngineerDetails()`.
> **Note**: `GetAllTestEngineers()` is `private`, but used internally by `ReloadAll()` and implicitly by the `PopulateEngineers()` method.
---
### 3. Invariants
- **`Name` is the only mutable property** exposed via the public interface for all three detail classes (`LabratoryDetails`, `CustomerDetails`, `TestEngineerDetails`).
- **`TestEngineerDetailsList` is a singleton** — only one instance exists (`_testEngineerList`), accessed via `TestEngineerList`.
- **Thread safety for `ReloadAll()`** is enforced via `lock (_testEngineerLock)` around `PopulateEngineers()`.
- **`"(none)"` sentinel entry** is always the first element in the list returned by `GetAllTestEngineers()`.
- **Duplicate names are prevented** in `_testEngineers` dictionary: `PopulateEngineers()` only adds an entry if `!_testEngineers.ContainsKey(t.Name)`.
- **`_testEngineers` is nullified on `DeleteAll()`**, forcing a full reload on next access.
---
### 4. Dependencies
#### Dependencies *of* this module:
- `ISO.LabratoryDetails` (type with static methods `DeleteLabratoryDetails()`)
- `ISO.CustomerDetails` (type with static method `DeleteCustomerDetails()`)
- `ISO.TestEngineerDetails` (type with static methods `GetAllTestEngineerDetails()`, `DeleteAllTestEngineerDetails()`, and constructors)
- `System.Collections.Generic.Dictionary<string, TestEngineerDetails>` (used in `TestEngineerDetailsList`)
#### Dependencies *on* this module:
- Not explicitly stated in source, but given the naming and structure, this module is likely consumed by:
- `DatabaseImport` pipeline components (e.g., importers that populate or validate test metadata).
- UI or service layers that require test metadata (e.g., selecting engineer or lab for a test run).
---
### 5. Gotchas
- **Typo in class names**: All classes use `Labratory` (misspelled) instead of `Laboratory`. This is preserved from the underlying `ISO` layer and must be maintained for compatibility.
- **`TestEngineerDetails` is *not* thread-safe for concurrent mutation** — while `ReloadAll()` is synchronized, direct access to `_testEngineerDetails.Name` (via `Name` property) is not guarded.
- **`_testEngineerDetails` field in `TestEngineerDetails` is *not* `readonly`**, unlike the others — implying potential reassignment (though not observed in current code).
- **`GetAllTestEngineers()` silently ignores duplicate names** — only the first occurrence is retained in `_testEngineers`.
- **No validation on `Name` values** — empty strings or duplicates are allowed at the wrapper level (though duplicates are deduped in `TestEngineerDetailsList`).
- **`CustomerDetailsList` and `LabratoryDetailsList` have no instance members beyond `DeleteAll()`** — they are effectively static namespaces.
- **`TestEngineerDetailsList` caches in-memory state** — changes made directly to `ISO.*` entities outside this module may not be reflected until `ReloadAll()` is called.
None identified beyond those above.