26 lines
1.8 KiB
Markdown
26 lines
1.8 KiB
Markdown
---
|
|
source_files:
|
|
- DataPRO/StateMachine.Tests/StatesShould.cs
|
|
generated_at: "2026-04-17T16:14:08.282619+00:00"
|
|
model: "zai-org/GLM-5-FP8"
|
|
schema_version: 1
|
|
sha256: "f3b6a750e8952451"
|
|
---
|
|
|
|
# StateMachine.Tests
|
|
|
|
### Purpose
|
|
This module contains unit tests for a singleton `States` factory class within the `DTS.DASLib.Service.StateMachine` namespace. It verifies that the `States` singleton is correctly initialized, that it maps `State` enum values to the correct `IDASState` instances, and that the `IDASFactory` dependency is properly propagated to all state instances.
|
|
|
|
### Public Interface
|
|
* **`StatesShould` (TestFixture)**
|
|
* `void Instance_ShouldNotBeNull()`: Verifies that the `States.Instance` singleton property returns a non-null reference.
|
|
* `void Instance_ShouldBeSame()`: Verifies that `States.Instance` returns the same reference on subsequent calls (Singleton pattern guarantee).
|
|
* `void States_ShouldReturnCorrectInstanceOfState()`: Verifies that specific properties on the `States` instance (e.g., `Arm`, `Arming`, `Configure`) return objects with the corresponding `State` enum value.
|
|
* `void GetIDASState_ReturnAllKnownStates()`: Iterates through all defined values of the `State` enum and verifies that `States.Instance.GetIDASState(State)` returns an object with a matching `State` property.
|
|
* `void GetIDASState_ShouldThrowException_WithUndefinedState()`: Verifies that calling `GetIDASState` with an invalid enum value (cast from integer `45`) throws an `InvalidOperationException` with the message "Undefined State".
|
|
* `void SetDASFactory_ShouldSetToAnInstanceOfDASFactory()`: Verifies that `States.SetDASFactory(IDASFactory)` correctly injects the factory into all state instances retrieved via `GetIDASState`.
|
|
|
|
### Invariants
|
|
* **Singleton Pattern:** `States.Instance` must always return the same object reference.
|
|
* |