89 lines
5.5 KiB
Markdown
89 lines
5.5 KiB
Markdown
---
|
|
source_files:
|
|
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestSummaryList/Model/TestSummaryModel.cs
|
|
generated_at: "2026-04-16T11:17:27.563683+00:00"
|
|
model: "zai-org/GLM-5-FP8"
|
|
schema_version: 1
|
|
sha256: "eacbbab8741bd493"
|
|
---
|
|
|
|
# Documentation: TestSummaryModel.cs
|
|
|
|
## 1. Purpose
|
|
|
|
`TestSummaryModel` is a model class within the `DTS.Viewer.TestSummaryList` module that orchestrates loading and merging test summary data from `.dts` files. It implements `IBaseModel` and serves as the data acquisition layer for the test summary list view, handling asynchronous file system operations, event publication for UI state management (busy indicators, app status), and intelligent merging of newly loaded tests with existing collections while preserving user selection state.
|
|
|
|
---
|
|
|
|
## 2. Public Interface
|
|
|
|
### Properties
|
|
|
|
| Signature | Description |
|
|
|-----------|-------------|
|
|
| `ITestSummaryListViewModel Parent { get; set; }` | Reference to the parent view model. Must be set before calling `GetTestSummary`. Used to access and modify `TestSummaryList`, `SelectedTestSummaryList`, and `IsBusy` state. |
|
|
| `IEventAggregator _eventAggregator { get; set; }` | Prism event aggregator for publishing events. Despite the underscore prefix (typically indicating private), this is a public property. Must be set before calling `GetTestSummary`. |
|
|
| `bool IsSaved { get; }` | Read-only property. Appears to be an unimplemented auto-property (always returns default `false`). |
|
|
|
|
### Methods
|
|
|
|
| Signature | Description |
|
|
|-----------|-------------|
|
|
| `void GetTestSummary(string path, string file, bool Include = false, bool selectAll = false)` | Loads test definitions from the specified path/file. Creates the directory if it doesn't exist. Merges results into `Parent.TestSummaryList`, replacing duplicates (matched by `Id`, `SetupName`, and `DataType`) while preserving selection state. Publishes `BusyIndicatorChangeNotification`, `AppStatusExEvent`, and `TestLoadedCountNotification` events. Executes work asynchronously via `Dispatcher.CurrentDispatcher.InvokeAsync` with `DispatcherPriority.Background`. |
|
|
| `void OnPropertyChanged(string propertyName)` | Raises the `PropertyChanged` event for the specified property name. |
|
|
|
|
### Events
|
|
|
|
| Event | Description |
|
|
|-------|-------------|
|
|
| `event PropertyChangedEventHandler PropertyChanged` | Standard `INotifyPropertyChanged` implementation. |
|
|
|
|
---
|
|
|
|
## 3. Invariants
|
|
|
|
- **Parent must be assigned** before calling `GetTestSummary`. The method accesses `Parent.IsBusy`, `Parent.TestSummaryList`, and `Parent.SelectedTestSummaryList` without null checks.
|
|
- **_eventAggregator must be assigned** before calling `GetTestSummary`. Events are published without null checks.
|
|
- **Duplicate detection key**: Tests are considered duplicates if they match on all three properties: `Id`, `SetupName`, and `DataType`.
|
|
- **Selection preservation**: When replacing a duplicate test, the `IsSelected` state is preserved from the replaced test.
|
|
- **Collection event handling**: When `Parent.TestSummaryList` is empty, the new list is assigned directly and `CollectionChanged` is wired to `Parent.TestSummaryList_CollectionChanged`. When non-empty, items are added/inserted individually.
|
|
- **Async execution**: `GetTestSummary` returns immediately; actual work is dispatched asynchronously. Callers cannot await completion.
|
|
|
|
---
|
|
|
|
## 4. Dependencies
|
|
|
|
### This module depends on:
|
|
- `DTS.Common.Base` — `IBaseModel` interface
|
|
- `DTS.Common.Classes.Viewer.TestMetadata` — `TestMetadataList` class
|
|
- `DTS.Common.Events` — `BusyIndicatorChangeNotification`, `AppStatusExEvent`, `AppStatusExArg`, `AppStatusArg`, `TestLoadedCountNotification`, `TestLoadedCountNotificationArg`
|
|
- `DTS.Common.Interface` — (specific interfaces unclear from source)
|
|
- `DTS.Viewer.TestSummaryList.ViewModel` — `ITestSummaryListViewModel`, `TestSummaryViewListModel`
|
|
- `Prism.Events` — `IEventAggregator`
|
|
- `System.Windows.Threading` — `Dispatcher`, `DispatcherPriority`
|
|
- `System.Windows` — `MessageBox`
|
|
- `System.IO` — `Directory`
|
|
- `System.Linq` — LINQ extension methods
|
|
|
|
### What depends on this module:
|
|
- Cannot be determined from this source file alone. The `Parent` property suggests consumption by `ITestSummaryListViewModel` implementations.
|
|
|
|
---
|
|
|
|
## 5. Gotchas
|
|
|
|
1. **Misleading XML documentation**: The `<summary>` for `GetTestSummary` states "Returns list of Test Definition" but the method returns `void`.
|
|
|
|
2. **Naming convention violation**: `_eventAggregator` uses an underscore prefix (conventionally indicating private fields) but is a public property.
|
|
|
|
3. **Fire-and-forget async pattern**: `GetTestSummary` dispatches work via `InvokeAsync` with no mechanism for callers to know when loading completes. The `IsBusy` flag and event publications are the only completion signals.
|
|
|
|
4. **Silent exception swallowing**: Lines 99-108 contain a try/catch with an empty catch block (`catch (Exception) { }`). The comment indicates this was added for a regression build to prevent crashes from a new feature (case 16158).
|
|
|
|
5. **Unimplemented property**: `IsSaved` is a get-only auto-property with no backing field assignment, meaning it always returns `false`.
|
|
|
|
6. **Hardcoded string literal**: The string `"ALL"` is used for `DataType` comparison in `DetermineTestsSelected` without a constant or enum.
|
|
|
|
7. **UI coupling in model**: The model directly shows a `MessageBox` on errors (line 113), violating separation of concerns.
|
|
|
|
8. **Case reference comments**: Multiple comments reference an internal manuscript system (e.g., `http://manuscript.dts.local/f/cases/28164/`) which are inaccessible outside the organization. |