Skip to content

Commit 130b61b

Browse files
Edouard Poorclaude
andcommitted
Fix spelling and grammar errors in RATIONALE.md
Correct numerous spelling and grammar issues throughout the document: Spelling corrections: - later → layer (business/domain layer) - thios → this - tranverse → traverse - devlepment → development - interfaced → interface - frameworking → frameworks - databae → database - psuedocode → pseudocode - equivilent → equivalent (9 instances) - strucurally → structurally (3 instances) - Reponse → Response (3 instances) - feilds → fields - expcted → expected - exampkle → example - consistantly → consistently Grammar corrections: - Fix possessive forms: engineers → engineer's/engineers' - Capitalize proper noun: docker → Docker - Fix verb form: "the send" → "to send" - Fix article: "a HTTP" → "an HTTP" - Fix typo in example: "test/html" → "text/html" - Add missing preposition: "added the server" → "added by the server" No changes to meaning or technical content. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 0b74d22 commit 130b61b

File tree

1 file changed

+49
-43
lines changed

1 file changed

+49
-43
lines changed

docs/RATIONALE.md

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Specifically ASP.NET and the .NET ecosystem give us:
1212

1313
* **TestServer** and **WebApplicationFactory**
1414

15-
The ability to instantiate the running API and as much of the business/domain later as
16-
required, and a client to interact with it, all running fast and locally on the engineers
15+
The ability to instantiate the running API and as much of the business/domain layer as
16+
required, and a client to interact with it, all running fast and locally on the engineer's
1717
laptop.
1818

1919
* **XUnit**, **Moq**, **AwesomeAssertions**, **Reqnroll**
@@ -23,21 +23,21 @@ Specifically ASP.NET and the .NET ecosystem give us:
2323
methods or classes, but are broadly used across the industry further up the test
2424
pyramid
2525

26-
The tests built with thios infrastructure is integrated into engineers IDEs and command-line
27-
tooling, and can even be run automatically with test runners like NCrunch or dotCovers
26+
The tests built with this infrastructure are integrated into engineers' IDEs and command-line
27+
tooling, and can even be run automatically with test runners like NCrunch or dotCover's
2828
Continuous Testing mode.
2929

3030
Reqnroll extends the automated tests to Behaviour Driven Design using the industry standard
3131
cucumber format, which transparently compiles down to unit tests.
3232

3333
* **TestContainers**
3434

35-
The ability to include other systems and and services directly into your unit tests in a
36-
transparent and fully managed way using docker containers.
35+
The ability to include other systems and services directly into your unit tests in a
36+
transparent and fully managed way using Docker containers.
3737

3838
A great example is running a database as part of your unit tests, so a call to the API within
39-
your unit tests can tranverse the code all the way to the database and back again to not only
40-
validate your API, but also the full vertical slice of you code all the way to the DB.
39+
your unit tests can traverse the code all the way to the database and back again to not only
40+
validate your API, but also the full vertical slice of your code all the way to the DB.
4141

4242
### Aside - "Unit Tests" vs "Fast Tests"
4343

@@ -76,14 +76,14 @@ I'm going to use the phrase "Unit Tests" throughout this document, but mostly I
7676

7777
## Correct and Complete
7878

79-
In software devlepment, there is an idea of Correct and Complete, where the code does what it is
79+
In software development, there is an idea of Correct and Complete, where the code does what it is
8080
supposed to do, without any bugs or misbehaviour (the "Correct" part), and it handles all the possible
8181
use cases, not just the happy path, and performs as intended in every one of those scenarios (the
8282
"Complete" part).
8383

8484
For example, a server should be able to handle
8585

86-
* the network changing on the fly - a network interfaced being added or removed
86+
* the network changing on the fly - a network interface being added or removed
8787
* the disk filling up, so there is no space to write files locally
8888
* inputs being invalid
8989
* deadlocks cancelling a query in the database
@@ -96,21 +96,21 @@ Each "unhappy path" should have a clear strategy for handling the situation
9696

9797
I find that many teams do a good job of correctness, but only a so-so job on completeness.
9898

