void VerifyEffectRealizationSources(TestEffect* testEffect) { Fixture f; f.m_deviceContext->DrawImageMethod.AllowAnyCall(); bool setInputCalled = false; bool setInputCountCalled = false; bool setValueCalled = false; f.m_deviceContext->CreateEffectMethod.SetExpectedCalls(1, [&](IID const&, ID2D1Effect** effect) { ComPtr<MockD2DEffect> mockEffect = Make<MockD2DEffect>(); mockEffect.CopyTo(effect); mockEffect->MockSetInput = [&](UINT32, ID2D1Image*) { Assert::IsFalse(setInputCalled); setInputCalled = true; }; mockEffect->MockSetInputCount = [&] { Assert::IsFalse(setInputCountCalled); setInputCountCalled = true; return S_OK; }; mockEffect->MockSetValue = [&](UINT32, D2D1_PROPERTY_TYPE, CONST BYTE*, UINT32) { Assert::IsFalse(setValueCalled); setValueCalled = true; return S_OK; }; return S_OK; }); f.m_drawingSession = nullptr; f.m_drawingSession = CanvasDrawingSession::CreateNew(f.m_deviceContext.Get(), std::make_shared<StubCanvasDrawingSessionAdapter>()); f.m_drawingSession->DrawImageAtOrigin(testEffect); Assert::IsTrue(setInputCalled); Assert::IsTrue(setInputCountCalled); Assert::IsTrue(setValueCalled); // Drawing on a second device context that shares the same device should NOT rerealize the effect. auto deviceContext2 = f.MakeDeviceContext(); deviceContext2->DrawImageMethod.AllowAnyCall(); deviceContext2->CreateEffectMethod.SetExpectedCalls(0); auto drawingSession2 = CanvasDrawingSession::CreateNew(deviceContext2.Get(), std::make_shared<StubCanvasDrawingSessionAdapter>()); drawingSession2->DrawImageAtOrigin(testEffect); }