diff --git a/src/Tests/ECS/Base/Test_ComponentSchema.cs b/src/Tests/ECS/Base/Test_ComponentSchema.cs index 7db0cd15..8c5e6e48 100644 --- a/src/Tests/ECS/Base/Test_ComponentSchema.cs +++ b/src/Tests/ECS/Base/Test_ComponentSchema.cs @@ -48,12 +48,12 @@ public static void Test_ComponentTypes() var components = schema.Components; var scripts = schema.Scripts; - AreEqual("components: 68 scripts: 10 entity tags: 16", schema.ToString()); - AreEqual(69, components.Length); + AreEqual("components: 69 scripts: 10 entity tags: 16", schema.ToString()); + AreEqual(70, components.Length); AreEqual(11, scripts.Length); - AreEqual(74, schema.SchemaTypeByKey.Count); - AreEqual(68, schema.ComponentTypeByType.Count); + AreEqual(75, schema.SchemaTypeByKey.Count); + AreEqual(69, schema.ComponentTypeByType.Count); AreEqual(10, schema.ScriptTypeByType.Count); IsNull(components[0]); diff --git a/src/Tests/ECS/Relations/Components.cs b/src/Tests/ECS/Relations/Components.cs index 3f088c51..fba2e729 100644 --- a/src/Tests/ECS/Relations/Components.cs +++ b/src/Tests/ECS/Relations/Components.cs @@ -46,4 +46,15 @@ internal struct InventoryItem : IRelation public override string ToString() => type.ToString(); } +/// Check generic relation +[GenericInstanceType("relation-string", typeof(string))] +internal struct GenericRelation : IRelation +{ + public int key; + public T value; + public int GetRelationKey() => key; + + public override string ToString() => key.ToString(); +} + } \ No newline at end of file diff --git a/src/Tests/ECS/Relations/Test_Relations.cs b/src/Tests/ECS/Relations/Test_Relations.cs index 147c6c70..ee0d904c 100644 --- a/src/Tests/ECS/Relations/Test_Relations.cs +++ b/src/Tests/ECS/Relations/Test_Relations.cs @@ -347,6 +347,17 @@ public static void Test_Relations_null_relation_key() IsNull (entity.GetRelation(null).value); } + /// Cover generic case at + [Test] + public static void Test_Relations_generic_relation() + { + var store = new EntityStore(); + var entity = store.CreateEntity(); + entity.AddRelation(new GenericRelation { key = 42, value = "test" }); + AreEqual("{ 42 }", entity.GetRelations>().Debug()); + AreEqual("test", entity.GetRelation, int>(42).value); + } + /* COMP_TAG obsolete: Relations do not implement IComponent anymore. So HasComponent(), GetComponent() and AddComponent() will result in a compiler error