Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / Castle.MonoRail.Framework / Test / MockEmailTemplateService.cs
blobf32b434afd0a6164864e89c270e56a08c3cfebe4
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.MonoRail.Framework.Test
17 using System.Collections;
18 using Castle.Components.Common.EmailSender;
19 using Core;
21 /// <summary>
22 /// Mocks the <see cref="IEmailTemplateService"/> calling
23 /// <see cref="MockEngineContext.AddMailTemplateRendered"/> to register
24 /// the calls made to these methods
25 /// </summary>
26 public class MockEmailTemplateService : IEmailTemplateService
28 private readonly MockEngineContext context;
30 /// <summary>
31 /// Initializes a new instance of the <see cref="MockEmailTemplateService"/> class.
32 /// </summary>
33 /// <param name="context">The context.</param>
34 public MockEmailTemplateService(MockEngineContext context)
36 this.context = context;
39 /// <summary>
40 /// Creates an instance of <see cref="Message"/>
41 /// using the specified template for the body
42 /// </summary>
43 /// <param name="templateName">Name of the template to load.
44 /// Will look in <c>Views/mail</c> for that template file.</param>
45 /// <param name="layoutName">Name of the layout.</param>
46 /// <param name="parameters">Dictionary with parameters
47 /// that you can use on the email template</param>
48 /// <returns>An instance of <see cref="Message"/></returns>
49 public Message RenderMailMessage(string templateName, string layoutName, IDictionary parameters)
51 context.AddMailTemplateRendered(templateName, parameters);
53 return new Message("from", "to", "subject", "body");
56 /// <summary>
57 /// Creates an instance of <see cref="Message"/>
58 /// using the specified template for the body
59 /// </summary>
60 /// <param name="templateName">Name of the template to load.
61 /// Will look in <c>Views/mail</c> for that template file.</param>
62 /// <param name="layoutName">Name of the layout.</param>
63 /// <param name="parameters">Dictionary with parameters
64 /// that you can use on the email template</param>
65 /// <returns>An instance of <see cref="Message"/></returns>
66 public Message RenderMailMessage(string templateName, string layoutName, object parameters)
68 context.AddMailTemplateRendered(templateName, new ReflectionBasedDictionaryAdapter(parameters));
70 return new Message("from", "to", "subject", "body");
73 /// <summary>
74 /// Renders the mail message.
75 /// </summary>
76 /// <param name="templateName">Name of the template.</param>
77 /// <param name="engineContext">The engine context.</param>
78 /// <param name="controller">The controller.</param>
79 /// <param name="controllerContext">The controller context.</param>
80 /// <param name="doNotApplyLayout">if set to <c>true</c> [do not apply layout].</param>
81 /// <returns></returns>
82 public Message RenderMailMessage(string templateName, IEngineContext engineContext, IController controller,
83 IControllerContext controllerContext, bool doNotApplyLayout)
85 context.AddMailTemplateRendered(templateName, controllerContext.PropertyBag);
87 return new Message("from", "to", "subject", "body");