aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-04-11 22:37:56 +0800
committercrupest <crupest@outlook.com>2022-04-11 22:37:56 +0800
commit65210138df643a475632690e2fb20401c1edbb95 (patch)
tree7e26e9d44dd2eae70d4f4baa4dbb8e3a13e4b938 /BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs
parentd4ccd980f6e3ae7ed7f1a8bedd5e3c10cf4df022 (diff)
downloadtimeline-65210138df643a475632690e2fb20401c1edbb95.tar.gz
timeline-65210138df643a475632690e2fb20401c1edbb95.tar.bz2
timeline-65210138df643a475632690e2fb20401c1edbb95.zip
...
Diffstat (limited to 'BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs')
-rw-r--r--BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs80
1 files changed, 77 insertions, 3 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs b/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs
index fbf7e2c8..169bc4e6 100644
--- a/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs
+++ b/BackEnd/Timeline.Tests/IntegratedTests2/TimelineBookmarkTest3.cs
@@ -2,6 +2,8 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
+using FluentAssertions;
+using Timeline.Models;
using Timeline.Models.Http;
using Xunit;
using Xunit.Abstractions;
@@ -58,7 +60,30 @@ namespace Timeline.Tests.IntegratedTests2
}
[Fact]
- public async Task DeleteNotExist()
+ public async Task MoveTest()
+ {
+ using var client = CreateClientAsUser();
+ var a = await client.TestJsonSendAsync<TimelineBookmark>(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello",
+ Position = 2
+ });
+ a.Position.Should().Be(2);
+
+ var b = await client.TestJsonSendAsync<TimelineBookmark>(HttpMethod.Get, "v2/users/user/bookmarks/2");
+ b.TimelineOwner.Should().Be("user");
+ b.TimelineName.Should().Be("hello");
+
+ await client.TestJsonSendAsync<TimelineBookmark>(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello",
+ }, expectedStatusCode: HttpStatusCode.UnprocessableEntity);
+ }
+
+ [Fact]
+ public async Task DeleteMoveNotExist()
{
using var client = CreateClientAsUser();
@@ -73,10 +98,25 @@ namespace Timeline.Tests.IntegratedTests2
TimelineOwner = "user",
TimelineName = "notexist"
}, expectedStatusCode: HttpStatusCode.UnprocessableEntity);
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "notexist",
+ TimelineName = "hello",
+ Position = 2
+
+ }, expectedStatusCode: HttpStatusCode.UnprocessableEntity);
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "notexist",
+ Position = 2
+ }, expectedStatusCode: HttpStatusCode.UnprocessableEntity);
}
[Fact]
- public async Task DeleteNotLogin()
+ public async Task DeleteMoveNotLogin()
{
using var client = CreateDefaultClient();
await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks/delete", new HttpTimelinebookmarkDeleteRequest
@@ -84,10 +124,17 @@ namespace Timeline.Tests.IntegratedTests2
TimelineOwner = "user",
TimelineName = "hello"
}, expectedStatusCode: HttpStatusCode.Unauthorized);
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello",
+ Position = 2
+ }, expectedStatusCode: HttpStatusCode.Unauthorized);
}
[Fact]
- public async Task DeleteForbid()
+ public async Task DeleteMoveForbid()
{
await CreateUserAsync("user2", "user2pw");
using var client = CreateClientWithToken(await CreateTokenWithCredentialAsync("user2", "user2pw"));
@@ -96,6 +143,13 @@ namespace Timeline.Tests.IntegratedTests2
TimelineOwner = "user",
TimelineName = "hello"
}, expectedStatusCode: HttpStatusCode.Forbidden);
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello",
+ Position = 2
+ }, expectedStatusCode: HttpStatusCode.Forbidden);
}
[Fact]
@@ -114,6 +168,26 @@ namespace Timeline.Tests.IntegratedTests2
TimelineName = "hello"
}, expectedStatusCode: HttpStatusCode.NotFound);
}
+
+ [Fact]
+ public async Task MoveAdmin()
+ {
+ using var client = CreateClientAsAdmin();
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/user/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello",
+ Position = 2
+ }, expectedStatusCode: HttpStatusCode.OK);
+
+ await client.TestJsonSendAsync(HttpMethod.Post, "v2/users/notexist/bookmarks/move", new HttpTimelineBookmarkMoveRequest
+ {
+ TimelineOwner = "user",
+ TimelineName = "hello",
+ Position = 2
+ }, expectedStatusCode: HttpStatusCode.NotFound);
+
+ }
}
}