Skip to content

Commit 25111af

Browse files
authored
Merge pull request #49 from devlead/feature/disable
Enhance `Routes` with `DisableRequests` functionality
2 parents bb3e708 + a91e8d6 commit 25111af

12 files changed

+387
-26
lines changed

src/Devlead.Testing.MockHttp.Tests/Constants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ namespace Devlead.Testing.MockHttp.Tests;
22

33
public class Constants
44
{
5+
public class Uris
6+
{
7+
public const string Index_Txt = "https://example.com/index.txt";
8+
public const string New_Txt = "https://example.com/new.txt";
9+
}
510
}

src/Devlead.Testing.MockHttp.Tests/Devlead.Testing.MockHttp.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<PackageReference Include="NUnit" />
2828
<PackageReference Include="NUnit.Analyzers" />
2929
<PackageReference Include="NUnit3TestAdapter" />
30+
<PackageReference Include="System.Linq.Async" />
3031
<PackageReference Include="Verify.NUnit" />
3132
<PackageReference Include="System.Text.Json" />
3233
<PackageReference Include="Verify.Http" VersionOverride="6.4.1" Condition="'$(TargetFramework)' != 'net9.0'" />

src/Devlead.Testing.MockHttp.Tests/Resources/Routes.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,74 @@
4141
"StatusCode": 200
4242
}
4343
]
44+
},
45+
{
46+
"Request": {
47+
"Methods": [
48+
{
49+
"Method": "PUT"
50+
}
51+
],
52+
"AbsoluteUri": "https://example.com/new.txt"
53+
},
54+
"Responses": [
55+
{
56+
"StatusCode": 201,
57+
"EnableRequests": [
58+
{
59+
"Method": "GET",
60+
"AbsoluteUri": "https://example.com/new.txt"
61+
},
62+
63+
{
64+
"Method": "DELETE",
65+
"AbsoluteUri": "https://example.com/new.txt"
66+
}
67+
]
68+
}
69+
]
70+
},
71+
{
72+
"Request": {
73+
"Methods": [
74+
{
75+
"Method": "GET"
76+
}
77+
],
78+
"AbsoluteUri": "https://example.com/new.txt",
79+
"Disabled": true
80+
},
81+
"Responses": [
82+
{
83+
"StatusCode": 200
84+
}
85+
]
86+
},
87+
{
88+
"Request": {
89+
"Methods": [
90+
{
91+
"Method": "DELETE"
92+
}
93+
],
94+
"AbsoluteUri": "https://example.com/new.txt",
95+
"Disabled": true
96+
},
97+
"Responses": [
98+
{
99+
"StatusCode": 204,
100+
"DisableRequests": [
101+
{
102+
"Method": "GET",
103+
"AbsoluteUri": "https://example.com/new.txt"
104+
},
105+
106+
{
107+
"Method": "DELETE",
108+
"AbsoluteUri": "https://example.com/new.txt"
109+
}
110+
]
111+
}
112+
]
44113
}
45114
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[
2+
{
3+
Version: 1.1,
4+
Content: {
5+
Headers: [
6+
{
7+
Content-Length: [
8+
0
9+
]
10+
}
11+
]
12+
},
13+
StatusCode: NotFound,
14+
ReasonPhrase: Not Found,
15+
Headers: [],
16+
TrailingHeaders: [],
17+
IsSuccessStatusCode: false
18+
}
19+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[
2+
{
3+
Version: 1.1,
4+
Content: {
5+
Headers: [
6+
{
7+
Content-Length: [
8+
0
9+
]
10+
}
11+
]
12+
},
13+
StatusCode: NotFound,
14+
ReasonPhrase: Not Found,
15+
Headers: [],
16+
TrailingHeaders: [],
17+
IsSuccessStatusCode: false
18+
}
19+
]
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[
2+
{
3+
Version: 1.1,
4+
Content: {
5+
Headers: [
6+
{
7+
Content-Length: [
8+
0
9+
]
10+
}
11+
]
12+
},
13+
StatusCode: Created,
14+
ReasonPhrase: Created,
15+
Headers: [],
16+
TrailingHeaders: [],
17+
IsSuccessStatusCode: true
18+
},
19+
{
20+
Version: 1.1,
21+
Content: {
22+
Headers: [
23+
{
24+
Content-Length: [
25+
0
26+
]
27+
}
28+
]
29+
},
30+
StatusCode: NoContent,
31+
ReasonPhrase: No Content,
32+
Headers: [],
33+
TrailingHeaders: [],
34+
IsSuccessStatusCode: true
35+
},
36+
{
37+
Version: 1.1,
38+
Content: {
39+
Headers: [
40+
{
41+
Content-Length: [
42+
0
43+
]
44+
}
45+
]
46+
},
47+
StatusCode: NotFound,
48+
ReasonPhrase: Not Found,
49+
Headers: [],
50+
TrailingHeaders: [],
51+
IsSuccessStatusCode: false
52+
}
53+
]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[
2+
{
3+
Version: 1.1,
4+
Content: {
5+
Headers: [
6+
{
7+
Content-Length: [
8+
0
9+
]
10+
}
11+
]
12+
},
13+
StatusCode: Created,
14+
ReasonPhrase: Created,
15+
Headers: [],
16+
TrailingHeaders: [],
17+
IsSuccessStatusCode: true
18+
},
19+
{
20+
Version: 1.1,
21+
Content: {
22+
Headers: [
23+
{
24+
Content-Length: [
25+
0
26+
]
27+
}
28+
]
29+
},
30+
StatusCode: NoContent,
31+
ReasonPhrase: No Content,
32+
Headers: [],
33+
TrailingHeaders: [],
34+
IsSuccessStatusCode: true
35+
}
36+
]
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[
2+
{
3+
Version: 1.1,
4+
Content: {
5+
Headers: [
6+
{
7+
Content-Length: [
8+
0
9+
]
10+
}
11+
]
12+
},
13+
StatusCode: Created,
14+
ReasonPhrase: Created,
15+
Headers: [],
16+
TrailingHeaders: [],
17+
IsSuccessStatusCode: true
18+
},
19+
{
20+
Version: 1.1,
21+
Content: {
22+
Headers: [
23+
{
24+
Content-Length: [
25+
0
26+
]
27+
}
28+
]
29+
},
30+
StatusCode: OK,
31+
ReasonPhrase: OK,
32+
Headers: [],
33+
TrailingHeaders: [],
34+
IsSuccessStatusCode: true
35+
},
36+
{
37+
Version: 1.1,
38+
Content: {
39+
Headers: [
40+
{
41+
Content-Length: [
42+
0
43+
]
44+
}
45+
]
46+
},
47+
StatusCode: NoContent,
48+
ReasonPhrase: No Content,
49+
Headers: [],
50+
TrailingHeaders: [],
51+
IsSuccessStatusCode: true
52+
}
53+
]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[
2+
{
3+
Version: 1.1,
4+
Content: {
5+
Headers: [
6+
{
7+
Content-Length: [
8+
0
9+
]
10+
}
11+
]
12+
},
13+
StatusCode: Created,
14+
ReasonPhrase: Created,
15+
Headers: [],
16+
TrailingHeaders: [],
17+
IsSuccessStatusCode: true
18+
},
19+
{
20+
Version: 1.1,
21+
Content: {
22+
Headers: [
23+
{
24+
Content-Length: [
25+
0
26+
]
27+
}
28+
]
29+
},
30+
StatusCode: OK,
31+
ReasonPhrase: OK,
32+
Headers: [],
33+
TrailingHeaders: [],
34+
IsSuccessStatusCode: true
35+
}
36+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[
2+
{
3+
Version: 1.1,
4+
Content: {
5+
Headers: [
6+
{
7+
Content-Length: [
8+
0
9+
]
10+
}
11+
]
12+
},
13+
StatusCode: Created,
14+
ReasonPhrase: Created,
15+
Headers: [],
16+
TrailingHeaders: [],
17+
IsSuccessStatusCode: true
18+
}
19+
]

0 commit comments

Comments
 (0)