-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Groundwork for fair use policy. Updated to .NET 8. Moved to Minimal API rather than MVC.
- Loading branch information
1 parent
5933fd9
commit 2f2fb6f
Showing
35 changed files
with
654 additions
and
519 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Set default behavior to automatically normalize line endings. | ||
* text=auto | ||
|
||
# Collapse these files in PRs by default | ||
*.xlf linguist-generated=true | ||
*.lcl linguist-generated=true | ||
|
||
*.jpg binary | ||
*.png binary | ||
*.gif binary | ||
|
||
# Force bash scripts to always use lf line endings so that if a repo is accessed | ||
# in Unix via a file share from Windows, the scripts will work. | ||
*.in text eol=lf | ||
*.sh text eol=lf | ||
|
||
# Likewise, force cmd and batch scripts to always use crlf | ||
*.cmd text eol=crlf | ||
*.bat text eol=crlf | ||
|
||
*.cs text=auto diff=csharp | ||
*.vb text=auto | ||
*.resx text=auto | ||
*.c text=auto | ||
*.cpp text=auto | ||
*.cxx text=auto | ||
*.h text=auto | ||
*.hxx text=auto | ||
*.py text=auto | ||
*.rb text=auto | ||
*.java text=auto | ||
*.html text=auto | ||
*.htm text=auto | ||
*.css text=auto | ||
*.scss text=auto | ||
*.sass text=auto | ||
*.less text=auto | ||
*.js text=auto | ||
*.lisp text=auto | ||
*.clj text=auto | ||
*.sql text=auto | ||
*.php text=auto | ||
*.lua text=auto | ||
*.m text=auto | ||
*.asm text=auto | ||
*.erl text=auto | ||
*.fs text=auto | ||
*.fsx text=auto | ||
*.hs text=auto | ||
|
||
*.csproj text=auto | ||
*.vbproj text=auto | ||
*.fsproj text=auto | ||
*.dbproj text=auto | ||
*.sln text=auto eol=crlf | ||
|
||
# Set linguist language for .h files explicitly based on | ||
# https://github.com/github/linguist/issues/1626#issuecomment-401442069 | ||
# this only affects the repo's language statistics | ||
*.h linguist-language=C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 17 additions & 13 deletions
30
src/Teapot.Web.Tests/IntegrationTests/CustomHeaderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
using Microsoft.AspNetCore.Mvc.Testing; | ||
using Teapot.Web.Controllers; | ||
|
||
namespace Teapot.Web.Tests.IntegrationTests; | ||
public class CustomHeaderTests { | ||
private static readonly HttpClient _httpClient = new WebApplicationFactory<Program>().CreateDefaultClient(); | ||
|
||
public class CustomHeaderTests | ||
{ | ||
|
||
[Test] | ||
public async Task CanSetCustomHeaders() { | ||
public async Task CanSetCustomHeaders() | ||
{ | ||
HttpClient httpClient = new WebApplicationFactory<Program>().CreateDefaultClient(); | ||
string uri = "/200"; | ||
string headerName = "Foo"; | ||
string headerValue = "bar"; | ||
|
||
using HttpRequestMessage request = new(HttpMethod.Get, uri); | ||
request.Headers.Add($"{StatusController.CUSTOM_RESPONSE_HEADER_PREFIX}{headerName}", headerValue); | ||
request.Headers.Add($"{StatusExtensions.CUSTOM_RESPONSE_HEADER_PREFIX}{headerName}", headerValue); | ||
|
||
using var response = await _httpClient.SendAsync(request); | ||
using HttpResponseMessage response = await httpClient.SendAsync(request); | ||
|
||
var headers = response.Headers; | ||
Assert.That(headers.Contains(headerName), Is.True); | ||
Assert.That(headers.TryGetValues(headerName, out var values), Is.True); | ||
Assert.That(values, Is.Not.Null); | ||
Assert.That(values.Count(), Is.EqualTo(1)); | ||
Assert.That(values.First(), Is.EqualTo(headerValue)); | ||
System.Net.Http.Headers.HttpResponseHeaders headers = response.Headers; | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(headers.Contains(headerName), Is.True); | ||
Assert.That(headers.TryGetValues(headerName, out IEnumerable<string>? values), Is.True); | ||
Assert.That(values, Is.Not.Null); | ||
Assert.That(values!.Count(), Is.EqualTo(1)); | ||
Assert.That(values!.First(), Is.EqualTo(headerValue)); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.