add test for singular ReadMessageWithEntity

pull/2/head
Evan Hemsley 2020-03-17 16:04:27 -07:00
parent 511a05f18e
commit 4d67b4ddf7
1 changed files with 52 additions and 0 deletions

View File

@ -497,6 +497,58 @@ namespace Tests
entityMessageResults.Should().BeEmpty(); 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<EntityMessage>(_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 class SomeComponentTestEngine : Engine
{ {
public override void Update(double dt) public override void Update(double dt)