TutorialsAndTests/Tests/AtlFreeServerTests.cpp
TEST(AtlFreServerTests, RequireThat_Bite_CausesDogToBitePostman)
{
    const auto postman = wrl::Make<IPostmanMock>();
    EXPECT_CALL(*postman.Get(), OnBitten()).WillOnce(Invoke([]()
    {
        return S_OK;
    }));

    ComPtr<IDog> guardDog;
    HR(CoCreateInstance(__uuidof(GuardDog), nullptr, CLSCTX_INPROC_SERVER, __uuidof(IDog), &guardDog));

    HR(guardDog->Bite(postman.Get()));
}
// Test that demonstrates how we can use mocks with COM by creating local instances
Test that demonstrates how we can use mocks with COM by creating local instances
Test that demonstrates how we can use mocks with COM by creating local instances
TEST(AtlFreServerTests, RequireThat_Bite_CausesDogToBitePostman)
{
    const auto postman = wrl::Make<IPostmanMock>();
    EXPECT_CALL(*postman.Get(), OnBitten()).WillOnce(Invoke([]()
    {
        return S_OK;
    }));
    ComPtr<IDog> guardDog;
    HR(CoCreateInstance(__uuidof(GuardDog), nullptr, CLSCTX_INPROC_SERVER, __uuidof(IDog), &guardDog));
    HR(guardDog->Bite(postman.Get()));
}
TEST ( AtlFreServerTests , RequireThat_Bite_CausesDogToBitePostman ) { const auto postman = wrl :: Make < IPostmanMock > ( ) ; EXPECT_CALL ( * postman . Get ( ) , OnBitten ( ) ) . WillOnce ( Invoke ( [ ] ( ) { return S_OK ; } ) ) ; ComPtr < IDog > guardDog ; HR ( CoCreateInstance ( __uuidof ( GuardDog ) , nullptr , CLSCTX_INPROC_SERVER , __uuidof ( IDog ) , & guardDog ) ) ; HR ( guardDog -> Bite ( postman . Get ( ) ) ) ; }
Test that demonstrates how we can use mocks with COM by creating local instances
Test that demonstrates how we can use mocks with COM by creating local instances