using NUnit.Framework; using CeresSharp; namespace CeresSharp.Test; /// /// Base class for tests with proper cleanup /// public abstract class TestBase { [TearDown] public void TearDown() { // Small delay to ensure native cleanup is complete before next test // This helps prevent crash when running multiple tests // Note: Don't force GC here as it may cause crash in finalizer thread System.Threading.Thread.Sleep(5); } /// /// Helper method to solve a problem with exception handling. /// Returns null if solve fails (expected in some cases). /// protected SolverSummary? TrySolve(Problem problem, SolverOptions options) { try { return problem.Solve(options); } catch (Exceptions.CeresException ex) { // Expected for some problems - just log and return null Console.WriteLine($"Solve failed (expected in some cases): {ex.Message}"); return null; } } }