forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptionCatchBlocksTests.cs
More file actions
124 lines (101 loc) · 3.89 KB
/
Copy pathExceptionCatchBlocksTests.cs
File metadata and controls
124 lines (101 loc) · 3.89 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.TestCommon;
namespace System.Web.Http.ExceptionHandling
{
public class ExceptionCatchBlocksTests
{
[Fact]
public void HttpBatchHandler_IsSpecifiedValue()
{
// Act
ExceptionContextCatchBlock catchBlock = ExceptionCatchBlocks.HttpBatchHandler;
// Assert
ExceptionContextCatchBlock expected =
new ExceptionContextCatchBlock("HttpBatchHandler", isTopLevel: false, callsHandler: true);
AssertEqual(expected, catchBlock);
}
[Fact]
public void HttpBatchHandler_IsSameInstance()
{
// Arrange
ExceptionContextCatchBlock first = ExceptionCatchBlocks.HttpBatchHandler;
// Act
ExceptionContextCatchBlock second = ExceptionCatchBlocks.HttpBatchHandler;
// Assert
Assert.Same(first, second);
}
[Fact]
public void HttpControllerDispatcher_IsSpecifiedValue()
{
// Act
ExceptionContextCatchBlock catchBlock = ExceptionCatchBlocks.HttpControllerDispatcher;
// Assert
ExceptionContextCatchBlock expected =
new ExceptionContextCatchBlock("HttpControllerDispatcher", isTopLevel: false, callsHandler: true);
AssertEqual(expected, catchBlock);
}
[Fact]
public void HttpControllerDispatcher_IsSameInstance()
{
// Arrange
ExceptionContextCatchBlock first = ExceptionCatchBlocks.HttpControllerDispatcher;
// Act
ExceptionContextCatchBlock second = ExceptionCatchBlocks.HttpControllerDispatcher;
// Assert
Assert.Same(first, second);
}
[Fact]
public void HttpServer_IsSpecifiedValue()
{
// Act
ExceptionContextCatchBlock catchBlock = ExceptionCatchBlocks.HttpServer;
// Assert
ExceptionContextCatchBlock expected =
new ExceptionContextCatchBlock("HttpServer", isTopLevel: true, callsHandler: true);
AssertEqual(expected, catchBlock);
}
[Fact]
public void HttpServer_IsSameInstance()
{
// Arrange
ExceptionContextCatchBlock first = ExceptionCatchBlocks.HttpServer;
// Act
ExceptionContextCatchBlock second = ExceptionCatchBlocks.HttpServer;
// Assert
Assert.Same(first, second);
}
[Fact]
public void IExceptionFilter_IsSpecifiedValue()
{
// Act
ExceptionContextCatchBlock catchBlock = ExceptionCatchBlocks.IExceptionFilter;
// Assert
ExceptionContextCatchBlock expected =
new ExceptionContextCatchBlock("IExceptionFilter", isTopLevel: false, callsHandler: true);
AssertEqual(expected, catchBlock);
}
[Fact]
public void IExceptionFilter_IsSameInstance()
{
// Arrange
ExceptionContextCatchBlock first = ExceptionCatchBlocks.IExceptionFilter;
// Act
ExceptionContextCatchBlock second = ExceptionCatchBlocks.IExceptionFilter;
// Assert
Assert.Same(first, second);
}
private static void AssertEqual(ExceptionContextCatchBlock expected, ExceptionContextCatchBlock actual)
{
if (expected == null)
{
Assert.Null(actual);
return;
}
Assert.NotNull(actual);
Assert.Equal(expected.Name, actual.Name);
Assert.Equal(expected.IsTopLevel, actual.IsTopLevel);
Assert.Equal(expected.CallsHandler, actual.CallsHandler);
}
}
}