Skip to content

Commit

Permalink
Tests: Cover ComponentCommands<>
Browse files Browse the repository at this point in the history
  • Loading branch information
friflo committed Dec 2, 2024
1 parent 8e1005a commit afe8b82
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/Tests/ECS/CommandBuffer/Test_CommandBuffer_Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public static void Test_CommandBuffer_Events_Components()
break;
case 1:
Mem.IsTrue(ComponentChangedAction.Update == changed.Action);
var old = changed.OldComponent<Position>();
Mem.AreEqual(new Position(1,1,1), old);
Mem.AreEqual(new Position(1,1,1), changed.OldComponent<Position>());
#pragma warning disable CS0618 // Type or member is obsolete
Mem.AreEqual(new Position(1,1,1), (Position)changed.DebugOldComponent);
#pragma warning restore CS0618 // Type or member is obsolete
break;
}
};
Expand Down Expand Up @@ -56,6 +58,22 @@ public static void Test_CommandBuffer_Events_Components()
AreEqual(1, removeCount);
}

/// Cover changed Action == null at <see cref="Friflo.Engine.ECS.ComponentCommands{T}.SendCommandEvents"/>
[Test]
public static void Test_CommandBuffer_Events_cover_change_null()
{
var store = new EntityStore();
store.OnComponentAdded += changed => { };

var entity = store.CreateEntity();
entity.AddComponent(new Position());
var ecb = store.GetCommandBuffer();
ecb.ReuseBuffer = true;

ecb.RemoveComponent<Position>(entity.Id);
ecb.Playback();
}

[Test]
public static void Test_CommandBuffer_Events_Tags()
{
Expand Down

0 comments on commit afe8b82

Please sign in to comment.