Skip to content

Commit

Permalink
Test_StructuralChangeException: add assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
friflo committed Feb 13, 2025
1 parent 1e6163d commit d24d0c5
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/Tests/ECS/Arch/Test_StructuralChangeException.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Friflo.Engine.ECS;
using Friflo.Engine.ECS.Serialize;
using NUnit.Framework;


Expand All @@ -17,11 +18,11 @@ public static void Test_StructuralChangeException_Entities()
store.CreateEntity(new MyComponent1(), new MyComponent2(), new MyComponent3(), new MyComponent4(), new MyComponent4());
foreach (var entity in store.Entities)
{
TestExceptions(entity);
TestExceptions(store, entity);
}
}

private static void TestExceptions(Entity entity)
private static void TestExceptions(EntityStore store, Entity entity)
{
Assert.Throws<StructuralChangeException>(() => {
entity.AddTag<TestTag>();
Expand All @@ -36,6 +37,28 @@ private static void TestExceptions(Entity entity)
entity.RemoveComponent<Position>();
});

var buffer = store.GetCommandBuffer();
Assert.Throws<StructuralChangeException>(() => {
buffer.Playback();
});

var entityBatch = new EntityBatch();
Assert.Throws<StructuralChangeException>(() => {
entityBatch.ApplyTo(entity);
});

TestMultiAddRemoveExceptions(entity);

var converter = EntityConverter.Default;
var dataEntity = new DataEntity { pid = 1 };
Assert.Throws<StructuralChangeException>(() => {
converter.DataEntityToEntity(dataEntity, store, out _);
});
}


private static void TestMultiAddRemoveExceptions(Entity entity)
{
// --- add multiple components
Assert.Throws<StructuralChangeException>(() => {
entity.Add(new Position());
Expand Down

0 comments on commit d24d0c5

Please sign in to comment.