Skip to content

Commit

Permalink
Account for comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacarniato committed Aug 28, 2024
1 parent e8cd80e commit 4ce710c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/MeshKernelNETTest/Api/MeshKernelTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
}
}
}

}

0 comments on commit 4ce710c

Please sign in to comment.