99-
Mocking frameworking like Moq help here a lot - failure modes that are hard or near impossible to
99+
Mocking frameworks like Moq help here a lot - failure modes that are hard or near impossible to
100100
trigger in a live system (whether in prod or pre-prod) can be invoked by a strategic mock when running
101-
the systems inside your unit tests - like mocking the databae layer to throw a
101+
the systems inside your unit tests - like mocking the database layer to throw a
102102
`MySqlException(ER_LOCK_DEADLOCK)` to ensure the system handles the deadlock correctly, ideally by retrying
103103
the SQL statement or transaction.
104104

105105
## So how do we test an API?
106106

107-
The simplest level of testing is the send a request to the REST API, and validate we get the
108-
correct Reponse, by comparing the result to what we expected.
107+
The simplest level of testing is to send a request to the REST API, and validate we get the
108+
correct Response, by comparing the result to what we expected.
109109

110-
In psuedocode this would be
110+
In pseudocode this would be
111111

112112
```
113-
expectedResponse = new HttpReponse(...) // specify the expected response we want
113+
expectedResponse = new HttpResponse(...) // specify the expected response we want
114114
request = new HttpRequest("GET", "/api/user/1234")
115115
actualResponse = httpClient.send(request)
116116
Assert.Equal(expectedResponse, actualResponse)
@@ -124,7 +124,7 @@ We send
124124
GET /api/user/1234 HTTP/1.1
125125
```
126126

127-
And we get a HTTP Reponse
127+
And we get an HTTP Response
128128

