forked from dillenmeister/Trello.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchTests.cs
171 lines (152 loc) · 6.31 KB
/
SearchTests.cs
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using System;
using System.Collections.Generic;
using System.Linq;
using ExpectedObjects;
using NUnit.Framework;
namespace TrelloNet.Tests
{
[TestFixture]
public class SearchTests : TrelloTestBase
{
[Test, Ignore("Search over actions is temporarily disabled and will return no results according to https://trello.com/docs/api/search/index.html")]
public void Search_WithTestQuery_ReturnsCorrectAction()
{
var expected = new List<Action>
{
new CommentCardAction
{
Id = "4f3f5d073cf351b24302417d",
IdMemberCreator = "4ece5a165237e5db06624a2a",
Date = DateTime.Parse("2012-02-18 08:10:47.335"),
Data = new CommentCardAction.ActionData
{
Board = new BoardName { Id = "4f2b8b4d4f2cb9d16d3684c9", Name = "Welcome Board" },
Card = new CardName { Id = "4f2b8b4d4f2cb9d16d3684e6", Name = "Welcome to Trello!" },
Text = "A test comment"
},
MemberCreator = new Action.ActionMember
{
FullName = "Oskar Dillén",
Username = "oskardillen",
Id = "4ece5a165237e5db06624a2a",
AvatarHash = "bb5dc0160e87c6573ef69c9d4a284bd2",
Initials = "OD"
}
}
}.ToExpectedObject();
var actual = _trelloReadOnly.Search("test").Actions;
expected.ShouldEqual(actual);
}
[Test]
public void Search_WithTestQuery_ReturnsCorrectBoard()
{
var expected = new Board
{
Closed = false,
Name = "Welcome Board",
Desc = "A test description",
IdOrganization = Constants.TestOrganizationId,
Pinned = true,
Url = "https://trello.com/b/J9JUdoYV/welcome-board",
Id = Constants.WelcomeBoardId,
Prefs = new BoardPreferences
{
Comments = CommentPermission.Members,
Invitations = InvitationPermission.Members,
PermissionLevel = PermissionLevel.Private,
Voting = VotingPermission.Members
},
LabelNames = new Dictionary<Color, string>
{
{ Color.Yellow, "" },
{ Color.Red, "" },
{ Color.Purple, "" },
{ Color.Orange, "" },
{ Color.Green, "label name" },
{ Color.Blue, "" },
}
}.ToExpectedObject();
var actual = _trelloReadOnly.Search("Welcome Board").Boards.First();
expected.ShouldEqual(actual);
}
[Test]
public void Search_WithTestQuery_ReturnsCorrectCard()
{
var expected = new Card
{
Id = Constants.WelcomeCardOfTheWelcomeBoardId,
Name = "Welcome to Trello!",
Desc = "",
Closed = false,
IdList = Constants.WelcomeBoardBasicsListId,
IdBoard = Constants.WelcomeBoardId,
Due = new DateTime(2015, 01, 01, 09, 00, 00),
Labels = new List<Card.Label>(),
IdShort = 1,
Url = "https://trello.com/c/pD2NljjG/1-welcome-to-trello",
ShortUrl = "https://trello.com/c/pD2NljjG",
Pos = 32768,
DateLastActivity = new DateTime(2012, 03, 24, 22, 48, 26, 596),
Badges = new Card.CardBadges
{
Votes = 1,
Attachments = 1,
Comments = 2,
CheckItems = 0,
CheckItemsChecked = 0,
Description = false,
Due = new DateTime(2015, 01, 01, 09, 00, 00),
FogBugz = ""
},
IdMembers = new List<string> { "4f2b8b464f2cb9d16d368326" }
}.ToExpectedObject();
var actual = _trelloReadOnly.Search("Welcome to Trello").Cards.First();
expected.ShouldEqual(actual);
}
[Test]
public void Search_WithTestQuery_ReturnsCorrectMember()
{
var expected = new
{
FullName = "Trello.NET Test User",
Bio = "Test bio",
Url = "https://trello.com/trellnettestuser",
Username = "trellnettestuser",
Id = Constants.MeId,
AvatarHash = "076e3caed758a1c18c91a0e9cae3368f",
Initials = "TU"
}.ToExpectedObject();
var actual = _trelloReadOnly.Search("Trello.NET Test User").Members.First();
expected.ShouldMatch(actual);
}
[Test]
public void Search_WithTestQueryButWithoutMemberModelType_ReturnsNoMembers()
{
var actual = _trelloReadOnly.Search("Trello.NET Test User", modelTypes: new[] { ModelType.Actions }).Members;
Assert.That(actual.Count(), Is.EqualTo(0));
}
[Test, Ignore("Search over actions is temporarily disabled and will return no results according to https://trello.com/docs/api/search/index.html")]
public void Search_WithActionsSince_ReturnsCorrectActions()
{
var shouldBeOneAction = _trelloReadOnly.Search("test", actionsSince: DateTime.Parse("2012-02-18")).Actions;
var shouldBeEmpty = _trelloReadOnly.Search("test", actionsSince: DateTime.Parse("2012-02-19")).Actions;
Assert.That(shouldBeOneAction.Count(), Is.EqualTo(1));
Assert.That(shouldBeEmpty.Count(), Is.EqualTo(0));
}
[Test, Ignore("Searching for organizations doesn't seem to work in Trello")]
public void Search_WithTestQuery_ReturnsCorrectOrganization()
{
var expected = new Organization
{
Id = "4f2b94c0c1c87fcb65422344",
DisplayName = "Trello.NET Test Organization",
Name = "trellnettestorganization",
Desc = "organization description",
Url = "https://trello.com/trellnettestorganization",
Website = "http://www.test.com"
}.ToExpectedObject();
var actual = _trelloReadOnly.Search("Trello.NET Test Organization").Organizations.First();
expected.ShouldEqual(actual);
}
}
}