diff options
author | 杨宇千 <crupest@outlook.com> | 2019-11-20 18:21:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 18:21:17 +0800 |
commit | ae5bb5cbef2aec94673e26712d7937fca3996f5b (patch) | |
tree | 788b8acdf1141c757cb3226d3cd5f64594386b8f /Timeline.Tests/IntegratedTests/UserDetailTest.cs | |
parent | 37a2e6340ab20de1f9e847d795c0cbec9846de97 (diff) | |
parent | ca87f6781a5b0e80989a66be338a699846c40f8d (diff) | |
download | timeline-ae5bb5cbef2aec94673e26712d7937fca3996f5b.tar.gz timeline-ae5bb5cbef2aec94673e26712d7937fca3996f5b.tar.bz2 timeline-ae5bb5cbef2aec94673e26712d7937fca3996f5b.zip |
Merge pull request #54 from crupest/timeline
Add core feature Timeline (currently only personal timeline)
Diffstat (limited to 'Timeline.Tests/IntegratedTests/UserDetailTest.cs')
-rw-r--r-- | Timeline.Tests/IntegratedTests/UserDetailTest.cs | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/Timeline.Tests/IntegratedTests/UserDetailTest.cs b/Timeline.Tests/IntegratedTests/UserDetailTest.cs index 8f2b6925..932c287e 100644 --- a/Timeline.Tests/IntegratedTests/UserDetailTest.cs +++ b/Timeline.Tests/IntegratedTests/UserDetailTest.cs @@ -1,38 +1,27 @@ using FluentAssertions;
using Microsoft.AspNetCore.Mvc.Testing;
-using System;
using System.Net;
using System.Net.Http.Headers;
using System.Net.Mime;
using System.Threading.Tasks;
using Timeline.Tests.Helpers;
-using Timeline.Tests.Helpers.Authentication;
-using Timeline.Tests.Mock.Data;
using Xunit;
namespace Timeline.Tests.IntegratedTests
{
- public class UserDetailTest : IClassFixture<WebApplicationFactory<Startup>>, IDisposable
+ public class UserDetailTest : IntegratedTestBase
{
- private readonly TestApplication _testApp;
- private readonly WebApplicationFactory<Startup> _factory;
-
public UserDetailTest(WebApplicationFactory<Startup> factory)
+ : base(factory)
{
- _testApp = new TestApplication(factory);
- _factory = _testApp.Factory;
- }
- public void Dispose()
- {
- _testApp.Dispose();
}
[Fact]
public async Task PermissionTest()
{
{ // unauthorize
- using var client = _factory.CreateDefaultClient();
+ using var client = await CreateClientWithNoAuth();
{ // GET
var res = await client.GetAsync($"users/{MockUser.User.Username}/nickname");
res.Should().HaveStatusCode(HttpStatusCode.OK);
@@ -47,7 +36,7 @@ namespace Timeline.Tests.IntegratedTests }
}
{ // user
- using var client = await _factory.CreateClientAsUser();
+ using var client = await CreateClientAsUser();
{ // GET
var res = await client.GetAsync($"users/{MockUser.User.Username}/nickname");
res.Should().HaveStatusCode(HttpStatusCode.OK);
@@ -70,7 +59,7 @@ namespace Timeline.Tests.IntegratedTests }
}
{ // user
- using var client = await _factory.CreateClientAsAdmin();
+ using var client = await CreateClientAsAdmin();
{ // PUT other
var res = await client.PutStringAsync($"users/{MockUser.User.Username}/nickname", "aaa");
res.Should().HaveStatusCode(HttpStatusCode.OK);
@@ -88,7 +77,7 @@ namespace Timeline.Tests.IntegratedTests var url = $"users/{MockUser.User.Username}/nickname";
var userNotExistUrl = "users/usernotexist/nickname";
{
- using var client = await _factory.CreateClientAsUser();
+ using var client = await CreateClientAsUser();
{
var res = await client.GetAsync(userNotExistUrl);
res.Should().HaveStatusCode(HttpStatusCode.NotFound)
@@ -134,7 +123,7 @@ namespace Timeline.Tests.IntegratedTests }
}
{
- using var client = await _factory.CreateClientAsAdmin();
+ using var client = await CreateClientAsAdmin();
{
var res = await client.PutStringAsync(userNotExistUrl, "aaa");
res.Should().HaveStatusCode(HttpStatusCode.BadRequest)
|