blob: 499eabbe152dc28213ff76b668434e2a6b1e58ae (
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
|
using FluentAssertions;
using System.Collections.Generic;
using System.Threading.Tasks;
using Timeline.Models.Http;
using Xunit;
using Xunit.Abstractions;
namespace Timeline.Tests.IntegratedTests
{
public class SearchTest : IntegratedTestBase
{
public SearchTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
}
[Fact]
public async Task TimelineSearch_Should_Work()
{
var client = await CreateClientAsUser();
{
await client.TestPostAsync("timelines", new HttpTimelineCreateRequest { Name = "hahaha" });
await client.TestPostAsync("timelines", new HttpTimelineCreateRequest { Name = "bababa" });
await client.TestPatchAsync("timelines/bababa", new HttpTimelinePatchRequest { Title = "hahaha" });
await client.TestPostAsync("timelines", new HttpTimelineCreateRequest { Name = "gagaga" });
}
{
var res = await client.TestGetAsync<List<HttpTimeline>>("search/timelines?q=hah");
res.Should().HaveCount(2);
res[0].Name.Should().Be("hahaha");
res[1].Name.Should().Be("bababa");
}
{
var res = await client.TestGetAsync<List<HttpTimeline>>("search/timelines?q=wuhu");
res.Should().BeEmpty();
}
}
[Fact]
public async Task UserSearch_Should_Work()
{
var client = await CreateClientAsAdministrator();
{
await client.TestPostAsync("users", new HttpUserPostRequest { Username = "hahaha", Password = "p" });
await client.TestPostAsync("users", new HttpUserPostRequest { Username = "bababa", Password = "p" });
await client.TestPatchAsync("users/bababa", new HttpUserPatchRequest { Nickname = "hahaha" });
await client.TestPostAsync("users", new HttpUserPostRequest { Username = "gagaga", Password = "p" });
}
{
var res = await client.TestGetAsync<List<HttpUser>>("search/users?q=hah");
res.Should().HaveCount(2);
res[0].Username.Should().Be("hahaha");
res[1].Username.Should().Be("bababa");
}
{
var res = await client.TestGetAsync<List<HttpUser>>("search/users?q=wuhu");
res.Should().BeEmpty();
}
}
}
}
|