Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
UTY-2533: add commands tests for subscription (#1448)
Browse files Browse the repository at this point in the history
This commit adds a couple of tests for the subscription system when sending commands.
  • Loading branch information
BryanJY-Wong authored Aug 11, 2020
1 parent 9ea8fd4 commit fcb1b4b
Showing 1 changed file with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,35 @@ public void SubscriptionSystem_invokes_callback_on_receiving_response()
});
}

[Test]
public void SubscriptionSystem_does_not_invoke_callback_when_gameobject_is_unlinked()
{
World.Step(world =>
{
world.Connection.CreateEntity(EntityId, GetTemplate());
})
.Step(world =>
{
return world.CreateGameObject<CommandStub>(EntityId).Item2;
})
.Step((world, mono) =>
{
mono.Sender.SendTestCommand(GetRequest(), response => throw new AssertionException("Don't call"));
})
.Step((world, mono) =>
{
world.Linker.UnlinkGameObjectFromEntity(new EntityId(EntityId), mono.gameObject);
})
.Step(world =>
{
world.Connection.GenerateResponses<TestCommands.Test.Request, TestCommands.Test.ReceivedResponse>(ResponseGenerator);
})
.Step((world, mono) =>
{
Assert.IsFalse(mono.enabled);
});
}

private static TestCommands.Test.ReceivedResponse ResponseGenerator(CommandRequestId id, TestCommands.Test.Request request)
{
return new TestCommands.Test.ReceivedResponse(
Expand All @@ -57,8 +86,8 @@ private static TestCommands.Test.ReceivedResponse ResponseGenerator(CommandReque
private static EntityTemplate GetTemplate()
{
var template = new EntityTemplate();
template.AddComponent(new Position.Snapshot(), "worker");
template.AddComponent(new TestCommands.Snapshot(), "worker");
template.AddComponent(new Position.Snapshot());
template.AddComponent(new TestCommands.Snapshot());
return template;
}

Expand Down

0 comments on commit fcb1b4b

Please sign in to comment.