forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceStackHttpHandlerFactoryTests.cs
More file actions
79 lines (68 loc) · 2.66 KB
/
ServiceStackHttpHandlerFactoryTests.cs
File metadata and controls
79 lines (68 loc) · 2.66 KB
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
using System;
using System.Collections.Generic;
using NUnit.Framework;
using ServiceStack.Host.Handlers;
using ServiceStack.Metadata;
using ServiceStack.Testing;
using ServiceStack.Text;
namespace ServiceStack.WebHost.Endpoints.Tests
{
[TestFixture]
public class ServiceStackHttpHandlerFactoryTests
{
ServiceStackHost appHost;
[TestFixtureSetUp]
public void TestFixtureSetUp()
{
appHost = new BasicAppHost(GetType().Assembly).Init();
HostContext.CatchAllHandlers.Add(new PredefinedRoutesFeature().ProcessRequest);
HostContext.CatchAllHandlers.Add(new MetadataFeature().ProcessRequest);
}
[TestFixtureTearDown]
public void TestFixtureTearDown()
{
appHost.Dispose();
}
readonly Dictionary<string, Type> pathInfoMap = new Dictionary<string, Type>
{
{"Metadata", typeof(IndexMetadataHandler)},
{"Soap11", typeof(Soap11MessageReplyHttpHandler)},
{"Soap12", typeof(Soap12MessageReplyHttpHandler)},
{"Json/Reply", typeof(JsonReplyHandler)},
{"Json/OneWay", typeof(JsonOneWayHandler)},
{"Json/Metadata", typeof(JsonMetadataHandler)},
{"Xml/Reply", typeof(XmlReplyHandler)},
{"Xml/OneWay", typeof(XmlOneWayHandler)},
{"Xml/Metadata", typeof(XmlMetadataHandler)},
{"Jsv/Reply", typeof(JsvReplyHandler)},
{"Jsv/OneWay", typeof(JsvOneWayHandler)},
{"Jsv/Metadata", typeof(JsvMetadataHandler)},
{"Soap11/Wsdl", typeof(Soap11WsdlMetadataHandler)},
{"Soap11/Metadata", typeof(Soap11MetadataHandler)},
{"Soap12/Wsdl", typeof(Soap12WsdlMetadataHandler)},
{"Soap12/Metadata", typeof(Soap12MetadataHandler)},
};
[Test]
public void Resolves_the_right_handler_for_expexted_paths()
{
foreach (var item in pathInfoMap)
{
var expectedType = item.Value;
var handler = HttpHandlerFactory.GetHandlerForPathInfo(null, item.Key, null, null);
Assert.That(handler.GetType(), Is.EqualTo(expectedType));
}
}
[Test]
public void Resolves_the_right_handler_for_case_insensitive_expexted_paths()
{
foreach (var item in pathInfoMap)
{
var expectedType = item.Value;
var lowerPathInfo = item.Key.ToLower();
lowerPathInfo.Print();
var handler = HttpHandlerFactory.GetHandlerForPathInfo(null, lowerPathInfo, null, null);
Assert.That(handler.GetType(), Is.EqualTo(expectedType));
}
}
}
}