0

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?

Chris Marisic
  • 32,487
  • 24
  • 164
  • 258

1 Answers1

5

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

  • That looks like exactly what i was looking for, thanks for your really fast response! Also great work with Machine.Fakes, my team and I released our first application built over both MSpec & SpecFlow the other week. – Chris Marisic Nov 14 '11 at 18:54
  • As a random thought, Configure() is directly diving into StructureMap isn't it? – Chris Marisic Nov 14 '11 at 19:00
  • Well, thank you! The Configure API only mimics StructureMaps API. It doesn't expose it. We're probably going to replace the StructureMap internals with a simpler container in a future version of Machine.Fakes. – Bjoern Rochel Nov 14 '11 at 19:17