Skip to content

Commit 85c8d2c

Browse files
committed
Acceptance steps related to scenarios involving HTTP headers.
1 parent 67ff7e9 commit 85c8d2c

1 file changed

Lines changed: 27 additions & 10 deletions

File tree

src/AcceptanceSteps.cs

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,24 +227,41 @@ public Task<HttpResponseMessage> WhenIGetUrlOnTheApiGateway(string url, CookieHe
227227

228228
#region Headers
229229

230-
public void ThenTheResponseHeaderIs(string key, string value) => ThenTheResponseHeaderExists(key).First().ShouldBe(value);
231-
public void ThenTheResponseContentHeaderIs(string key, string value) => ThenTheResponseContentHeaderExists(key).First().ShouldBe(value);
230+
public void ThenTheResponseHeaderIs(string key, string value)
231+
{
232+
ThenTheResponseHeaderExists(key);
233+
var header = response?.Headers.GetValues(key) ?? [];
234+
header.Any(string.IsNullOrEmpty).ShouldBeFalse();
235+
string.Join(';', header).ShouldBe(value);
236+
}
232237

233-
public IEnumerable<string> ThenTheResponseHeaderExists(string key)
238+
public void ThenTheResponseContentHeaderIs(string key, string value)
234239
{
235-
response.ShouldNotBeNull();
236-
response.Headers.Contains(key).ShouldBeTrue();
237-
var header = response.Headers.GetValues(key);
240+
ThenTheResponseContentHeaderExists(key);
241+
var header = response?.Content.Headers.GetValues(key) ?? [];
238242
header.Any(string.IsNullOrEmpty).ShouldBeFalse();
239-
return header;
243+
string.Join(';', header).ShouldBe(value);
244+
}
245+
246+
public string ThenTheResponseHeaderExists(string key)
247+
{
248+
response.ShouldNotBeNull().Headers.Contains(key).ShouldBeTrue();
249+
var header = response.Headers.GetValues(key);
250+
return string.Join(';', header);
240251
}
241-
public IEnumerable<string> ThenTheResponseContentHeaderExists(string key)
252+
253+
public void ThenTheResponseHeaderExists(string key, bool exists)
254+
=> response.ShouldNotBeNull().Headers.Contains(key).ShouldBe(exists);
255+
256+
public string ThenTheResponseContentHeaderExists(string key)
242257
{
243258
response.ShouldNotBeNull().Content.Headers.Contains(key).ShouldBeTrue();
244259
var header = response.Content.Headers.GetValues(key);
245-
header.Any(string.IsNullOrEmpty).ShouldBeFalse();
246-
return header;
260+
return string.Join(';', header);
247261
}
262+
263+
public void ThenTheResponseContentHeaderExists(string key, bool exists)
264+
=> response.ShouldNotBeNull().Content.Headers.Contains(key).ShouldBe(exists);
248265
#endregion
249266

250267
public void ThenTheResponseReasonPhraseIs(string expected)

0 commit comments

Comments
 (0)