How to tell Machine.Fake to satisfy a dependency with a given type

752 Views Asked by At

Suppose I have a context that is configured similar to:

Establish context = () =>
    {
        ...

        IFileProcesser processer = new FileProcesser();

        The<IFileProcesser>()
            .WhenToldTo(x => x.Read(Param<Stream>.IsAnything))
            .Return<Stream>(processer.Read);

        ...
    };

Is there a better way to tell Machine.Fakes to not fake IFileProcesser and use the implementation of FileProcesser?

1

There are 1 best solutions below

3
On BEST ANSWER

You can use the Configure method for this.

Establish context = () =>
{
    Configure(x => x.For<IFileProcesser>().Use<FileProcesser>());
};

If something is registered that way (there're several overloads of Use) it has precedence over the auto mocking capabilities.

HTH