Commit efe9bcd
test(integration): Seed write/UoW/audit/delete tests via a separate DbContext (#87)
* test(integration): Seed write/UoW/audit/delete tests via a separate DbContext
Convert Arrange-phase fixture seeding in the remaining integration-test
classes from the repository / UnitOfWork write path to a separate
DbContext (RepositoryHelper.Add...(CreateRootDbContext)), completing the
work begun for ReadRepositoryTests. Seeding through a separate context
keeps the seeded entities out of the code-under-test's change tracker,
so reads genuinely re-hydrate from the database and the fixture setup no
longer depends on the write path it is meant to be independent of.
Per-test classification (Arrange converted, Act left in place):
- ReadWriteRepositoryAsyncTests: all 9 read-test seedings converted.
- ReadWriteRepositoryDeleteByIdTests: 3 Arrange seedings converted.
- UnitOfWorkRepositoryAsyncSQLiteInMemoryTests: 3 update/delete-test
Arrange seedings converted; the add+commit calls in the add-and-query
and AddAsync tests left repository-based (the add IS the test) with
explanatory comments.
- ReadWriteRepositoryAsyncAuditTests: both seedings left repository-based
(the class verifies the repository write path's audit behaviour) with
explanatory comments.
Add DbContext and Func<DbContext> overloads to RepositoryHelper's
AddTestBlogEntities helper. Fix UpdateAsync_entity, which was a vacuous
self-comparison (seed and read shared one change-tracker instance) until
the seed context was separated; exclude the audit columns it does not
assert on.
Refs: #85
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test(integration): Use fetch-modify-update in UpdateAsync_entity
Address PR #87 review feedback (gemini-code-assist, codeant-ai): the
previous UpdateAsync_entity built a partial Blog (Id + Name only), and
ReadWriteRepositoryAsync.UpdateAsync applies it via CurrentValues.SetValues,
which blanks every unsupplied column — including CreatedTime. Excluding
CreatedTime from the assertion masked that.
Switch to the idiomatic fetch-modify-update pattern so the update payload
carries every column; CreatedTime is now preserved and asserted rather
than excluded. Only ModifiedTime stays excluded (UpdateAsync legitimately
changes it).
Refs: #85
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test(integration): Deconstruct seeding tuple in FindFirstAsync test
Address the SonarCloud IDE0042 finding on PR #87: the FindFirstAsync
seeding result was bound to a named variable when only one element was
used. Deconstruct the tuple directly (`var (_, blogPost1, _)`).
Refs: #85
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test(integration): Add DbContext seed overloads for the UserIdea helper
Address PR #87 review feedback (@kploch): issue #85's acceptance criteria
lists the UserIdea helpers among those needing DbContext / Func<DbContext>
seed overloads. Add them to AddAsyncTestUserIdeasEntitiesAsync (real logic
in the DbContext overload; the Func<DbContext> overload wraps it with
await using) so future Arrange-phase UserIdea tests can seed via a
separate context without falling back to the repository write path.
Refs: #85
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(solution): Fix editorconfig test glob and clear SonarCloud findings
The `[*Tests/**/*.cs]` editorconfig section header never matched any
file. The section is anchored to the repository root and requires the
first path segment to end in literal `Tests`, but test projects live
under the lowercase `tests/` directory and editorconfig globs are
case-sensitive. As a result the `IDE0058` ("Expression value is never
used") suppression intended for test code never took effect, leaving
SonarCloud to import the diagnostic for every idiomatic discard of an
`EntityEntry` returned by `AddAsync`. Corrected the header to
`[tests/**/*.cs]`.
Also cleared the remaining SonarCloud findings on PR #87:
- Renamed the new async seeding overloads `AddTestBlogEntities` to
`AddTestBlogEntitiesAsync` (CC0061).
- Simplified the `UserIdea` array returns to collection expressions
(IDE0300).
Refs: #85
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 582c83b commit efe9bcd
6 files changed
Lines changed: 172 additions & 83 deletions
File tree
- tests/Data.GenericRepository/Data.GenericRepository.EFCore.IntegrationTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
707 | 707 | | |
708 | 708 | | |
709 | 709 | | |
710 | | - | |
| 710 | + | |
711 | 711 | | |
712 | 712 | | |
713 | 713 | | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| |||
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
| |||
Lines changed: 30 additions & 48 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
39 | 37 | | |
40 | 38 | | |
41 | 39 | | |
| |||
46 | 44 | | |
47 | 45 | | |
48 | 46 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
54 | 50 | | |
55 | 51 | | |
56 | 52 | | |
| |||
70 | 66 | | |
71 | 67 | | |
72 | 68 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
78 | 72 | | |
79 | 73 | | |
80 | 74 | | |
| |||
86 | 80 | | |
87 | 81 | | |
88 | 82 | | |
89 | | - | |
90 | | - | |
| 83 | + | |
| 84 | + | |
91 | 85 | | |
92 | 86 | | |
93 | 87 | | |
94 | 88 | | |
95 | 89 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
101 | 93 | | |
102 | 94 | | |
103 | 95 | | |
| |||
121 | 113 | | |
122 | 114 | | |
123 | 115 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
129 | 119 | | |
130 | 120 | | |
131 | 121 | | |
| |||
156 | 146 | | |
157 | 147 | | |
158 | 148 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
164 | 152 | | |
165 | 153 | | |
166 | 154 | | |
| |||
182 | 170 | | |
183 | 171 | | |
184 | 172 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
190 | 176 | | |
191 | 177 | | |
192 | 178 | | |
| |||
197 | 183 | | |
198 | 184 | | |
199 | 185 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
205 | 189 | | |
206 | 190 | | |
207 | 191 | | |
| |||
275 | 259 | | |
276 | 260 | | |
277 | 261 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
283 | 265 | | |
284 | 266 | | |
285 | 267 | | |
286 | 268 | | |
287 | 269 | | |
288 | 270 | | |
289 | | - | |
| 271 | + | |
290 | 272 | | |
291 | 273 | | |
292 | 274 | | |
| |||
Lines changed: 17 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
52 | 56 | | |
53 | 57 | | |
54 | 58 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
| |||
Lines changed: 87 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 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 | + | |
57 | 103 | | |
58 | 104 | | |
59 | 105 | | |
60 | 106 | | |
61 | 107 | | |
62 | 108 | | |
63 | 109 | | |
64 | | - | |
| 110 | + | |
65 | 111 | | |
66 | 112 | | |
67 | 113 | | |
| |||
206 | 252 | | |
207 | 253 | | |
208 | 254 | | |
209 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
210 | 295 | | |
211 | 296 | | |
212 | 297 | | |
| |||
0 commit comments