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

Commit fcb1b4b

Browse files
authored
UTY-2533: add commands tests for subscription (#1448)
This commit adds a couple of tests for the subscription system when sending commands.
1 parent 9ea8fd4 commit fcb1b4b

File tree

1 file changed

+31
-2
lines changed
  • workers/unity/Assets/Tests/EditmodeTests/Correctness/Subscriptions

1 file changed

+31
-2
lines changed

workers/unity/Assets/Tests/EditmodeTests/Correctness/Subscriptions/CommandTests.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,35 @@ public void SubscriptionSystem_invokes_callback_on_receiving_response()
4040
});
4141
}
4242

43+
[Test]
44+
public void SubscriptionSystem_does_not_invoke_callback_when_gameobject_is_unlinked()
45+
{
46+
World.Step(world =>
47+
{
48+
world.Connection.CreateEntity(EntityId, GetTemplate());
49+
})
50+
.Step(world =>
51+
{
52+
return world.CreateGameObject<CommandStub>(EntityId).Item2;
53+
})
54+
.Step((world, mono) =>
55+
{
56+
mono.Sender.SendTestCommand(GetRequest(), response => throw new AssertionException("Don't call"));
57+
})
58+
.Step((world, mono) =>
59+
{
60+
world.Linker.UnlinkGameObjectFromEntity(new EntityId(EntityId), mono.gameObject);
61+
})
62+
.Step(world =>
63+
{
64+
world.Connection.GenerateResponses<TestCommands.Test.Request, TestCommands.Test.ReceivedResponse>(ResponseGenerator);
65+
})
66+
.Step((world, mono) =>
67+
{
68+
Assert.IsFalse(mono.enabled);
69+
});
70+
}
71+
4372
private static TestCommands.Test.ReceivedResponse ResponseGenerator(CommandRequestId id, TestCommands.Test.Request request)
4473
{
4574
return new TestCommands.Test.ReceivedResponse(
@@ -57,8 +86,8 @@ private static TestCommands.Test.ReceivedResponse ResponseGenerator(CommandReque
5786
private static EntityTemplate GetTemplate()
5887
{
5988
var template = new EntityTemplate();
60-
template.AddComponent(new Position.Snapshot(), "worker");
61-
template.AddComponent(new TestCommands.Snapshot(), "worker");
89+
template.AddComponent(new Position.Snapshot());
90+
template.AddComponent(new TestCommands.Snapshot());
6291
return template;
6392
}
6493

0 commit comments

Comments
 (0)