Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
titleTestExample.cpp
MockContainerServices* mcs = nullptr;

setUp() {
    mcs = new MockContainerServices(cn, nullptr);
    mcs->activateComponent<MaciTestComponentImpl>("TEST_COMP1");
    mcs->activateComponent<MaciTestComponentImpl>("TEST_COMP2");
}

cleanUp() {
    mcs.deactivateComponent->deactivateComponent("TEST_COMP1");
    mcs.deactivateComponent->deactivateComponent("TEST_COMP2");
    delete mcs;
    mcs = nullptr;
}

//The tests should not know anything about the changes we've done, but they rely on this mcs instance just for convenience
test_example() {
    MACI_TEST::MaciTestComponent_var comp = mcs->getComponent<MACI_TEST::MaciTestComponent>("TEST_COMP1");
    comp->some_method(...); //If some_method retrieves a component, it should also work normally, since on creation, we passed an instance of MockContainerServices
}

...