test/ObserverTest.cpp
/**
 * Adding multiple observers should notify each one during a notification.
 */
Adding multiple observers should notify each one during a notification.
Adding multiple observers should notify each one during a notification .
TEST(ObserverTest, addObserverMultiple)
{
    auto observable = make_shared<Observable<TestObserver>>();
    auto obs1 = make_shared<MockObserver>();
    auto obs2 = make_shared<MockObserver>();
    observable->addObserver(obs1);
    observable->addObserver(obs2);
    observable->notify([=](TestObserver& o) { o.onChange(); });
    EXPECT_TRUE(VALIDATE(*obs1, onChange).called());
    EXPECT_TRUE(VALIDATE(*obs2, onChange).called());
}
TEST ( ObserverTest , addObserverMultiple ) { auto observable = make_shared < Observable < TestObserver > > ( ) ; auto obs1 = make_shared < MockObserver > ( ) ; auto obs2 = make_shared < MockObserver > ( ) ; observable -> addObserver ( obs1 ) ; observable -> addObserver ( obs2 ) ; observable -> notify ( [ = ] ( TestObserver & o ) { o . onChange ( ) ; } ) ; EXPECT_TRUE ( VALIDATE ( * obs1 , onChange ) . called ( ) ) ; EXPECT_TRUE ( VALIDATE ( * obs2 , onChange ) . called ( ) ) ; }
Adding multiple observers should notify each one during a notification.
Adding multiple observers should notify each one during a notification .
//add the observers to this object. //notify the observers. //the observers should have been notified.