From aba27835e033fc26e3a8b8dfc2607a9adc864edc Mon Sep 17 00:00:00 2001 From: BeanCheeseBurrito Date: Fri, 15 Nov 2024 01:36:40 -0800 Subject: [PATCH] Port C++ modified tag pair tests --- src/Flecs.NET.Tests/Cpp/DocTests.cs | 2 +- src/Flecs.NET.Tests/Cpp/PairTests.cs | 53 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/Flecs.NET.Tests/Cpp/DocTests.cs b/src/Flecs.NET.Tests/Cpp/DocTests.cs index 1c2041f4..dada2c32 100644 --- a/src/Flecs.NET.Tests/Cpp/DocTests.cs +++ b/src/Flecs.NET.Tests/Cpp/DocTests.cs @@ -73,7 +73,7 @@ private void SetUuid() Assert.True(e.Has(Ecs.Doc.Uuid)); - Assert.Equal(e.DocUuid(), "81f50b40-09ff-4ce0-a388-4a52a14052c7"); + Assert.Equal("81f50b40-09ff-4ce0-a388-4a52a14052c7", e.DocUuid()); } [Fact] diff --git a/src/Flecs.NET.Tests/Cpp/PairTests.cs b/src/Flecs.NET.Tests/Cpp/PairTests.cs index 46e2b6e0..aa723a18 100644 --- a/src/Flecs.NET.Tests/Cpp/PairTests.cs +++ b/src/Flecs.NET.Tests/Cpp/PairTests.cs @@ -1114,4 +1114,57 @@ private void SymmetricWithChildOf() Assert.True(bob.Has(alice)); } + + [Fact] + private void ModifiedTagSecond() + { + using World world = World.Create(); + + int count = 0; + world.Observer() + .TermAt(0).Second() + .Event(Ecs.OnSet) + .Each((ref Position p) => + { + Assert.Equal(10, p.X); + Assert.Equal(20, p.Y); + count++; + }); + + Entity e = world.Entity(); + + ref Position p = ref e.EnsureFirst(); + p.X = 10; + p.Y = 20; + e.Modified(); + + Assert.Equal(1, count); + } + + [Fact] + private void ModifiedTagFirst() + { + using World world = World.Create(); + + int count = 0; + world.Observer() + .With() + .Event(Ecs.OnSet) + .Each((Iter it, int row) => + { + ref Position p = ref it.FieldAt(0, row); + Assert.Equal(10, p.X); + Assert.Equal(20, p.Y); + count++; + }); + + Entity e = world.Entity(); + + ref Position p = ref e.EnsureSecond(); + p.X = 10; + p.Y = 20; + e.Modified(); + + Assert.Equal(1, count); + } }