Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / Castle.MonoRail.Framework / Test / ViewEngineStub.cs
blob291a3e3b551fe42fefe82a2a08f5c00d23c23da6
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.Generic;
18 using System.IO;
19 using Castle.MonoRail.Framework.JSGeneration.Prototype;
21 /// <summary>
22 /// Pendent
23 /// </summary>
24 public class ViewEngineStub : ViewEngineBase
26 private string viewFileExtension;
27 private bool supportsJSGeneration;
28 private string jsGeneratorFileExtension;
29 private readonly List<string> jsTemplateRendered = new List<string>();
30 private readonly List<string> templateRendered = new List<string>();
31 private readonly List<string> partialRendered = new List<string>();
33 /// <summary>
34 /// Initializes a new instance of the <see cref="ViewEngineStub"/> class.
35 /// </summary>
36 /// <param name="viewFileExtension">The view file extension.</param>
37 /// <param name="supportsJSGeneration">if set to <c>true</c> [supports JS generation].</param>
38 /// <param name="jsGeneratorFileExtension">The js generator file extension.</param>
39 public ViewEngineStub(string viewFileExtension, string jsGeneratorFileExtension, bool supportsJSGeneration)
41 this.viewFileExtension = viewFileExtension;
42 this.supportsJSGeneration = supportsJSGeneration;
43 this.jsGeneratorFileExtension = jsGeneratorFileExtension;
46 /// <summary>
47 /// Initializes a new instance of the <see cref="ViewEngineStub"/> class.
48 /// </summary>
49 public ViewEngineStub() : this(".mm", ".jsm", true)
53 /// <summary>
54 /// Gets a list of partial templates that were "rendered" since the stub was created.
55 /// </summary>
56 /// <value>The partial rendered.</value>
57 public List<string> PartialRendered
59 get { return partialRendered; }
62 /// <summary>
63 /// Gets a list of templates that were "rendered" since the stub was created.
64 /// </summary>
65 /// <value>The template rendered.</value>
66 public List<string> TemplateRendered
68 get { return templateRendered; }
71 /// <summary>
72 /// Gets a list of js templates that were "rendered" since the stub was created.
73 /// </summary>
74 /// <value>The js template rendered.</value>
75 public List<string> JsTemplateRendered
77 get { return jsTemplateRendered; }
80 /// <summary>
81 /// Gets the view file extension.
82 /// </summary>
83 /// <value>The view file extension.</value>
84 public override string ViewFileExtension
86 get { return viewFileExtension; }
89 /// <summary>
90 /// Gets a value indicating whether the view engine
91 /// support the generation of JS.
92 /// </summary>
93 /// <value>
94 /// <c>true</c> if JS generation is supported; otherwise, <c>false</c>.
95 /// </value>
96 public override bool SupportsJSGeneration
98 get { return supportsJSGeneration; }
101 /// <summary>
102 /// Gets the JS generator file extension.
103 /// </summary>
104 /// <value>The JS generator file extension.</value>
105 public override string JSGeneratorFileExtension
107 get { return jsGeneratorFileExtension; }
110 /// <summary>
111 /// Returns a prototype generator.
112 /// </summary>
113 /// <param name="generatorInfo"></param>
114 /// <param name="context"></param>
115 /// <param name="controller"></param>
116 /// <param name="controllerContext"></param>
117 /// <returns></returns>
118 public override object CreateJSGenerator(JSCodeGeneratorInfo generatorInfo, IEngineContext context,
119 IController controller, IControllerContext controllerContext)
121 return new PrototypeGenerator(generatorInfo.CodeGenerator);
124 /// <summary>
125 /// Records on <see cref="JsTemplateRendered"/> the js template
126 /// specified.
127 /// </summary>
128 /// <param name="templateName">Name of the template.</param>
129 /// <param name="output">The output.</param>
130 /// <param name="generatorInfo">The generator info.</param>
131 /// <param name="context">The request context.</param>
132 /// <param name="controller">The controller.</param>
133 /// <param name="controllerContext">The controller context.</param>
134 public override void GenerateJS(string templateName, TextWriter output, JSCodeGeneratorInfo generatorInfo,
135 IEngineContext context, IController controller, IControllerContext controllerContext)
137 jsTemplateRendered.Add(templateName);
140 /// <summary>
141 /// Records on <see cref="TemplateRendered"/> the template
142 /// specified.
143 /// </summary>
144 /// <param name="templateName"></param>
145 /// <param name="output"></param>
146 /// <param name="context"></param>
147 /// <param name="controller"></param>
148 /// <param name="controllerContext"></param>
149 public override void Process(string templateName, TextWriter output, IEngineContext context, IController controller,
150 IControllerContext controllerContext)
152 templateRendered.Add(templateName);
155 /// <summary>
156 /// Records on <see cref="TemplateRendered"/> the template
157 /// specified.
158 /// </summary>
159 /// <param name="templateName"></param>
160 /// <param name="layoutName"></param>
161 /// <param name="output"></param>
162 /// <param name="parameters"></param>
163 public override void Process(string templateName, string layoutName, TextWriter output,
164 IDictionary<string, object> parameters)
166 templateRendered.Add(templateName);
169 /// <summary>
170 /// Records on <see cref="PartialRendered"/> the partial template
171 /// specified.
172 /// </summary>
173 /// <param name="partialName">The partial name.</param>
174 /// <param name="output">The output.</param>
175 /// <param name="context">The request context.</param>
176 /// <param name="controller">The controller.</param>
177 /// <param name="controllerContext">The controller context.</param>
178 public override void ProcessPartial(string partialName, TextWriter output, IEngineContext context,
179 IController controller, IControllerContext controllerContext)
181 partialRendered.Add(partialName);
184 /// <summary>
185 /// Records on <see cref="PartialRendered"/> the partial template
186 /// specified.
187 /// </summary>
188 /// <param name="contents"></param>
189 /// <param name="context"></param>
190 /// <param name="controller"></param>
191 /// <param name="controllerContext"></param>
192 public override void RenderStaticWithinLayout(string contents, IEngineContext context, IController controller,
193 IControllerContext controllerContext)
195 partialRendered.Add(contents);