2
2
using FluentAssertions . Specialized ;
3
3
using JsonApiDotNetCore . OpenApi . Client ;
4
4
using Newtonsoft . Json ;
5
- using OpenApiEndToEndTests . ClientGeneratedId . GeneratedCode ;
5
+ using OpenApiEndToEndTests . ClientIdGenerationModes . GeneratedCode ;
6
6
using OpenApiTests ;
7
- using OpenApiTests . ClientGeneratedId ;
7
+ using OpenApiTests . ClientIdGenerationModes ;
8
8
using TestBuildingBlocks ;
9
9
using Xunit ;
10
10
11
- namespace OpenApiEndToEndTests . ClientGeneratedId ;
11
+ namespace OpenApiEndToEndTests . ClientIdGenerationModes ;
12
12
13
- public sealed class PostTests : IClassFixture < IntegrationTestContext < OpenApiStartup < ClientGeneratedIdDbContext > , ClientGeneratedIdDbContext > >
13
+ public sealed class PostTests : IClassFixture < IntegrationTestContext < OpenApiStartup < ClientIdGenerationModesDbContext > , ClientIdGenerationModesDbContext > >
14
14
{
15
- private readonly IntegrationTestContext < OpenApiStartup < ClientGeneratedIdDbContext > , ClientGeneratedIdDbContext > _testContext ;
16
- private readonly ClientGeneratedIdFakers _fakers = new ( ) ;
15
+ private readonly IntegrationTestContext < OpenApiStartup < ClientIdGenerationModesDbContext > , ClientIdGenerationModesDbContext > _testContext ;
16
+ private readonly ClientIdGenerationModesFakers _fakers = new ( ) ;
17
17
18
- public PostTests ( IntegrationTestContext < OpenApiStartup < ClientGeneratedIdDbContext > , ClientGeneratedIdDbContext > testContext )
18
+ public PostTests ( IntegrationTestContext < OpenApiStartup < ClientIdGenerationModesDbContext > , ClientIdGenerationModesDbContext > testContext )
19
19
{
20
20
_testContext = testContext ;
21
21
22
22
testContext . UseController < PlayersController > ( ) ;
23
23
testContext . UseController < GamesController > ( ) ;
24
- testContext . UseController < GroupsController > ( ) ;
24
+ testContext . UseController < PlayerGroupsController > ( ) ;
25
25
}
26
26
27
27
[ Fact ]
28
- public async Task Omit_required_id ( )
28
+ public async Task Cannot_create_resource_without_ID_when_mode_is_required ( )
29
29
{
30
30
// Arrange
31
31
Player player = _fakers . Player . Generate ( ) ;
32
32
33
33
using HttpClient httpClient = _testContext . Factory . CreateClient ( ) ;
34
- ClientGeneratedIdClient apiClient = new ( httpClient ) ;
34
+ ClientIdGenerationModesClient apiClient = new ( httpClient ) ;
35
35
36
36
// Act
37
37
Func < Task < PlayerPrimaryResponseDocument ? > > action = ( ) => ApiResponse . TranslateAsync ( ( ) => apiClient . PostPlayerAsync ( null , new PlayerPostRequestDocument
@@ -41,7 +41,7 @@ public async Task Omit_required_id()
41
41
Id = null ! ,
42
42
Attributes = new PlayerAttributesInPostRequest
43
43
{
44
- Name = player . Name
44
+ UserName = player . UserName
45
45
}
46
46
}
47
47
} ) ) ;
@@ -52,14 +52,14 @@ public async Task Omit_required_id()
52
52
}
53
53
54
54
[ Fact ]
55
- public async Task Pass_required_id ( )
55
+ public async Task Can_create_resource_with_ID_when_mode_is_required ( )
56
56
{
57
57
// Arrange
58
58
Player player = _fakers . Player . Generate ( ) ;
59
59
player . Id = Guid . NewGuid ( ) ;
60
60
61
61
using HttpClient httpClient = _testContext . Factory . CreateClient ( ) ;
62
- ClientGeneratedIdClient apiClient = new ( httpClient ) ;
62
+ ClientIdGenerationModesClient apiClient = new ( httpClient ) ;
63
63
64
64
// Act
65
65
Func < Task < PlayerPrimaryResponseDocument ? > > action = ( ) => ApiResponse . TranslateAsync ( ( ) => apiClient . PostPlayerAsync ( null , new PlayerPostRequestDocument
@@ -69,7 +69,7 @@ public async Task Pass_required_id()
69
69
Id = player . StringId ! ,
70
70
Attributes = new PlayerAttributesInPostRequest
71
71
{
72
- Name = player . Name
72
+ UserName = player . UserName
73
73
}
74
74
}
75
75
} ) ) ;
@@ -80,13 +80,13 @@ public async Task Pass_required_id()
80
80
}
81
81
82
82
[ Fact ]
83
- public async Task Omit_allowed_id ( )
83
+ public async Task Can_create_resource_without_ID_when_mode_is_allowed ( )
84
84
{
85
85
// Arrange
86
86
Game game = _fakers . Game . Generate ( ) ;
87
87
88
88
using HttpClient httpClient = _testContext . Factory . CreateClient ( ) ;
89
- ClientGeneratedIdClient apiClient = new ( httpClient ) ;
89
+ ClientIdGenerationModesClient apiClient = new ( httpClient ) ;
90
90
91
91
// Act
92
92
Func < Task < GamePrimaryResponseDocument ? > > action = ( ) => ApiResponse . TranslateAsync ( ( ) => apiClient . PostGameAsync ( null , new GamePostRequestDocument
@@ -96,8 +96,8 @@ public async Task Omit_allowed_id()
96
96
Id = null ! ,
97
97
Attributes = new GameAttributesInPostRequest
98
98
{
99
- Name = game . Name ,
100
- Price = ( double ) game . Price
99
+ Title = game . Title ,
100
+ PurchasePrice = ( double ) game . PurchasePrice
101
101
}
102
102
}
103
103
} ) ) ;
@@ -108,14 +108,14 @@ public async Task Omit_allowed_id()
108
108
}
109
109
110
110
[ Fact ]
111
- public async Task Pass_allowed_id ( )
111
+ public async Task Can_create_resource_with_ID_when_mode_is_allowed ( )
112
112
{
113
113
// Arrange
114
114
Game game = _fakers . Game . Generate ( ) ;
115
115
game . Id = Guid . NewGuid ( ) ;
116
116
117
117
using HttpClient httpClient = _testContext . Factory . CreateClient ( ) ;
118
- ClientGeneratedIdClient apiClient = new ( httpClient ) ;
118
+ ClientIdGenerationModesClient apiClient = new ( httpClient ) ;
119
119
120
120
// Act
121
121
Func < Task < GamePrimaryResponseDocument ? > > action = ( ) => ApiResponse . TranslateAsync ( ( ) => apiClient . PostGameAsync ( null , new GamePostRequestDocument
@@ -125,8 +125,8 @@ public async Task Pass_allowed_id()
125
125
Id = game . StringId ! ,
126
126
Attributes = new GameAttributesInPostRequest
127
127
{
128
- Name = game . Name ,
129
- Price = ( double ) game . Price
128
+ Title = game . Title ,
129
+ PurchasePrice = ( double ) game . PurchasePrice
130
130
}
131
131
}
132
132
} ) ) ;
@@ -137,28 +137,29 @@ public async Task Pass_allowed_id()
137
137
}
138
138
139
139
[ Fact ]
140
- public async Task Omit_forbidden_id ( )
140
+ public async Task Can_create_resource_without_ID_when_mode_is_forbidden ( )
141
141
{
142
142
// Arrange
143
- Group group = _fakers . Group . Generate ( ) ;
143
+ PlayerGroup playerGroup = _fakers . Group . Generate ( ) ;
144
144
145
145
using HttpClient httpClient = _testContext . Factory . CreateClient ( ) ;
146
- ClientGeneratedIdClient apiClient = new ( httpClient ) ;
146
+ ClientIdGenerationModesClient apiClient = new ( httpClient ) ;
147
147
148
148
// Act
149
- Func < Task < GroupPrimaryResponseDocument ? > > action = ( ) => ApiResponse . TranslateAsync ( ( ) => apiClient . PostGroupAsync ( null , new GroupPostRequestDocument
150
- {
151
- Data = new GroupDataInPostRequest
149
+ Func < Task < PlayerGroupPrimaryResponseDocument ? > > action = ( ) => ApiResponse . TranslateAsync ( ( ) => apiClient . PostPlayerGroupAsync ( null ,
150
+ new PlayerGroupPostRequestDocument
152
151
{
153
- Attributes = new GroupAttributesInPostRequest
152
+ Data = new PlayerGroupDataInPostRequest
154
153
{
155
- Name = group . Name
154
+ Attributes = new PlayerGroupAttributesInPostRequest
155
+ {
156
+ Name = playerGroup . Name
157
+ }
156
158
}
157
- }
158
- } ) ) ;
159
+ } ) ) ;
159
160
160
161
// Assert
161
- GroupPrimaryResponseDocument ? doc = ( await action . Should ( ) . NotThrowAsync ( ) ) . Subject ;
162
+ PlayerGroupPrimaryResponseDocument ? doc = ( await action . Should ( ) . NotThrowAsync ( ) ) . Subject ;
162
163
doc ? . Data . Id . Should ( ) . NotBeNullOrEmpty ( ) ;
163
164
}
164
165
}
0 commit comments