aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Setup
diff options
context:
space:
mode:
authorlbsa712009-05-14 08:21:14 +0000
committerlbsa712009-05-14 08:21:14 +0000
commit95d87244b0c52bc0755af936809945f30a7d78ff (patch)
treef546c09e39bcf3db53bae1035e466adbd3e1629b /OpenSim/Tests/Common/Setup
parent* Ignored some gens (diff)
downloadopensim-SC_OLD-95d87244b0c52bc0755af936809945f30a7d78ff.zip
opensim-SC_OLD-95d87244b0c52bc0755af936809945f30a7d78ff.tar.gz
opensim-SC_OLD-95d87244b0c52bc0755af936809945f30a7d78ff.tar.bz2
opensim-SC_OLD-95d87244b0c52bc0755af936809945f30a7d78ff.tar.xz
* Moved BaseRequestHandlerTestHelper to OpenSim.Tests.Common.Setup for great justice.
Diffstat (limited to 'OpenSim/Tests/Common/Setup')
-rw-r--r--OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs59
1 files changed, 59 insertions, 0 deletions
diff --git a/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs b/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs
new file mode 100644
index 0000000..65c66b0
--- /dev/null
+++ b/OpenSim/Tests/Common/Setup/BaseRequestHandlerTestHelper.cs
@@ -0,0 +1,59 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using NUnit.Framework;
5using OpenSim.Framework;
6using OpenSim.Framework.Servers;
7using OpenSim.Framework.Servers.HttpServer;
8using OpenSim.Tests.Common.Mock;
9
10namespace OpenSim.Tests.Common.Setup
11{
12 public class BaseRequestHandlerTestHelper
13 {
14 private static string[] m_emptyStringArray = new string[] { };
15
16 public static void BaseTestGetParams(BaseRequestHandler handler, string assetsPath)
17 {
18 Assert.AreEqual(String.Empty, handler.GetParam(null), "Failed on null path.");
19 Assert.AreEqual(String.Empty, handler.GetParam(""), "Failed on empty path.");
20 Assert.AreEqual(String.Empty, handler.GetParam("s"), "Failed on short url.");
21 Assert.AreEqual(String.Empty, handler.GetParam("corruptUrl"), "Failed on corruptUrl.");
22
23 Assert.AreEqual(String.Empty, handler.GetParam(assetsPath));
24 Assert.AreEqual("/", handler.GetParam(assetsPath + "/"));
25 Assert.AreEqual("/a", handler.GetParam(assetsPath + "/a"));
26 Assert.AreEqual("/b/", handler.GetParam(assetsPath + "/b/"));
27 Assert.AreEqual("/c/d", handler.GetParam(assetsPath + "/c/d"));
28 Assert.AreEqual("/e/f/", handler.GetParam(assetsPath + "/e/f/"));
29 }
30
31 public static void BaseTestSplitParams(BaseRequestHandler handler, string assetsPath)
32 {
33 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(null), "Failed on null.");
34 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(""), "Failed on empty path.");
35 Assert.AreEqual(m_emptyStringArray, handler.SplitParams("corruptUrl"), "Failed on corrupt url.");
36
37 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath), "Failed on empty params.");
38 Assert.AreEqual(m_emptyStringArray, handler.SplitParams(assetsPath + "/"), "Failed on single slash.");
39
40 Assert.AreEqual(new string[] { "a" }, handler.SplitParams(assetsPath + "/a"), "Failed on first segment.");
41 Assert.AreEqual(new string[] { "b" }, handler.SplitParams(assetsPath + "/b/"), "Failed on second slash.");
42 Assert.AreEqual(new string[] { "c", "d" }, handler.SplitParams(assetsPath + "/c/d"), "Failed on second segment.");
43 Assert.AreEqual(new string[] { "e", "f" }, handler.SplitParams(assetsPath + "/e/f/"), "Failed on trailing slash.");
44 }
45
46 public static byte[] EmptyByteArray = new byte[] {};
47
48 public static void BaseTestHandleNoParams(BaseGetAssetStreamHandler handler, string assetsPath)
49 {
50 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath, null, null, null), "Failed on empty params.");
51 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath + "/", null, null, null), "Failed on single slash.");
52 }
53
54 public static void BaseTestHandleMalformedGuid(BaseGetAssetStreamHandler handler, string assetsPath)
55 {
56 Assert.AreEqual(EmptyByteArray, handler.Handle(assetsPath + "/badGuid", null, null, null), "Failed on bad guid.");
57 }
58 }
59} \ No newline at end of file