From 228f7d441fade543b00bb1df8565fe1c5973c560 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 6 Apr 2017 20:12:31 +0200 Subject: [PATCH] Commands: draft further test case to cover handling of duplicates The instance manager opens (creates) a new instance by cloning from the prototype. Unless this instance is dispatched, it does not allow to open a further instance (for the same instanceID). But of course it allows to open a different instance from the same prototype --- .../control/command-instance-manager-test.cpp | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/core/proc/control/command-instance-manager-test.cpp b/tests/core/proc/control/command-instance-manager-test.cpp index 191772590..cf5009317 100644 --- a/tests/core/proc/control/command-instance-manager-test.cpp +++ b/tests/core/proc/control/command-instance-manager-test.cpp @@ -250,11 +250,32 @@ namespace test { } - /** @test */ + /** @test there can be only one active "opened" instance + * The CommandInstanceManager opens (creates) a new instance by cloning from the prototype. + * Unless this instance is dispatched, it does not allow to open a further instance + * (for the same instanceID). But of course it allows to open a different instance from + * the same prototype, but with a different invocationID and hence a different instanceID + */ void verify_duplicates() { - UNIMPLEMENTED ("reject duplicates"); + Fixture fixture; + CommandInstanceManager iManager{fixture}; + Symbol i1 = iManager.newInstance (COMMAND_PROTOTYPE, "i1"); + Symbol i2 = iManager.newInstance (COMMAND_PROTOTYPE, "i2"); + + VERIFY_ERROR (DUPLICATE_COMMAND, iManager.newInstance (COMMAND_PROTOTYPE, "i1")); + VERIFY_ERROR (DUPLICATE_COMMAND, iManager.newInstance (COMMAND_PROTOTYPE, "i2")); + + Command c11 = iManager.getInstance (i1); + c11.bind(-1); + iManager.dispatch (i1); + + iManager.newInstance (COMMAND_PROTOTYPE, "i1"); + VERIFY_ERROR (DUPLICATE_COMMAND, iManager.newInstance (COMMAND_PROTOTYPE, "i2")); + + CHECK (iManager.getInstance (i1)); + CHECK (iManager.getInstance (i2)); }