Repository navigation
Commit cefa875
authored
GET request parameters: retarget net10.0, drop AutoMapper, real test assertions (#2177)
Retarget both projects from net6.0 to net10.0.
Remove AutoMapper. Product and ProductDto declared the same six properties
in the same order, so the mapper copied an object onto its identical twin,
which taught nothing about passing parameters to a GET action. The package,
Mapper/Map.cs, Models/ProductDto.cs, the IMapper field and constructor, and
all eight Map calls are gone; every endpoint now returns the entity and the
JSON responses are byte-identical to before.
Program.cs moves to top-level statements, with the public partial class
Program declaration WebApplicationFactory<Program> needs in the test project.
Packages: Swashbuckle.AspNetCore 6.2.3 to 10.2.3, MSTest 2.2.8 to the 4.3.3
meta package, Microsoft.NET.Test.Sdk 17.1.0 to 18.9.0,
Microsoft.AspNetCore.Mvc.Testing 6.0.0 to 10.0.11, coverlet.collector 3.1.2
to 10.0.1. Newtonsoft.Json 13.0.4 is now referenced explicitly: it used to
arrive transitively through Microsoft.TestPlatform.TestHost 17.1.0, which
declared Newtonsoft.Json 9.0.1; TestHost 18.9.0 declares no such dependency,
so the tests would not compile without it.
Tests: all eight asserted nothing. Each did Assert.IsNotNull followed by a
foreach over the response, so an empty list passed green, and there was no
count assertion in the file. One of the eight really did return empty: the
route-plus-query test called ?waranty=2, one r, against a warranty parameter,
so the value never bound, warranty defaulted to 0, and no product matched.
Fixed the spelling and gave every test a status-code check, a count check and
an exact identity check on the returned products. With the misspelling still
in place the corrected test fails on the count, expected 2 and actual 0.
Build clean with 0 warnings, 8 of 8 tests passing on net10.0.1 parent 0b8e13b commit cefa875
7 files changed
Lines changed: 106 additions & 180 deletions
File tree
- aspnetcore-webapi/MultipleParametersInGetMethod
- MultipleParametersInGetMethod
- Controllers
- Mapper
- Models
- Test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
4 | 2 | | |
5 | 3 | | |
| |||
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | 20 | | |
29 | 21 | | |
30 | 22 | | |
| |||
33 | 25 | | |
34 | 26 | | |
35 | 27 | | |
36 | | - | |
| 28 | + | |
37 | 29 | | |
38 | 30 | | |
39 | 31 | | |
| |||
45 | 37 | | |
46 | 38 | | |
47 | 39 | | |
48 | | - | |
| 40 | + | |
49 | 41 | | |
50 | 42 | | |
51 | 43 | | |
52 | 44 | | |
53 | 45 | | |
54 | | - | |
| 46 | + | |
55 | 47 | | |
56 | | - | |
| 48 | + | |
57 | 49 | | |
58 | 50 | | |
59 | 51 | | |
60 | 52 | | |
61 | 53 | | |
62 | | - | |
| 54 | + | |
63 | 55 | | |
64 | | - | |
| 56 | + | |
65 | 57 | | |
66 | 58 | | |
67 | 59 | | |
68 | 60 | | |
69 | 61 | | |
70 | | - | |
| 62 | + | |
71 | 63 | | |
72 | | - | |
| 64 | + | |
73 | 65 | | |
74 | 66 | | |
75 | 67 | | |
76 | 68 | | |
77 | 69 | | |
78 | 70 | | |
79 | 71 | | |
80 | | - | |
| 72 | + | |
81 | 73 | | |
82 | | - | |
| 74 | + | |
83 | 75 | | |
84 | 76 | | |
85 | 77 | | |
86 | | - | |
| 78 | + | |
87 | 79 | | |
88 | | - | |
| 80 | + | |
89 | 81 | | |
90 | | - | |
| 82 | + | |
91 | 83 | | |
92 | 84 | | |
93 | 85 | | |
94 | 86 | | |
95 | 87 | | |
96 | | - | |
| 88 | + | |
97 | 89 | | |
98 | | - | |
| 90 | + | |
99 | 91 | | |
100 | 92 | | |
101 | | - | |
| 93 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
2 | 13 | | |
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 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
0 commit comments