Monorail services

by benl

The monorail pipeline is modeled around a key set of services. This allows a certain amount of flexibility when acquiring resources or using dependent services such as email sending, scaffolding support, controller factories and the like.

Upon initialization of the monorail framework these services are defaulted to monorail provided implementations based on the existence (or non-existence) of service configuration in your web.config file.

This is particularly handy for mocking out infrastructure during automated acceptance testing. Emailing is a good example of when you might want to do such a thing. To provide a mock service for email sending you simply add the following into your web.config:

        type="Castle.Components.Common.EmailSender.Mock.MockEmailSender, Castle.Components.Common.EmailSender" />

You could of course provide your own mock implementations if necessary.

To provide dynamic mocking for unit testing you should mock out the RailsEngineContext and return an IEmailSender implementation (or dynamic mock) by setting up an expected return on the IRailsEngineContext.GetService call: