51 lines
3.9 KiB
Markdown
51 lines
3.9 KiB
Markdown
---
|
|
source_files:
|
|
- DataPRO/UnitTest/DTS.Common.DataModel.Tests/GroupShould.cs
|
|
generated_at: "2026-04-16T03:51:03.653495+00:00"
|
|
model: "Qwen/Qwen3-Coder-Next-FP8"
|
|
schema_version: 1
|
|
sha256: "574ef8550b69736d"
|
|
---
|
|
|
|
# DTS.Common.DataModel.Tests
|
|
|
|
## Documentation Page: `GroupShould.cs` Unit Tests
|
|
|
|
### 1. Purpose
|
|
This file contains unit tests for the `Group` class in the `GroupList.Model` namespace, specifically validating the behavior of its `Filter` method and `ConvertToEmbedded` method. The tests ensure that filtering logic correctly handles edge cases (null/empty search terms, missing associated test setups), searches across multiple properties (`DisplayName`, `Description`, `ChannelCount`, `LastModified`), and that `ConvertToEmbedded` behaves idempotently when invoked on an already-embedded group.
|
|
|
|
### 2. Public Interface
|
|
The tests reference the following public members of the `Group` class (defined externally, not in this file):
|
|
|
|
- **`bool Filter(string term)`**
|
|
Performs a case-sensitive substring search across `DisplayName`, `Description`, `ChannelCount` (as string), and `LastModified` (as string, using default `ToString()`). Returns `true` if any field contains the search term (or if `term` is null/empty, or if `AssociatedTestSetups` is null), otherwise `false`.
|
|
|
|
- **`void ConvertToEmbedded(IGroupChannel[] channels)`**
|
|
Converts the `Group` instance to an embedded state. Tests confirm that invoking this method on a group with `Embedded = true` does not cause an exception and leaves `Embedded` as `true`. (Full behavior of this method is not fully specified by the tests.)
|
|
|
|
### 3. Invariants
|
|
- `Filter("")` and `Filter(null)` **must** return `true`.
|
|
- If `AssociatedTestSetups` is `null`, `Filter(term)` **must** return `true` (regardless of `term`).
|
|
- `Filter(term)` returns `true` if `term` is a substring of:
|
|
- `DisplayName`,
|
|
- `Description`,
|
|
- `ChannelCount.ToString()`, or
|
|
- `LastModified.ToString()`
|
|
(using default string conversion and case-sensitive comparison).
|
|
- `Filter(term)` returns `false` only if `term` is non-null/non-empty, `AssociatedTestSetups` is non-null, and `term` is not found in any of the above fields.
|
|
- `ConvertToEmbedded` must be safe to call on an already-embedded group (no exception thrown, `Embedded` remains `true`).
|
|
|
|
### 4. Dependencies
|
|
- **Internal dependencies (inferred from test setup):**
|
|
- `GroupList.Model.Group` — the class under test.
|
|
- `Interface.Groups.GroupList.TestSetupParentHelper` — used to populate `AssociatedTestSetups` (a `List<TestSetupParentHelper>`).
|
|
- `Interface.Channels.IGroupChannel` — used as the parameter type for `ConvertToEmbedded`.
|
|
- **Test framework:** `NUnit` (v3+), via `[TestFixture]` and `[Test]` attributes.
|
|
- **Dependencies on this module:** None explicitly stated in this test file. Tests are internal to the `DTS.Common.DataModel.Tests` namespace.
|
|
|
|
### 5. Gotchas
|
|
- **Case sensitivity:** Tests do not verify case-insensitive matching; `Filter` appears to be case-sensitive (e.g., `"abc"` matches `"defabchy"` but not `"defABChy"` unless explicitly implemented otherwise — not confirmed here).
|
|
- **String conversion of `ChannelCount` and `LastModified`:** Uses default `.ToString()`; behavior may vary with culture settings (e.g., `LastModified.ToString()` may produce `"12/31/2023 10:00:00 AM"` vs `"2023-12-31T10:00:00"` depending on environment).
|
|
- **`AssociatedTestSetups` null vs empty list:** Tests distinguish between `null` (returns `true` for any term) and an empty list (returns `false` if term not found elsewhere).
|
|
- **`ConvertToEmbedded` behavior incomplete:** Tests only verify idempotency for already-embedded groups. No tests confirm behavior for non-embedded groups, side effects (e.g., channel assignment), or exception conditions.
|
|
- **No tests for `Embedded` property mutation:** While `Embedded` is read in tests, no tests assert that `ConvertToEmbedded` sets it to `true` when initially `false`. |