FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ASP.NET-MVC-JavaScript-Routing/Test/RouteReaderTests.cs at master · WestDiscGolf/ASP.NET-MVC-JavaScript-Routing · GitHub
WestDiscGolf
/
ASP.NET-MVC-JavaScript-Routing
Public
Notifications
You must be signed in to change notification settings
Fork
5
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ASP.NET-MVC-JavaScript-Routing
/
Test
/
RouteReaderTests.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
110 lines (92 loc) · 3.9 KB
Breadcrumbs
ASP.NET-MVC-JavaScript-Routing
/
Test
/
RouteReaderTests.cs
Copy path
File metadata and controls
110 lines (92 loc) · 3.9 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Linq
;
using
System
.
Web
.
Routing
;
using
JsRouting
.
Core
;
using
Xunit
;
namespace
Test
{
public
class
RouteReaderTests
{
[
Fact
]
public
void
Ctr_ThrowsException_GivenNullSources
(
)
{
Assert
.
Throws
<
ArgumentNullException
>
(
(
)
=>
new
RouteReader
(
null
,
Enumerable
.
Empty
<
IRouteInterceptor
>
(
)
)
)
;
}
[
Fact
]
public
void
Ctr_ThrowsException_GivenNullInterceptors
(
)
{
Assert
.
Throws
<
ArgumentNullException
>
(
(
)
=>
new
RouteReader
(
Enumerable
.
Empty
<
IRouteSource
>
(
)
,
null
)
)
;
}
[
Fact
]
public
void
Ctr_AddsRoute_WhenInterceptorReturnsTrue
(
)
{
const
string
pattern
=
"{controller}/{action}"
;
var
source
=
new
RouteSource
(
)
;
source
.
Routes
.
Add
(
Tuple
.
Create
(
"foo"
,
new
Route
(
pattern
,
new
BlankRouteHandler
(
)
)
)
)
;
var
reader
=
new
RouteReader
(
new
[
]
{
source
}
,
new
[
]
{
new
BlankInterceptor
{
ReturnValue
=
true
}
}
)
;
Assert
.
Equal
(
pattern
,
reader
.
Definitions
.
First
(
)
.
UrlPattern
)
;
}
[
Fact
]
public
void
Ctr_DoesNotAddRoute_WhenInterceptorReturnsFalse
(
)
{
var
source
=
new
RouteSource
(
)
;
source
.
Routes
.
Add
(
Tuple
.
Create
(
"foo"
,
new
Route
(
""
,
new
BlankRouteHandler
(
)
)
)
)
;
var
reader
=
new
RouteReader
(
new
[
]
{
source
}
,
new
[
]
{
new
BlankInterceptor
{
ReturnValue
=
false
}
}
)
;
Assert
.
Empty
(
reader
.
Definitions
)
;
}
[
Fact
]
public
void
Ctr_CallsAllInterceptorsToDetermineAcceptance
(
)
{
var
source
=
new
RouteSource
(
)
;
source
.
Routes
.
Add
(
Tuple
.
Create
(
"foo"
,
new
Route
(
""
,
new
BlankRouteHandler
(
)
)
)
)
;
var
reader
=
new
RouteReader
(
new
[
]
{
source
}
,
new
[
]
{
new
BlankInterceptor
{
ReturnValue
=
true
}
,
new
BlankInterceptor
{
ReturnValue
=
false
}
,
new
BlankInterceptor
{
ReturnValue
=
true
}
}
)
;
Assert
.
Empty
(
reader
.
Definitions
)
;
}
[
Fact
]
public
void
Ctr_AddsRouteNameToRoute
(
)
{
const
string
name
=
"name"
;
var
source
=
new
RouteSource
(
)
;
source
.
Routes
.
Add
(
Tuple
.
Create
(
name
,
new
Route
(
""
,
new
BlankRouteHandler
(
)
)
)
)
;
var
reader
=
new
RouteReader
(
new
[
]
{
source
}
,
new
IRouteInterceptor
[
0
]
)
;
Assert
.
Same
(
name
,
reader
.
Definitions
.
First
(
)
.
Name
)
;
}
[
Fact
]
public
void
Ctr_AddsRoutes_FromAllSources
(
)
{
var
source1
=
new
RouteSource
(
)
;
source1
.
Routes
.
Add
(
Tuple
.
Create
(
"foo"
,
new
Route
(
""
,
new
BlankRouteHandler
(
)
)
)
)
;
var
source2
=
new
RouteSource
(
)
;
source1
.
Routes
.
Add
(
Tuple
.
Create
(
"bar"
,
new
Route
(
"{controller}"
,
new
BlankRouteHandler
(
)
)
)
)
;
var
source3
=
new
RouteSource
(
)
;
source1
.
Routes
.
Add
(
Tuple
.
Create
(
"baz"
,
new
Route
(
"url"
,
new
BlankRouteHandler
(
)
)
)
)
;
source1
.
Routes
.
Add
(
Tuple
.
Create
(
"baz2"
,
new
Route
(
"url2"
,
new
BlankRouteHandler
(
)
)
)
)
;
var
reader
=
new
RouteReader
(
new
[
]
{
source1
,
source2
,
source3
}
,
new
IRouteInterceptor
[
0
]
)
;
Assert
.
Equal
(
4
,
reader
.
Definitions
.
Count
(
)
)
;
}
public
class
RouteSource
:
IRouteSource
{
private
IList
<
Tuple
<
string
,
Route
>
>
routes
=
new
List
<
Tuple
<
string
,
Route
>
>
(
)
;
public
IList
<
Tuple
<
string
,
Route
>
>
Routes
{
get
{
return
routes
;
}
}
}
private
class
BlankInterceptor
:
IRouteInterceptor
{
public
bool
ReturnValue
{
get
;
set
;
}
public
bool
Intercept
(
RouteDefinition
definition
)
{
return
ReturnValue
;
}
}
private
class
BlankRouteHandler
:
IRouteHandler
{
public
System
.
Web
.
IHttpHandler
GetHttpHandler
(
RequestContext
requestContext
)
{
throw
new
NotImplementedException
(
)
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL