1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using OpenSim.Data;
using OpenSim.Tests.Common;
namespace OpenSim.Framework.Servers.Tests
{
[TestFixture]
public class GetAssetStreamHandlerTests
{
[Test]
public void TestConstructor()
{
TestHelper.InMethod();
GetAssetStreamHandler handler = new GetAssetStreamHandler( null );
}
[Test]
public void TestGetParams()
{
TestHelper.InMethod();
GetAssetStreamHandler handler = new GetAssetStreamHandler(null);
Assert.AreEqual("", handler.GetParam(null), "Failed on null path.");
Assert.AreEqual("", handler.GetParam(""), "Failed on empty path.");
Assert.AreEqual("", handler.GetParam("s"), "Failed on short url.");
Assert.AreEqual("", handler.GetParam("corruptUrl"), "Failed on corruptUrl.");
Assert.AreEqual("", handler.GetParam("/assets"));
Assert.AreEqual("/", handler.GetParam("/assets/"));
Assert.AreEqual("/a", handler.GetParam("/assets/a"));
Assert.AreEqual("/b/", handler.GetParam("/assets/b/"));
Assert.AreEqual("/c/d", handler.GetParam("/assets/c/d"));
Assert.AreEqual("/e/f/", handler.GetParam("/assets/e/f/"));
}
[Test]
public void TestSplitParams()
{
TestHelper.InMethod();
GetAssetStreamHandler handler = new GetAssetStreamHandler(null);
Assert.AreEqual(new string[] { }, handler.SplitParams(null), "Failed on null.");
Assert.AreEqual(new string[] { }, handler.SplitParams(""), "Failed on empty path.");
Assert.AreEqual(new string[] { }, handler.SplitParams("corruptUrl"), "Failed on corrupt url.");
Assert.AreEqual(new string[] { }, handler.SplitParams("/assets"), "Failed on empty params.");
Assert.AreEqual(new string[] { }, handler.SplitParams("/assets/"), "Failed on single slash.");
Assert.AreEqual(new string[] { "a" }, handler.SplitParams("/assets/a"), "Failed on first segment.");
Assert.AreEqual(new string[] { "b" }, handler.SplitParams("/assets/b/"), "Failed on second slash.");
Assert.AreEqual(new string[] { "c", "d" }, handler.SplitParams("/assets/c/d"), "Failed on second segment.");
Assert.AreEqual(new string[] { "e", "f" }, handler.SplitParams("/assets/e/f/"), "Failed on trailing slash.");
}
[Test]
public void TestHandleNoParams()
{
TestHelper.InMethod();
byte[] emptyResult = new byte[] {};
GetAssetStreamHandler handler = new GetAssetStreamHandler(null);
Assert.AreEqual(new string[] { }, handler.Handle("/assets", null, null, null), "Failed on empty params.");
Assert.AreEqual(new string[] { }, handler.Handle("/assets/", null, null, null ), "Failed on single slash.");
}
[Test]
public void TestHandleMalformedGuid()
{
TestHelper.InMethod();
byte[] emptyResult = new byte[] {};
GetAssetStreamHandler handler = new GetAssetStreamHandler(null);
Assert.AreEqual(new string[] {}, handler.Handle("/assets/badGuid", null, null, null), "Failed on bad guid.");
}
//[Test]
//public void TestHandleFetchMissingAsset()
//{
// byte[] emptyResult = new byte[] { };
// GetAssetStreamHandler handler = new GetAssetStreamHandler(null);
// Assert.AreEqual(new string[] { }, handler.Handle("/assets/badGuid", null, null, null), "Failed on bad guid.");
//}
}
}
|