Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / Castle.MonoRail.Framework / Test / ViewEngineManagerStub.cs
blobdb865d4be6f17cc0abbe67ad92f1c45a441d5390
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;
18 using System.Collections.Generic;
19 using System.IO;
20 using Castle.MonoRail.Framework.JSGeneration.Prototype;
21 using JSGeneration;
23 /// <summary>
24 /// Pendent
25 /// </summary>
26 public class ViewEngineManagerStub : IViewEngineManager
28 private readonly List<string> templates = new List<string>();
29 private string templateRendered;
30 private string partialRendered;
31 private string contentWithinLayoutRendered;
33 /// <summary>
34 /// Gets the name of the template rendered by the controller.
35 /// </summary>
36 /// <value>The template rendered.</value>
37 public string TemplateRendered
39 get { return templateRendered; }
42 /// <summary>
43 /// Gets the name of the partial template rendered.
44 /// </summary>
45 /// <value>The partial rendered.</value>
46 public string PartialRendered
48 get { return partialRendered; }
51 /// <summary>
52 /// Gets the static content rendered from the controller.
53 /// </summary>
54 /// <value>The content within layout rendered.</value>
55 public string ContentWithinLayoutRendered
57 get { return contentWithinLayoutRendered; }
60 /// <summary>
61 /// Registers the template.
62 /// </summary>
63 /// <param name="template">The template.</param>
64 public void RegisterTemplate(string template)
66 templates.Add(template);
69 /// <summary>
70 /// Evaluates whether the specified template exists.
71 /// </summary>
72 /// <param name="templateName"></param>
73 /// <returns><c>true</c> if it exists</returns>
74 public bool HasTemplate(string templateName)
76 return templates.Exists(
77 delegate(string item) { return item.Equals(templateName, StringComparison.InvariantCultureIgnoreCase); });
80 /// <summary>
81 /// Processes the view - using the templateName
82 /// to obtain the correct template
83 /// and writes the results to the System.TextWriter.
84 /// <para>
85 /// Please note that no layout is applied
86 /// </para>
87 /// </summary>
88 public void Process(string templateName, TextWriter output, IEngineContext context, IController controller,
89 IControllerContext controllerContext)
91 templateRendered = templateName;
94 /// <summary>
95 /// Processes the view - using the templateName
96 /// to obtain the correct template
97 /// and writes the results to the System.TextWriter.
98 /// </summary>
99 public void Process(string templateName, string layoutName, TextWriter output, IDictionary<string, object> parameters)
101 templateRendered = templateName;
104 /// <summary>
105 /// Processes a partial view using the partialName
106 /// to obtain the correct template and writes the
107 /// results to the System.TextWriter.
108 /// </summary>
109 public void ProcessPartial(string partialName, TextWriter output, IEngineContext context, IController controller,
110 IControllerContext controllerContext)
112 partialRendered = partialName;
115 /// <summary>
116 /// Wraps the specified content in the layout using
117 /// the context to output the result.
118 /// </summary>
119 public void RenderStaticWithinLayout(string contents, IEngineContext context, IController controller,
120 IControllerContext controllerContext)
122 contentWithinLayoutRendered = contents;
125 /// <summary>
126 /// Creates the JS code generator info. Temporarily on IViewEngineManager
127 /// </summary>
128 /// <param name="engineContext">The engine context.</param>
129 /// <param name="controller">The controller.</param>
130 /// <param name="controllerContext">The controller context.</param>
131 /// <returns></returns>
132 public JSCodeGeneratorInfo CreateJSCodeGeneratorInfo(IEngineContext engineContext, IController controller,
133 IControllerContext controllerContext)
135 JSCodeGenerator codeGen = new JSCodeGenerator();
137 return new JSCodeGeneratorInfo(codeGen, new PrototypeGenerator(codeGen), new object[0], new object[0]);