| 
       Built-In During Filters  | 
    Top Previous Next | 
| 
 Filtering During Specific Module 
 Restrict fakes to a specific module: 
 TEST(DuringTests, FakeCallsFromSpecifiedDllUsingAModule) { auto a = Isolator(During(A::Module("Test.dll"))); 
 auto fake = a.Fake.Instance<Person>(); 
 // This is restricted to getName called within test.dll a.CallTo(fake->GetName()).WillReturn("John"); 
 auto res = fake->GetName(); ASSERT_TRUE(strcmp(res, "John") == 0); } 
 
 Filtering During Specific Thread 
 Restrict fakes to a single thread: 
 TEST(DuringTests, FilterByThreadIdUsingAThread) { auto a = Isolator(During(A::Thread(GetCurrentThreadId()))); 
 auto fake = a.Fake.Instance<Person>(); 
 // This is restricted to getName called within current thread a.CallTo(fake->GetName()).WillReturn("John"); 
 auto res = fake->GetName(); ASSERT_TRUE(strcmp(res, "John") == 0); } 
 
 Filtering During Specific Function Calls 
 Use A::Call to restrict the fakes to a specific function up the call stack: 
 
 
 TEST(DuringTests, FakeWhenCallsFromGlobalFilterSucceeded) { auto a = Isolator(During(A::Call(CallGetBuildingNumber))); 
 // This is restricted to GetBuildingNumber called within CallGetBuildingNumber a.CallToPrivate(A::Global(GetBuildingNumber)).WillReturn(3); 
 ASSERT_EQ(3, CallGetBuildingNumber()); } 
 
 
 So far we’ve seen restrictions applied at the suite level, let’s look at how to restrict them at other levels. 
 Filtering During Specific Module on the instance 
 Restrict fakes to a specific module on the instance level: 
 TEST_F(ConditionalBehavior, MultipleDuringFiltersUsingAModuleSucceeded) { auto a = Isolator(); 
 auto fake = a.Fake.Instance<Person>(During(A::Module("Test.dll"))); 
 // This is restricted to getName called within test.dll a.CallTo(fake->GetName()).WillReturn("John"); 
 auto res = fake->GetName(); ASSERT_TRUE(strcmp(res, "John") == 0); } 
   Filtering During Specific Module on the call 
 Restrict fakes to a specific module on the call level: 
 TEST_F(ConditionalBehavior, MultipleDuringFiltersUsingAModuleSucceeded) { auto a = Isolator(); auto fake = a.Fake.Instance<Person>(); 
 // This is restricted to getName called within test.dll a.CallTo(fake->GetName()).During(A::Module("Test.dll")).WillReturn("John"); 
 auto res = fake->GetName(); ASSERT_TRUE(strcmp(res, "John") == 0); }  | 
Copyright Typemock Ltd. 2009-2025. All Rights Reserved.