folder.cs
5.63 KB
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
172
173
174
175
176
177
178
179
180
using NUnit.Framework;
using System;
using System.IO;
namespace MonoTests.KnowledgeTree
{
[TestFixture]
public class FolderTest : KTTest
{
private int _folder_id;
private int _subfolder_id;
[SetUp]
public void SetUp()
{
}
[TearDown]
public void TearDown()
{
}
[Test]
public void GetFolderDetail()
{
kt_folder_detail response = this._kt.get_folder_detail(this._session, 1);
Assert.AreEqual(0, response.status_code);
Assert.AreEqual(1, response.id);
Assert.AreEqual("Root Folder", response.folder_name);
Assert.AreEqual(0, response.parent_id);
Assert.AreEqual("/", response.full_path);
}
[Test]
public void AddFolder()
{
kt_folder_detail response = this._kt.create_folder(this._session, 1, "kt_unit_test");
Assert.AreEqual(0,response.status_code);
this._folder_id = response.id;
response = this._kt.create_folder(this._session, this._folder_id, "subfolder");
Assert.AreEqual(0,response.status_code);
this._subfolder_id = response.id;
}
[Test]
public void GetFolderByName()
{
kt_folder_detail response = this._kt.get_folder_detail_by_name(this._session, "/kt_unit_test");
Assert.AreEqual(0,response.status_code);
Assert.AreEqual(this._folder_id, response.id);
response = this._kt.get_folder_detail_by_name(this._session, "kt_unit_test");
Assert.AreEqual(0,response.status_code);
Assert.AreEqual(this._folder_id, response.id);
response = this._kt.get_folder_detail_by_name(this._session, "kt_unit_test/subfolder");
Assert.AreEqual(0,response.status_code);
Assert.AreEqual(this._subfolder_id,response.id);
response = this._kt.get_folder_detail_by_name(this._session, "kt_unit_test/subfolder2");
Assert.IsFalse(response.status_code == 0);
}
[Test]
public void GetFolderContents()
{
kt_folder_contents response = this._kt.get_folder_contents(this._session, this._folder_id, 1, "DF");
Assert.AreEqual(0,response.status_code);
Assert.AreEqual(this._folder_id,response.folder_id);
Assert.AreEqual("kt_unit_test", response.folder_name);
Assert.AreEqual("kt_unit_test", response.full_path);
kt_folder_contents response2 = this._kt.get_folder_contents(this._session, this._subfolder_id, 1, "DF");
Assert.AreEqual(0, response2.status_code);
Assert.AreEqual(this._subfolder_id, response2.folder_id);
Assert.AreEqual("subfolder", response2.folder_name);
Assert.AreEqual("kt_unit_test/subfolder", response2.full_path);
}
[Test]
public void RenameFolder()
{
kt_response response = this._kt.rename_folder(this._session, this._subfolder_id, "subfolde'r2");
Assert.AreEqual(0, response.status_code);
kt_folder_detail response2 = this._kt.get_folder_detail(this._session, this._subfolder_id);
Assert.AreEqual(0, response2.status_code);
Assert.AreEqual(this._subfolder_id, response2.id);
Assert.AreEqual("subfolde-r2", response2.folder_name);
Assert.AreEqual(this._folder_id, response2.parent_id);
Assert.AreEqual("kt_unit_test/subfolde-r2", response2.full_path);
}
[Test]
public void RemoveFolder()
{
kt_response response = this._kt.delete_folder(this._session, this._folder_id, "unit testing remove");
Assert.AreEqual(0, response.status_code);
}
[Test]
public void AddFolderWithSpecialCharacters()
{
kt_folder_detail response = this._kt.create_folder(this._session, 1, "kt.unit.test");
Assert.AreEqual(0,response.status_code);
Assert.AreEqual("kt.unit.test",response.folder_name);
response = this._kt.create_folder(this._session, 1, "kt ' unit \" test");
Assert.AreEqual(0,response.status_code);
Assert.AreEqual("kt - unit - test",response.folder_name);
// this fails because the previous folder makes a folder with the same name because of invalid character substitution
response = this._kt.create_folder(this._session, 1, "kt - unit - test");
Assert.AreEqual(22,response.status_code);
// Assert.AreEqual("kt - unit - test",response.folder_name);
response = this._kt.get_folder_detail_by_name(this._session, "/kt ' unit \" test");
Assert.AreEqual(0,response.status_code);
Assert.AreEqual("kt - unit - test",response.folder_name);
}
[Test]
public void CopyFolder()
{
kt_folder_detail response = this._kt.create_folder(this._session, 1, "kt_unit_test2");
Assert.AreEqual(0,response.status_code);
this._folder_id = response.id;
response = this._kt.create_folder(this._session, 1, "subfolder");
Assert.AreEqual(0,response.status_code);
this._subfolder_id = response.id;
response = this._kt.copy_folder(this._session, this._folder_id, this._subfolder_id, "copy reason");
Assert.AreEqual(0,response.status_code);
Assert.AreEqual(this._subfolder_id,response.parent_id);
Assert.AreEqual("kt_unit_test2",response.folder_name);
}
[Test]
public void MoveFolder()
{
kt_folder_detail response = this._kt.create_folder(this._session, 1, "kt_unit_test3");
Assert.AreEqual(0,response.status_code);
this._folder_id = response.id;
response = this._kt.create_folder(this._session, 1, "subfolder3");
Assert.AreEqual(0,response.status_code);
this._subfolder_id = response.id;
response = this._kt.move_folder(this._session, this._folder_id, this._subfolder_id, "move reason");
Assert.AreEqual(0,response.status_code);
Assert.AreEqual(this._folder_id,response.id);
Assert.AreEqual(this._subfolder_id,response.parent_id);
Assert.AreEqual("kt_unit_test3",response.folder_name);
}
}
}