blob: e6ae178f7f7708f0620c02b957d0070d61952443 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
using FluentAssertions;
using System.Collections.Generic;
using System.Threading.Tasks;
using Timeline.Models.Http;
using Xunit;
namespace Timeline.Tests.IntegratedTests
{
public class BookmarkTimelineTest : IntegratedTestBase
{
[Fact]
public async Task AuthTest()
{
using var client = await CreateDefaultClient();
await client.TestPutAssertUnauthorizedAsync("bookmarks/@user1");
await client.TestDeleteAssertUnauthorizedAsync("bookmarks/@user1");
await client.TestPostAssertUnauthorizedAsync("bookmarkop/move", new HttpBookmarkTimelineMoveRequest { Timeline = "aaa", NewPosition = 1 });
}
[Fact]
public async Task InvalidModel()
{
using var client = await CreateClientAsUser();
await client.TestPutAssertInvalidModelAsync("bookmarks/!!!");
await client.TestDeleteAssertInvalidModelAsync("bookmarks/!!!");
await client.TestPostAssertInvalidModelAsync("bookmarkop/move", new HttpBookmarkTimelineMoveRequest { Timeline = null!, NewPosition = 1 });
await client.TestPostAssertInvalidModelAsync("bookmarkop/move", new HttpBookmarkTimelineMoveRequest { Timeline = "!!!", NewPosition = 1 });
await client.TestPostAssertInvalidModelAsync("bookmarkop/move", new HttpBookmarkTimelineMoveRequest { Timeline = "aaa", NewPosition = null });
}
[Fact]
public async Task ShouldWork()
{
using var client = await CreateClientAsUser();
await client.TestPostAsync("timelines", new TimelineCreateRequest { Name = "t1" });
{
var h = await client.TestGetAsync<List<HttpTimeline>>("bookmarks");
h.Should().BeEmpty();
}
await client.TestPutAsync("bookmarks/@user1");
{
var h = await client.TestGetAsync<List<HttpTimeline>>("bookmarks");
h.Should().HaveCount(1);
h[0].Name.Should().Be("@user1");
}
await client.TestPutAsync("bookmarks/t1");
{
var h = await client.TestGetAsync<List<HttpTimeline>>("bookmarks");
h.Should().HaveCount(2);
h[0].Name.Should().Be("@user1");
h[1].Name.Should().Be("t1");
}
await client.TestPostAsync("bookmarkop/move", new HttpHighlightTimelineMoveRequest { Timeline = "@user1", NewPosition = 2 });
{
var h = await client.TestGetAsync<List<HttpTimeline>>("bookmarks");
h.Should().HaveCount(2);
h[0].Name.Should().Be("t1");
h[1].Name.Should().Be("@user1");
}
await client.TestDeleteAsync("bookmarks/@user1");
{
var h = await client.TestGetAsync<List<HttpTimeline>>("bookmarks");
h.Should().HaveCount(1);
h[0].Name.Should().Be("t1");
}
await client.TestDeleteAsync("bookmarks/t1");
{
var h = await client.TestGetAsync<List<HttpTimeline>>("bookmarks");
h.Should().BeEmpty();
}
}
}
}
|