diff options
author | crupest <crupest@outlook.com> | 2020-11-15 17:38:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-15 17:38:10 +0800 |
commit | fa7b123be84afe020fc582535cc270e8cf24e85b (patch) | |
tree | 58d88a6412f718c1d6b304d7ee9580eaf1ab6c3a /BackEnd/Timeline.Tests/Helpers/CacheTestHelper.cs | |
parent | 379b4bafe982a8a8cd3158f0a9fa38a563dbdb57 (diff) | |
parent | 9f9f02c94f1248ecf02860a6c90c2ee1e2992c46 (diff) | |
download | timeline-fa7b123be84afe020fc582535cc270e8cf24e85b.tar.gz timeline-fa7b123be84afe020fc582535cc270e8cf24e85b.tar.bz2 timeline-fa7b123be84afe020fc582535cc270e8cf24e85b.zip |
Merge pull request #186 from crupest/unittest
Refactor unit tests.
Diffstat (limited to 'BackEnd/Timeline.Tests/Helpers/CacheTestHelper.cs')
-rw-r--r-- | BackEnd/Timeline.Tests/Helpers/CacheTestHelper.cs | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/BackEnd/Timeline.Tests/Helpers/CacheTestHelper.cs b/BackEnd/Timeline.Tests/Helpers/CacheTestHelper.cs deleted file mode 100644 index b3709a28..00000000 --- a/BackEnd/Timeline.Tests/Helpers/CacheTestHelper.cs +++ /dev/null @@ -1,64 +0,0 @@ -using FluentAssertions;
-using System;
-using System.Net;
-using System.Net.Http;
-using System.Net.Http.Headers;
-using System.Threading.Tasks;
-using Timeline.Models.Http;
-
-namespace Timeline.Tests.Helpers
-{
- public static class CacheTestHelper
- {
- public static async Task TestCache(HttpClient client, string getUrl)
- {
- EntityTagHeaderValue eTag;
- {
- var res = await client.GetAsync(getUrl);
- res.Should().HaveStatusCode(200);
- var cacheControlHeader = res.Headers.CacheControl;
- cacheControlHeader.NoCache.Should().BeTrue();
- cacheControlHeader.NoStore.Should().BeFalse();
- cacheControlHeader.Private.Should().BeTrue();
- cacheControlHeader.Public.Should().BeFalse();
- cacheControlHeader.MustRevalidate.Should().BeTrue();
- cacheControlHeader.MaxAge.Should().NotBeNull().And.Be(TimeSpan.FromDays(14));
- eTag = res.Headers.ETag;
- }
-
- {
- using var request = new HttpRequestMessage()
- {
- RequestUri = new Uri(client.BaseAddress, getUrl),
- Method = HttpMethod.Get,
- };
- request.Headers.TryAddWithoutValidation("If-None-Match", "\"dsdfd");
- var res = await client.SendAsync(request);
- res.Should().HaveStatusCode(HttpStatusCode.BadRequest)
- .And.HaveCommonBody(ErrorCodes.Common.Header.IfNonMatch_BadFormat);
- }
-
- {
- using var request = new HttpRequestMessage()
- {
- RequestUri = new Uri(client.BaseAddress, getUrl),
- Method = HttpMethod.Get,
- };
- request.Headers.TryAddWithoutValidation("If-None-Match", "\"aaa\"");
- var res = await client.SendAsync(request);
- res.Should().HaveStatusCode(HttpStatusCode.OK);
- }
-
- {
- using var request = new HttpRequestMessage()
- {
- RequestUri = new Uri(client.BaseAddress, getUrl),
- Method = HttpMethod.Get,
- };
- request.Headers.Add("If-None-Match", eTag.ToString());
- var res = await client.SendAsync(request);
- res.Should().HaveStatusCode(HttpStatusCode.NotModified);
- }
- }
- }
-}
|