NINA.Test is the NUnit-based test project for the solution. It exercises code across almost every NINA.* runtime assembly.
Build shape from NINA.Test.csproj:
- Target framework:
net10.0-windows - Test framework: NUnit
- Platform target:
x64 - References the main runtime libraries and the
NINAexecutable project
The folder structure mirrors the production code areas being tested:
AstrometryTest/Autofocus/Converters/Database/Dome/Equipment/FlatDevice/Focuser/Image/MGEN/Planetarium/PlateSolving/Plugin/ProfileTest/Rotator/Sequencer/SerialCommunication/SimpleSequencer/Utility/ViewModel/
The Sequencer/ subtree is especially deep and mirrors the production sequencer areas (Behaviors, Conditions, Container, DragDrop, Logic, SequenceItem, Serialization, Trigger, View).
Usings.cs contains a [SetUpFixture] that preloads native DLLs before test execution:
SOFAlib.dllNOVAS31lib.dll
That bootstrap is necessary because parts of the production astronomy code depend on native libraries being available in the test process.
ImageDataFactoryTestUtility.cs is a representative example of how the project builds production objects for tests:
- creates mocked
IProfileService - creates mocked pluggable behavior selectors for star detection and annotation
- instantiates real
ImageDataFactoryandExposureDataFactory
The general pattern in this project is:
- mock high-level collaborators
- instantiate real production objects when the behavior under test is inside the object itself
NINA.Test.csproj copies sample files into the output directory, including:
- horizon data files under
AstrometryTest/HorizonData Autofocus/TestImage_Jelly.xisf
That makes some tests integration-style rather than purely synthetic.
This project references almost every runtime project:
NINANINA.AstrometryNINA.CoreNINA.CustomControlLibraryNINA.EquipmentNINA.ImageNINA.MGENNINA.PlateSolvingNINA.PluginNINA.ProfileNINA.SequencerNINA.WPF.Base
It is the verification layer, not a reusable library.
- Place new tests under the folder that matches the production area under test; the existing layout makes failures easy to navigate.
- Reuse existing helpers and mocks when possible instead of rebuilding factory/bootstrap code in each fixture.
- For WPF-facing tests that instantiate
System.Windows.Application, depend onApplication.Current.Resources, or construct XAML-backed views, keep the fixture in an STA apartment and generally mark it[NonParallelizable]to avoid multiple-application races during full-suite execution. - If a production change needs native files or sample data at test time, update the project file so the assets are copied into the test output.
- For astronomical or other numerically sensitive changes, prefer assertions based on documented reference values, authoritative sample data, and edge cases rather than only hand-derived spot checks.
AstrometryTest/AstrometryTest.csalready contains that pattern, including cases annotated with SOFA documented values and other cited reference data; extend those fixtures when the production change touches the same calculation families.- Keep tests explicit about integration boundaries; some areas here are pure unit tests, while others intentionally exercise file I/O, serialization, or native-library loading.