File tree Expand file tree Collapse file tree 4 files changed +447
-22
lines changed
src/NimblePros.SampleToDo.Web/Projects
tests/NimblePros.SampleToDo.FunctionalTests Expand file tree Collapse file tree 4 files changed +447
-22
lines changed Original file line number Diff line number Diff line change 1- using FastEndpoints ;
2- using FluentValidation ;
1+ using FluentValidation ;
32using NimblePros . SampleToDo . Infrastructure . Data . Config ;
43
54namespace NimblePros . SampleToDo . Web . Projects ;
@@ -18,6 +17,7 @@ public CreateToDoItemValidator()
1817 . MinimumLength ( 2 )
1918 . MaximumLength ( DataSchemaConstants . DEFAULT_NAME_LENGTH ) ;
2019 RuleFor ( x => x . Description )
20+ . MaximumLength ( 200 ) // TODO: Move to constant
2121 . NotEmpty ( ) ;
2222 }
2323}
Original file line number Diff line number Diff line change 1+ using NimblePros . SampleToDo . Web ;
2+ using NimblePros . SampleToDo . Web . Projects ;
3+
4+ namespace NimblePros . SampleToDo . FunctionalTests . Projects ;
5+
6+ /// <summary>
7+ /// Fluent builder for CreateToDoItemRequest to make tests more readable and maintainable
8+ /// </summary>
9+ public class CreateToDoItemRequestBuilder
10+ {
11+ private readonly CreateToDoItemRequest _request = new ( ) ;
12+
13+ public CreateToDoItemRequestBuilder WithProjectId ( int projectId )
14+ {
15+ _request . ProjectId = projectId ;
16+ return this ;
17+ }
18+
19+ public CreateToDoItemRequestBuilder WithTitle ( string title )
20+ {
21+ _request . Title = title ;
22+ return this ;
23+ }
24+
25+ public CreateToDoItemRequestBuilder WithDescription ( string description )
26+ {
27+ _request . Description = description ;
28+ return this ;
29+ }
30+
31+ public CreateToDoItemRequestBuilder WithContributorId ( int ? contributorId )
32+ {
33+ _request . ContributorId = contributorId ;
34+ return this ;
35+ }
36+
37+ public CreateToDoItemRequestBuilder WithValidDefaults ( )
38+ {
39+ var uniqueId = Guid . NewGuid ( ) . ToString ( ) [ ..8 ] ;
40+ var timestamp = DateTimeOffset . UtcNow . Ticks . ToString ( ) [ ^ 8 ..] ; // Last 8 digits of ticks
41+ return WithProjectId ( SeedData . TestProject1 . Id . Value )
42+ . WithTitle ( $ "Test Todo { uniqueId } -{ timestamp } ")
43+ . WithDescription ( $ "Test Description { uniqueId } -{ timestamp } ") ;
44+ }
45+
46+ public CreateToDoItemRequest Build ( ) => _request ;
47+
48+ public static CreateToDoItemRequestBuilder Create ( ) => new ( ) ;
49+ }
You can’t perform that action at this time.
0 commit comments