Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 70 additions & 30 deletions readme.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649;CS8632;NU1608;NU1109</NoWarn>
<Version>7.0.0</Version>
<Version>7.1.0</Version>
<LangVersion>preview</LangVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
<PackageTags>Http, Verify</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
httpCall: [
{
Request: https://fake/getOne,
Response: 200 Ok
},
{
Request: https://fake/getTwo,
Response: 200 Ok
}
]
}
37 changes: 26 additions & 11 deletions src/Tests/MockHttpClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public async Task DefaultContent()

#endregion

#region RecordedCalls
#region TrackedCalls

[Fact]
public async Task RecordedCalls()
public async Task TrackedCalls()
{
using var client = new MockHttpClient();

Expand Down Expand Up @@ -127,16 +127,15 @@ await Verify(new
[Fact]
public async Task ResponseBuilder()
{
using var client = new MockHttpClient(
request =>
using var client = new MockHttpClient(request =>
{
var content = $"Hello to {request.RequestUri}";
var response = new HttpResponseMessage(HttpStatusCode.OK)
{
var content = $"Hello to {request.RequestUri}";
var response = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(content),
};
return response;
});
Content = new StringContent(content),
};
return response;
});

var result1 = await client.GetAsync("https://fake/get1");
var result2 = await client.GetAsync("https://fake/get2");
Expand Down Expand Up @@ -288,4 +287,20 @@ await Verify(
})
.UniqueForRuntimeAndVersion();
}

#region RecordingMockInteractions

[Fact]
public async Task RecordingMockInteractions()
{
using var client = new MockHttpClient(recording: true);

Recording.Start();
await client.GetStringAsync("https://fake/getOne");
await client.GetStringAsync("https://fake/getTwo");

await Verify();
}

#endregion
}
1 change: 0 additions & 1 deletion src/Tests/Tests.HttpClientRecording.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization|Accept-Encoding,
Expand Down
1 change: 0 additions & 1 deletion src/Tests/Tests.HttpClientRecordingGlobal.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization|Accept-Encoding,
Expand Down
1 change: 0 additions & 1 deletion src/Tests/Tests.HttpResponse.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization,Accept-Encoding,
Expand Down
1 change: 0 additions & 1 deletion src/Tests/Tests.HttpResponseNested.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization,Accept-Encoding,
Expand Down
1 change: 0 additions & 1 deletion src/Tests/Tests.IgnoreAuth.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization,Accept-Encoding,
Expand Down
1 change: 0 additions & 1 deletion src/Tests/Tests.IgnoreHeader.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization,Accept-Encoding,
Expand Down
1 change: 0 additions & 1 deletion src/Tests/Tests.ImageHttpResponse.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization,Accept-Encoding,
Expand Down
2 changes: 0 additions & 2 deletions src/Tests/Tests.JsonGet.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
Headers: {
Access-Control-Allow-Origin: ,
Cache-Control: no-cache,
Content-Security-Policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com github.githubassets.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/,
Location: https://raw.githubusercontent.com/VerifyTests/Verify.Http/main/src/global.json,
Referrer-Policy: no-referrer-when-downgrade,
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload,
Expand Down Expand Up @@ -45,7 +44,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization,Accept-Encoding,
Expand Down
1 change: 0 additions & 1 deletion src/Tests/Tests.PauseResume.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization|Accept-Encoding,
Expand Down
1 change: 0 additions & 1 deletion src/Tests/Tests.RecordingFullControl.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization|Accept-Encoding,
Expand Down
1 change: 0 additions & 1 deletion src/Tests/Tests.ScrubHttpTextResponse.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization,Accept-Encoding,
Expand Down
4 changes: 0 additions & 4 deletions src/Tests/Tests.TestHttpRecording.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
Headers: {
Access-Control-Allow-Origin: ,
Cache-Control: no-cache,
Content-Security-Policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com github.githubassets.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/,
Location: https://raw.githubusercontent.com/VerifyTests/Verify.Http/main/src/global.json,
Referrer-Policy: no-referrer-when-downgrade,
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload,
Expand Down Expand Up @@ -42,7 +41,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization,Accept-Encoding,
Expand Down Expand Up @@ -74,7 +72,6 @@
Headers: {
Access-Control-Allow-Origin: ,
Cache-Control: no-cache,
Content-Security-Policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com github.githubassets.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/,
Location: https://raw.githubusercontent.com/VerifyTests/Verify.Http/main/src/appveyor.yml,
Referrer-Policy: no-referrer-when-downgrade,
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload,
Expand Down Expand Up @@ -102,7 +99,6 @@
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization,Accept-Encoding,
Expand Down
1 change: 0 additions & 1 deletion src/Tests/Tests.TestHttpRecordingWithResponse.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ SOFTWARE.
Access-Control-Allow-Origin: *,
Cache-Control: max-age=300,
Connection: keep-alive,
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox,
Cross-Origin-Resource-Policy: cross-origin,
Strict-Transport-Security: max-age=31536000,
Vary: Authorization,Accept-Encoding,
Expand Down
3 changes: 2 additions & 1 deletion src/Verify.Http/HttpRecording/HttpListener.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma warning disable CA1822
// ReSharper disable UnusedParameter.Global
#pragma warning disable CA1822
class HttpListener :
IObserver<DiagnosticListener>,
IDisposable
Expand Down
Loading