Skip to content

Fakes for Application.FileDialog? #6230

Answered by retailcoder
owfischer asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the feedback!

The Rubberduck COM API Fakes module hooks into the VBA7 library and essentially hijacks certain specific internal function calls, like rtcMsgBox and many others.

Application.FileDialog lives in the Excel COM library, which Rubberduck is agnostic to, so a different strategy is needed. With mocking you'd write test code that sets up a type that gets materialized at run-time and implements the exact same interface, but then you'd still need a way to provide the mocked dependency to your function under test - and that's where dependency injection comes into play.

But Excel.Application is a rather large interface to depend on, which makes it impractical for mocking. So…

Replies: 7 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by retailcoder
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@SmileyFtW
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@owfischer
Comment options

@pflugs30
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants