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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top