Skip to content

Add more interfaces to make FileHelpers mockeable #65

Description

@MarcosMeli

I have little background on working with advance mocking, mostly for mocking IO ops

So we need your help to identify the key points to make FileHelpers main classes mockeable

That addition must avoid breaking changes, in the worst case we can add some overloads but not change the way users work now with the library

Activity

  1. added this to the 4.0 milestone on Jun 29, 2015
  2. changed the title [-]Add more interfaces to make FileHelpers moqueable[/-] [+]Add more interfaces to make FileHelpers mockeable[/+] on Jul 26, 2015
  3. waynebrantley commented on Sep 25, 2015

    @waynebrantley

    If using dependency injection and I want a constructor like this:

    public MyClass( IFileHelperAsyncEngine<SomeClass> fileHelper)

    I would have to register all the classes that could be used for the generic argument. However, if we had a IFileHelperClass marker interface that was put on every class that was intended for that use, I could generically register all the dependencies dynamically. Might it be nice to have the interface in the library and then some example automatic registration and use for users?

    The problem with the above, is the IFileHelperAsyncEngine generic argument would contain ''where T : IFileHelperClass

    If you put that constraint on the interface, that means we have the same constraint on the implementation, and that means every user would be required to mark the class with IFileHelperClass interface. This would of course be a 'breaking change' and users would have to add the (empty) interface to every filehelpers definition (not painful, but breaking)

    The above applies to non-async too of course, but other than that I think the interfaces do what I need for DI.

  4. lilasquared commented on Jan 22, 2018

    @lilasquared

    @MarcosMeli I know this is a pretty old thread - has there been any progress on this? Particularly I am interested in mocking out the file system itself so that I can write unit tests that use the engine or other classes. I am currently using System.IO.Abstractions. Is there any way to mock where FileHelpers pulls the files from? Thanks!

    Edit: To be more clear I know I can pull from a stream I was more wondering if there is a way to mock the underlying file system as a whole.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions