From 4ce710cd167e3f1588bfa646973d9e90e936cc62 Mon Sep 17 00:00:00 2001 From: Luca Carniato Date: Wed, 28 Aug 2024 14:29:05 +0200 Subject: [PATCH] Account for comments --- test/MeshKernelNETTest/Api/MeshKernelTest.cs | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/MeshKernelNETTest/Api/MeshKernelTest.cs b/test/MeshKernelNETTest/Api/MeshKernelTest.cs index 5d7dd0d..afea44d 100644 --- a/test/MeshKernelNETTest/Api/MeshKernelTest.cs +++ b/test/MeshKernelNETTest/Api/MeshKernelTest.cs @@ -3014,12 +3014,14 @@ public void Mesh2dUndoThenRedoTwoDeleteNodesThroughApi() int meshKernelId = -1; Assert.AreEqual(0, api.UndoState(ref undone, ref meshKernelId)); Assert.AreEqual(true, undone); + Assert.AreEqual(0, meshKernelId); Assert.AreEqual(0, api.Mesh2dGetData(id, out mesh2d)); Assert.AreEqual(100.0, mesh2d.NodeX[6]); Assert.AreEqual(numberOfVerticesBefore - 1, mesh2d.NumValidNodes); Assert.AreEqual(0, api.UndoState(ref undone, ref meshKernelId)); Assert.AreEqual(true, undone); + Assert.AreEqual(0, meshKernelId); Assert.AreEqual(0, api.Mesh2dGetData(id, out mesh2d)); Assert.AreEqual(0.0, mesh2d.NodeX[0]); Assert.AreEqual(numberOfVerticesBefore, mesh2d.NumValidNodes); @@ -3029,12 +3031,14 @@ public void Mesh2dUndoThenRedoTwoDeleteNodesThroughApi() Assert.AreEqual(0, api.RedoState(ref redone, ref meshKernelId)); Assert.AreEqual(true, redone); + Assert.AreEqual(0, meshKernelId); Assert.AreEqual(0, api.Mesh2dGetData(id, out mesh2d)); Assert.AreEqual(-999.0, mesh2d.NodeX[0]); Assert.AreEqual(numberOfVerticesBefore - 1, mesh2d.NumValidNodes); Assert.AreEqual(0, api.RedoState(ref redone, ref meshKernelId)); Assert.AreEqual(true, redone); + Assert.AreEqual(0, meshKernelId); Assert.AreEqual(0, api.Mesh2dGetData(id, out mesh2d)); Assert.AreEqual(-999.0, mesh2d.NodeX[6]); Assert.AreEqual(numberOfVerticesBefore - 2, mesh2d.NumValidNodes); @@ -3358,6 +3362,40 @@ public void Mesh2dSnapToLandBoundaryThroughApi() } } } + + + [Test] + public void Mesh2dExpungeStateThroughApi() + { + // Setup + using (DisposableMesh2D mesh = CreateMesh2D(10, 10, 10, 10)) + using (var api = new MeshKernelApi()) + { + var id = 0; + var mesh0 = new DisposableMesh2D(); + var mesh1 = new DisposableMesh2D(); + try + { + // prepare + id = api.AllocateState(0); + Assert.AreEqual(0, api.Mesh2dSet(id, mesh)); + + // execute + Assert.AreEqual(0, api.Mesh2dGetData(id, out mesh0)); + Assert.AreEqual(0, api.ExpungeState(id)); + Assert.AreEqual(1, api.Mesh2dGetData(id, out mesh1)); //Once the id is expunged, no data can be retrieved and the exitcode is 1 + + // assert + Assert.AreEqual(100, mesh0.NumNodes); + Assert.AreEqual(0, mesh1.NumNodes); + } + finally + { + api.ClearState(); + mesh1?.Dispose(); + } + } + } } }