• Home
  • Raw
  • Download

Lines Matching refs:Concrete

352 ## Alternative to Mocking Concrete Classes ##
356 call it `Concrete`), you may be tempted to make the methods of
357 `Concrete` virtual and then mock it.
372 to interfaces": instead of talking to the `Concrete` class, your code
374 interface as an adaptor on top of `Concrete`. In tests, you can easily
385 …* `Concrete`'s API may not fit your problem domain very well, as you may not be the only client it…
386 …* If `Concrete`'s implementation ever has to change, you don't have to rewrite everywhere it is us…
393Concrete` in different ways, so the best interfaces for them will be different. Therefore, each of…
394 … just like they have been sharing `Concrete`. You can check in the interface and the adaptor somew…
568 virtual int Concrete(const char* str) { ... }
575 // Mocking a concrete method. Foo::Concrete() is shadowed.
576 MOCK_METHOD1(Concrete, int(const char* str));
580 Sometimes you may want to call `Foo::Concrete()` instead of
581 `MockFoo::Concrete()`. Perhaps you want to do it as part of a stub
582 action, or perhaps your test doesn't need to mock `Concrete()` at all
594 // Mocking a concrete method. Foo::Concrete() is shadowed.
595 MOCK_METHOD1(Concrete, int(const char* str));
597 // Use this to call Concrete() defined in Foo.
598 int FooConcrete(const char* str) { return Foo::Concrete(str); }
602 Now, you can call `Foo::Concrete()` inside an action by:
608 EXPECT_CALL(foo, Concrete(_))
612 or tell the mock object that you don't want to mock `Concrete()`:
617 ON_CALL(foo, Concrete(_))
621 (Why don't we just write `Invoke(&foo, &Foo::Concrete)`? If you do
622 that, `MockFoo::Concrete()` will be called (and cause an infinite
623 recursion) since `Foo::Concrete()` is virtual. That's just how C++