GlassHopper.Test
Directories
- TestFiles
The directory serves as a test suite for the "GlassHopper.Test project, containing a collection of Grasshopper definition files used for parametric modeling within Rhino 3D. These `.ghx` components, including `Loads`, `MaterialsToCombinations`, and various templates, represent distinct visual programming scripts that define structural logic and standards. The files are organized in a dedicated `TestFiles` subdirectory, indicating they function as specific input data or configuration examples for validating the application's solver and material combination features.
- bin
The `GlassHopper.Test/bin/Debug/ is a standard build output directory for the GlassHopper.Test project, indicating it contains compiled artifacts generated during a debug configuration. This folder typically holds executable files, libraries, and dependencies necessary to run unit tests or integration tests locally. Files within this directory are directly related as they represent the immediate result of compiling the source code in the parent solution structure.
- obj
The `GlassHopper.Test/obj/Debug/` directory serves as the build output folder for a .NET project, storing intermediate files generated during the compilation and package resolution process. Its main components include several NuGet-related configuration files, such assests like `project.assets.json`, which locks package versions, and MSBuild property and target files (`*.props`, `*.targets`) that define build settings. Additionally, it contains dependency specification and cache files that help MSBuild efficiently resolve and restore external library dependencies without redundant network requests. These files collectively ensure that the test project builds correctly by managing its specific package history and build metadata.
Files
- CultureSetter.cs
`CultureSetter.cs` is a utility class within the `GlassHopper.Test` namespace designed to manage thread-specific culture settings for testing purposes. It ensures consistent localization behavior by allowing developers to explicitly define the current and UI cultures for the executing thread. The class features a constructor that automatically initializes the culture to "en-GB" upon instantiation, providing a predictable default state. Key methods include `SetCultureToEn()`, which hardcodes the British English culture, and `SetCulture(string)`, which dynamically updates both `CurrentCulture` and `CurrentUICulture` based on a provided culture string argument. This approach isolates cultural dependencies, preventing locale-related inconsistencies in automated tests or specific execution contexts.
- GlassHopper.Test.csproj
This is an XML-based Microsoft .NET project file (`.csproj`) used by the MSBuild build system to define compilation settings, dependencies, and targets for a C# or VB.NET application. The UTF-8 BOM (`ef bb bf`) followed by the opening `<Project Sdk="Microsoft.Net` tag confirms it is a modern .NET SDK-style project configuration file. It serves as the primary manifest for building the `GlassHopper.Test` unit test project.
- GrasshopperFixture.cs
`GrasshopperFixture.cs` is a test utility class designed to manage and initialize the Grasshopper scripting environment within Rhino for automated testing. It implements the `IDisposable` pattern to ensure proper cleanup of resources, including closing documents and suppressing finalization when disposed. The class lazily initializes key components like the `GH_RhinoScriptInterface`, `GH_DocumentIO`, and the active `GH_Document` via dedicated properties and helper methods. Its primary function is loading `.gh definition files by clearing existing Grasshopper documents from the server, enabling headless execution, and managing document lifecycle states such as enabling and adding documents to the instance server. This setup allows tests to interact with Grasshopper definitions programmatically without requiring a visible UI.
- GrasshopperTestBase.cs
This file defines `GrasshopperTestBase`, an abstract base class for unit testing Grasshopper definitions within the Rhino/Grasshopper environment. It extends a `GrasshopperFixture` to load and manage `.gh` files, providing a structured foundation for automated validation of parametric models. The core functionality consists of helper methods that query the document’s component graph by name, nickname, or GUID to locate specific nodes. It also includes robust utilities for extracting output values from input and output parameters, handling Grasshopper's volatile data structures, such as retrieving single or multiple values (doubles, bools, strings, objects) from component outputs while managing type casting and branch traversal. These helpers simplify assertions in test cases by abstracting away the complexity of accessing `IGH_Param` data and `GH_ObjectWrapper` types. Ultimately, this class serves as a reusable toolkit to streamline the verification of logic and geometry outputs in Grasshopper-based software tests.
- RhinoCoreFixture.cs
This file defines an xUnit test fixture and collection to manage the lifecycle of the Rhino 3D modeling engine within automated tests. The `RhinoCoreFixture` class initializes the `RhinoInside.Resolver` in its static constructor, ensuring Rhino DLLs are loaded correctly before any other components access them. It exposes the core Rhino instance via a property and implements `IDisposable` to cleanly shut down the singleton when the test suite completes. The associated `RhinoCollection` class groups tests into a non-parallelized collection ensures that this setup and teardown logic runs exactly once for the entire test run, preventing race conditions or multiple initializations. This approach allows multiple test classes to safely share a single, persistent Rhino context without parallel execution conflicts.
- RhinoCoreSingleton.cs
This file defines a thread-safe singleton class, `RhinoCoreSingleton`, designed for headless testing within the `GlassHopper.Test` namespace. It initializes an in-process Rhino engine and creates a headless document, ensuring the main plugin library (`GlassHopper.gha`) is loaded correctly during construction. Key components include lazy initialization via `Lazy<T>`, UI-thread-safe document creation using `InvokeOnUiThread`, and unit system configuration to millimeters. The class implements `IDisposable` to properly cleans up the Rhino core instance when disposed. This setup allows automated tests to interact with Rhino’s geometry and document APIs without requiring a graphical user interface.
- TemplateTest.cs
This file is a C# unit test class named `TemplateTest` that validates Grasshopper template files within the GlassHopper application. It utilizes the xUnit framework to execute two specific tests (`TestTemplate1` and `TestTemplate2`) against `.ghx` files located in a designated test directory. The core logic, encapsulated in the `TestTemplate` method, orchestrates an automated workflow by authenticating with the Maffeis domain, triggering glass analysis and PDF report generation components, and waiting for server responses. It then verifies that these processes complete successfully via HTTP status checks. Finally, it inspects internal "TestAssert" components within the Grasshopper definition to ensure all expected data validations pass without errors.
- TestAnalysis.cs
This file is a C# unit test suite for the "GlassHopper" Grasshopper plugin, specifically targeting glass analysis and reporting functionalities. It inherits from `GrasshopperTestBase` to interact with a Rhino/Grasshopper document and utilizes xUnit fixtures to manage test state and authentication. The code validates three main areas: verifying default `AnalysisOptions` configuration, executing a full structural analysis to check displacement and stress results against expected numerical tolerances, and generating a PDF report generation workflow. Key components tested include the Glass Analysis component (V2) for computational results and the Glass Report component for outputting documentation files.
- TestCombinations.cs
This file is a C# unit test suite for the "GlassHopper" application, specifically validating logic related to load combinations in structural engineering simulations. It inherits from `GrasshopperTestBase` to interact with Rhino/Grasshopper components, using fixtures to manage test state and document contexts. The tests verify that specific Grasshopper components correctly parse, calculate, and manipulate `GlassCombination` objects, including their coefficients, usage types, and interlayer shear module overrides. Key methods cover loading, copying, and clipboard operations like copy/paste functionality via manual thread manipulation to handle Single-Threaded Apartment (STA) requirements. Assertions ensure precise numerical accuracy for wind, snow, and self-weight loads across various combination scenarios.
- TestLoads.cs
This file is a unit test suite for the "GlassHopper" Grasshopper plugin, specifically validating structural load calculation components. It inherits from `GrasshopperTestBase` and uses xUnit attributes to define tests that interact with a pre-loaded `.ghx` file containing various load definition nodes. The key components tested include gravity, barrier, snow, wind, concentrated, and climate-related loads (altitude, temperature, pressure, and wind loads, as well reference temperatures. Each test method configures specific input parameters like magnitude, duration, and geometric properties, then verifies that the output load objects contain the correctly calculated values within a defined error margin. This ensures the underlying engineering logic for converting user inputs into standardized finite element analysis loads functions accurately.
- TestMaterials.cs
This file contains unit tests for validating material component definitions within the Grasshopper-based "GlassHopper" framework. It inherits from a base test class and utilizes xUnit attributes to execute specific verification scenarios for different material types, including ASTM and EN16612 glass standards, air, interlayers, and catalog entries. The key components include a shared `MaterialsFixture initializes by loading a pre-configured Grasshopper document to retrieve component outputs and assert their physical properties against expected values. Each test method targets a specific material component GUID, extracts its output data, and verifies attributes such as density, elastic modulus, and thermal expansion. This ensures that the material logic correctly implements engineering specifications defined in various international standards.
- TestMesh.cs
This file is a C# unit test suite for the "GlassHopper" Grasshopper plugin, specifically targeting mesh-related components. It utilizes xUnit testing frameworks to validate the functionality of three distinct algorithms: Mesh Sampling, Mesh Subdivide, and QuadMesh Rhino. Each test method initializes a Grasshopper document fixture, authenticates with an external domain, and verifies that specific output values (such as vertex counts or numerical results) match expected assertions. The tests rely on a shared `MeshFixture` to load a predefined Grasshopper definition file, ensuring consistent test environments across all cases.
- TestRestraints.cs
This file is a C# unit test suite for the "GlassHopper" Grasshopper plugin, specifically verifying the functionality of structural restraint components. It inherits from `GrasshopperTestBase` and uses xUnit to validate that edge restraints are correctly generated and positioned within a Rhino/Grasshopper document. The tests execute by retrieving specific component outputs and assert precise numerical checks on coordinate systems (origin and vectors) and degrees of freedom for individual restraints against expected values with a defined error tolerance. Key components include the `RestraintsFixture` for setup and two primary test methods: `TestEdgeRestraint` and `TestEdgeRestraintByType`, which verify different restraint generation logic.
- TestResults.cs
This file is a C# unit test suite for the "GlassHopper" Grasshopper plugin, specifically verifying structural analysis result components. It inherits from `GrasshopperTestBase` and uses xUnit attributes to define four distinct tests: `TestMeshColorMap`, `TestMeshDisplacement`, `TestResultExtractor`, and `TestResultCheckExtractor`. Each test initializes a predefined `.ghx` definition file (`WholeSolver.ghx` as its fixture. The tests programmatically trigger a glass analysis simulation and validate that output meshes, displacements, and stresses match expected numerical values within specified tolerances. Key components include assertions on vertex/face counts, displacement metrics, stress ratios (Wr), and position data to ensure computational accuracy.
- TestSaveOptions.cs
This file is a C# unit test suite for the "Save Options" functionality within the GlassHopper Grasshopper plugin. It inherits from `GrasshopperTestBase` to interact with Rhino/Grasshopper environments and uses xUnit attributes like `[Fact]` to define individual test cases. The tests verify core features such as retrieving glass job references, organization folder handling, and authentication to the Maffeis domain integration by executing specific components like `GlassJobComponent` and `OrganizationFoldersComponent`. Each test ensures that outputs are correctly populated and validated against expected values after running solutions. A key setup requirement involves a pre-existing directory structure (`Glasshopper.Test`) with subfolders to ensure test reliability. Overall, it serves as an integration test layer for validating data flow and API interactions in the plugin.
- TestStandars.cs
This file contains unit tests for a Grasshopper plugin named "GlassHopper," specifically targeting structural standard components. It inherits from `GrasshopperTestBase` and uses xUnit to validate the behavior of specific Rhino/Grasshopper components, such as ASTM 1300 and EN 16612 standards. The `StandardsFixture` initializes a test data via a shared `.ghx` file. Key methods include `TestStandardASTM1300`, which verifies default output values, and `TestStandardEN16612`, which checks custom input parameters like gamma factors and consequence classes. The tests assert that component outputs match expected model instances, ensuring correctness in engineering calculations.
- TestStartUp.cs
This file contains unit tests for the "GlassHopper" Grasshopper plugin, specifically verifying authentication and units functionality. It inherits from `GrasshopperTestBase` and uses xUnit fixtures to load a test definition file (`WholeSolver.ghx`). The `TestAuth` method checks successful authentication by triggering an auth component to ensure users can log in via the MAFFEIS provider, while `TestLogout` verifies session termination by temporarily backing up and restoring local credential data. Additionally, `TestUnits` validates that the system correctly switches between Metric and Imperial unit settings. These tests rely on helper methods like `BackupAuthData` and `CopyFolder` to manage file system state during execution.
- TestStratigraphy.cs
This file is a C# unit test suite for the "Stratigraphy" components within the GlassHopper Grasshopper plugin. It validates the correct parsing and output of glass layer properties, including monolithic glass, interlayers, and air chambers, by loading a specific `.ghx` test file. The tests verify both logical composition and geometric mesh generation from the `StratigraphyFixture`. Key components tested include the Layer component, Stratigraphy component, and specialized code and mesh generators. Each test asserts specific attributes like material names, thicknesses, and counts of layers to ensure data integrity.
- WholeSolveConcentrated.cs
This file defines a unit test class for validating a Grasshopper definition named "SolverConcentrated.ghx" within the GlassHopper testing framework. It inherits from `GrasshopperTestBase` to manage the Grasshopper document and utilizes xUnit attributes like `[Fact]` and `IClassFixture` for test execution. The core functionality involves instantiating a specific Rhino collection context. The primary test method, `TestSolver`, programmatically locates components by name, specifically targeting "Glass Analysis" and "Standard EN16612." It then sets an input parameter (`ɣMv`) on the standard component to verify correct solver behavior. This structure ensures automated regression testing for concentrated glass analysis workflows.
- xunit.runner.json
This file is an **xunit.runner.json** configuration file used to configure the behavior of the xUnit.net test runner. It explicitly disables parallel execution for both assemblies and test collections, ensuring tests run sequentially. The `appDomain` setting is set to "denied," which prevents the use of separate application domains for test isolation, likely to simplify debugging or avoid compatibility issues with certain frameworks. This configuration prioritizes stability and ease of troubleshooting over performance.