From 4d67b4ddf7a120993a341ee59c057f7bad561304 Mon Sep 17 00:00:00 2001 From: Evan Hemsley Date: Tue, 17 Mar 2020 16:04:27 -0700 Subject: [PATCH] add test for singular ReadMessageWithEntity --- test/EngineTest.cs | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/test/EngineTest.cs b/test/EngineTest.cs index b415eb8..29da00c 100644 --- a/test/EngineTest.cs +++ b/test/EngineTest.cs @@ -497,6 +497,58 @@ namespace Tests entityMessageResults.Should().BeEmpty(); } + [Sends(typeof(EntityMessage), typeof(MockMessage))] + class EntityMessageSingularEmitterEngine : Engine + { + private Entity _entity; + + public EntityMessageSingularEmitterEngine(Entity entity) + { + _entity = entity; + } + + public override void Update(double dt) + { + SendMessage(new EntityMessage(_entity, 2)); + SendMessage(new MockMessage()); + } + } + + static EntityMessage entityMessageResult; + + [Receives(typeof(EntityMessage))] + class SingularMessageWithEntityEngine : Engine + { + private Entity _entity; + + public SingularMessageWithEntityEngine(Entity entity) + { + _entity = entity; + } + + public override void Update(double dt) + { + entityMessageResult = ReadMessageWithEntity(_entity); + } + } + + [Test] + public void MessageWithEntity() + { + var worldBuilder = new WorldBuilder(); + + var entity = worldBuilder.CreateEntity(); + + worldBuilder.AddEngine(new EntityMessageSingularEmitterEngine(entity)); + worldBuilder.AddEngine(new SingularMessageWithEntityEngine(entity)); + + var world = worldBuilder.Build(); + + world.Update(0.01); + + entityMessageResult.Should().Be(new EntityMessage(entity, 2)); + } + class SomeComponentTestEngine : Engine { public override void Update(double dt)