TEST(ProviderTest, unregister_attributeListener) { MockPublicationManager publicationManager; std::string attributeName("testAttribute"); std::string subscriptionId("test-subscription-id"); Variant attributeValue(Variant::make<int>(42)); // Expect the publicationManager not to be called when the attribute value changes EXPECT_CALL(publicationManager, attributeValueChanged(Eq(subscriptionId),Eq(attributeValue))) .Times(0); DummyProvider provider; // This should not contact the publicationManager provider.onAttributeValueChanged(attributeName, attributeValue); // Do a register then unregister SubscriptionAttributeListener* attributeListener = new SubscriptionAttributeListener(subscriptionId, publicationManager); provider.registerAttributeListener(attributeName, attributeListener); provider.unregisterAttributeListener(attributeName, attributeListener); // This should not contact the publicationManager provider.onAttributeValueChanged(attributeName, attributeValue); }
TEST(ProviderTest, register_attributeListener) { MockPublicationManager publicationManager; std::string attributeName("testAttribute"); QString subscriptionId("test-subscription-id"); QVariant attributeValue(42); // Expect the publicationManager to be called when the attribute value changes EXPECT_CALL(publicationManager, attributeValueChanged(Eq(subscriptionId),Eq(attributeValue))) .Times(1); DummyProvider provider; provider.registerAttributeListener(attributeName, new SubscriptionAttributeListener(subscriptionId, publicationManager)); provider.onAttributeValueChanged(attributeName, attributeValue); }