129129
```
130130
HTTP/1.1 200 OK
@@ -146,26 +146,28 @@ Content-Type: application/json
146146
But this is where we have to stop and consider what we mean by the expected response being
147147
equal to the actual response.
148148

149+
## Headers
150+
149151
### Header Case
150152

151-
The HTTP spec states that we should treat the header "content-type: text/html" to be equivilent to
152-
the header "Content-type: text/html"
153+
The HTTP spec states that we should treat the header `content-type: text/html` to be equivalent to
154+
the header `Content-type: text/html`
153155

154156
### Header Whitespace
155157

156-
The HTTP spec also states that the header "Content-type: text/html" is equivilent to the header
157-
"Content-type: test/html ". i.e. additional whitespace is ignored
158+
The HTTP spec also states that the header `Content-type: text/html` is equivalent to the header
159+
`Content-type: text/html `. i.e. additional whitespace is ignored
158160

159161
### Cache-Control Header and Parameter Order
160162

161-
Another thing the spec says is that "Cache-Control: max-age=3600, no-store" is equivilent to
162-
"Cache-Control: no-store, max-age=3600".
163+
Another thing the spec says is that `Cache-Control: max-age=3600, no-store` is equivalent to
164+
`Cache-Control: no-store, max-age=3600`.
163165

164-
If your expected response is "Cache-Control: max-age=3600, no-store", but the actual response
165-
is "Cache-Control: no-store, max-age=3600" you want to say that that expected header matches.
166+
If your expected response is `Cache-Control: max-age=3600, no-store`, but the actual response
167+
is `Cache-Control: no-store, max-age=3600` you want to say that that expected header matches.
166168

167169
But that there are some headers where the order is important, e.g.
168-
"Content-Encoding: sdch, gzip". The order matters, and cannot be reversed.
170+
`Content-Encoding: sdch, gzip`. The order matters, and cannot be reversed.
169171

170172
### Date Header
171173

@@ -178,23 +180,23 @@ where you want the header to be present, but you don't care about the value
178180

179181
### X-Request-ID Header
180182

181-
There are some headers that may be added the server code, or by middleware, or even
182-
by intermediate proxies. "X-Request-ID" is one of these, and we may want to ignore it
183+
There are some headers that may be added by the server code, or by middleware, or even
184+
by intermediate proxies. `X-Request-ID` is one of these, and we may want to ignore it
183185
altogether, or simply validate that the header is present, while ignoring the
184186
value.
185187

186-
"Via: 1.1 varnish" is explicitly a proxy header, and may be added by intermediate hops
188+
`Via: 1.1 varnish` is explicitly a proxy header, and may be added by intermediate hops
187189
in the HTTP request when running in the real world.
188190

189191

190192
## JSON Response Body
191193

192-
The JSON body itself can be strucurally equivilent, but not be exactly the same.
194+
The JSON body itself can be structurally equivalent, but not be exactly the same.
193195

194196
### Whitespace
195197

196-
`{"Username":"joeblogs"}` is strucurally equivilent to `{ "Username": "joeblogs" }`
197-
which is also equivilent to
198+
`{"Username":"joeblogs"}` is structurally equivalent to `{ "Username": "joeblogs" }`
199+
which is also equivalent to
198200

199201
```
200202
{
@@ -211,7 +213,7 @@ which is also equivilent to
211213
}
212214
```
213215

214-
is strucrally equivilent to
216+
is structurally equivalent to
215217

216218
```
217219
{
@@ -220,29 +222,33 @@ is strucrally equivilent to
220222
}
221223
```
222224

223-
### Numerical Equivilence
225+
### Numerical Equivalence
226+
227+
TODO
224228

225229
1 ≡ 1.0 ≡ 1e0
226230

227231

228-
### Escaped Equivilence
232+
### Escaped Equivalence
233+
234+
TODO
229235

230236
"hello" ≡ "he\u006Clo"
231237

232238

233239
## Selective Field Testing, Field Presence Only
234240

235241
Sometimes, when testing a specific action with an API, we may not care about all of
236-
the feilds, but only the ones that are relevant to the action we are performing.
242+
the fields, but only the ones that are relevant to the action we are performing.
237243

238244
Another common case is that we want to ensure that a certain field is present, but we don't
239245
care what the value is. E.g. when creating a new entity.
240246

241-
For example a POST call to /api/job,
242-
where we care that we get a reponse back with the job details, but every call to the API
247+
For example a POST call to /api/job,
248+
where we care that we get a response back with the job details, but every call to the API
243249
will give us a unique job ID.
244250

245-
This is a little like the Date: or X-Request-ID headers - we may want to ensure the reponse
251+
This is a little like the Date: or X-Request-ID headers - we may want to ensure the response
246252
has a field, but we know that the value for that field changes every time.
247253

248254

@@ -253,14 +259,14 @@ Sooner or later the response may have values that could be correct or incorrect
253259
meaning of data.
254260

255261
e.g. does the order of the value matter in this array `[1,2,3]`? Is `[2,1,3]` the same? Almost always
256-
no, but its more grey with something like `[{"StockId": 221313},{"StockId": 621142}]`. at this point
262+
no, but it's more grey with something like `[{"StockId": 221313},{"StockId": 621142}]`. At this point
257263
the answer may end up being "it depends".
258264

259265
Sometimes we are working with an ordered list, and sometimes we are not. JSON has no "set" datatype. Some
260266
JSON HTTP Responses might have multiple arrays, some which need to be treated as ordered arrays, and
261267
some that should be treated as unordered sets.
262268

263-
And another valid JSON reponse might be `{"a":1, "a":2}`, which is "valid" JSON text under RFC 8259, but its not "well-defined". Treating this consistantly is also hard.
269+
And another valid JSON response might be `{"a":1, "a":2}`, which is "valid" JSON text under RFC 8259, but it's not "well-defined". Treating this consistently is also hard.
264270

265271
And then there is Unicode normalisation: "é" vs "e\u0301"
266272

@@ -298,11 +304,11 @@ Actual Response:
298304
```
299305

300306
If we just want to ensure that the status code is working as expected, then we may want to
301-
only check if the expcted response is a subset of the actual reponse.
307+
only check if the expected response is a subset of the actual response.
302308

303309
## Ignoring values
304310

305-
Building on the subset exampkle above, it may be good to do a subset match, but also have the
311+
Building on the subset example above, it may be good to do a subset match, but also have the
306312
ability to ignore the values of certain fields, but check that they are present.
307313

308314
Expected Response:

0 commit comments

Comments
 (0)