Fix the build.
[castle.git] / MonoRail / Castle.MonoRail.Framework / Test / MockServerUtility.cs
blobf5b4452508425540267a4168a20e2b1c5fdb3dbe
1 // Copyright 2004-2007 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.IO;
20 /// <summary>
21 /// Represents a mock implementation of <see cref="IServerUtility"/> for unit test purposes.
22 /// </summary>
23 public class MockServerUtility : IServerUtility
25 /// <summary>
26 /// Returns the physical path for the
27 /// specified virtual path.
28 /// </summary>
29 /// <param name="virtualPath">The virtual path.</param>
30 /// <returns>The mapped path</returns>
31 public virtual string MapPath(string virtualPath)
33 return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, virtualPath);
36 /// <summary>
37 /// HTML encodes a string and returns the encoded string.
38 /// </summary>
39 /// <param name="content">The text string to HTML encode.</param>
40 /// <returns>The HTML encoded text.</returns>
41 public virtual string HtmlEncode(string content)
43 return content;
46 /// <summary>
47 /// URL encodes a string and returns the encoded string.
48 /// </summary>
49 /// <param name="content">The text to URL encode.</param>
50 /// <returns>The URL encoded text.</returns>
51 public virtual string UrlEncode(string content)
53 return content.Replace("&", "&amp;");
56 /// <summary>
57 /// URL decodes a string and returns the decoded string.
58 /// </summary>
59 /// <param name="content">The text to URL decode.</param>
60 /// <returns>The URL decoded text.</returns>
61 public virtual string UrlDecode(string content)
63 return content.Replace("&amp", "&");
66 /// <summary>
67 /// URL encodes the path portion of a URL string and returns the encoded string.
68 /// </summary>
69 /// <param name="content">The text to URL encode.</param>
70 /// <returns>The URL encoded text.</returns>
71 public virtual string UrlPathEncode(string content)
73 return content;
76 /// <summary>
77 /// Escapes JavaScript with Url encoding and returns the encoded string.
78 /// </summary>
79 /// <param name="content">The text to URL encode and escape JavaScript within.</param>
80 /// <returns>
81 /// The URL encoded and JavaScript escaped text.
82 /// </returns>
83 /// <remarks>
84 /// Converts quotes, single quotes and CR/LFs to their representation as an escape character.
85 /// </remarks>
86 public virtual string JavaScriptEscape(string content)
88 return content;