Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol Composition Mock #379

Closed
SeamusY opened this issue Feb 1, 2021 · 4 comments
Closed

Protocol Composition Mock #379

SeamusY opened this issue Feb 1, 2021 · 4 comments

Comments

@SeamusY
Copy link

SeamusY commented Feb 1, 2021

I was writing a piece of code that requires a "Protocol Composition"
InteractionServiceHandler & NavigationContentCaller

But it seems that the Cuckoo only support single Protocol, is the feature supported for the composition ?

Information provide from:
https://docs.swift.org/swift-book/LanguageGuide/Protocols.html#//apple_ref/doc/uid/TP40014097-CH25-ID282

@MatyasKriz
Copy link
Collaborator

Hey, it's possible that this case has been overlooked, can you work around it using generics?

Using your protocols, declaring <T: InteractionServiceHandler & NavigationContentCaller> to see if that works and if not, using the where clause, so func gg<T>() where T: InteractionServiceHandler, T: NavigationContentCaller.

@SeamusY
Copy link
Author

SeamusY commented Feb 3, 2021

I just ended up building a class inheriting the two types
class Mocker: InteractionServiceHandler, NavigationContentCaller which doesn't use Cuckoo in my test case.

Ideally we should support composition.

@MatyasKriz
Copy link
Collaborator

We should add support for this. Not very common but definitely a good thing to have.

@MatyasKriz
Copy link
Collaborator

Fixed in 2.0.3. Thanks for the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants