This repository was archived by the owner on Nov 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathClientFileTests.cs
More file actions
110 lines (90 loc) · 3.15 KB
/
Copy pathClientFileTests.cs
File metadata and controls
110 lines (90 loc) · 3.15 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
using System;
using System.Diagnostics;
using System.Net;
using System.Threading.Tasks;
using DropNetRT;
using DropNetRT.Exceptions;
using NUnit.Framework;
namespace DropNetRTTests
{
[TestFixture]
public class ClientFileTests
{
[SetUp]
public void Setup()
{
_client = new DropNetClient(AppKey, AppSecret, UserToken, UserSecret);
}
[Test]
public async Task Given_A_Root_Path_Get_Metadata()
{
var data = await _client.GetMetaData("/");
Assert.NotNull(data);
Assert.IsTrue(data.IsDirectory);
}
[Test]
public async Task Given_A_Folder_Path_Get_Metadata()
{
var data = await _client.GetMetaData("/photos");
Assert.NotNull(data);
Assert.IsTrue(data.IsDirectory, "Give path is not a directory");
bool nameMatches = string.Compare(data.Name, "photos", StringComparison.InvariantCultureIgnoreCase) == 0;
Assert.IsTrue(nameMatches);
}
[Test]
public async Task Given_A_File_Path_Get_Metadata()
{
var data = await _client.GetMetaData("/getting started.pdf");
Assert.NotNull(data);
Assert.IsFalse(data.IsDirectory, "Give path is not a file");
bool nameMatches = string.Compare(data.Name, "getting started.pdf", StringComparison.InvariantCultureIgnoreCase) == 0;
Assert.IsTrue(nameMatches);
}
[Test]
public async Task Given_A_Non_Existing_File_Path_Throws_DropNet_Exception_With_NotFound_Response()
{
try
{
await _client.GetMetaData("/DoesNotExist.pdf");
}
catch (DropboxException exception)
{
Assert.AreEqual(HttpStatusCode.NotFound, exception.StatusCode);
}
}
[Test]
public async Task Given_Path_Get_A_Share_Link()
{
var share = await _client.GetShare("/photos");
Assert.NotNull(share);
Assert.IsNotNull(share.Url);
Debug.WriteLine(share.Url);
}
[Test]
public async Task Given_Search_String_Find_The_Matching_Items()
{
var items = await _client.Search("pdf");
Assert.IsNotNull(items);
Assert.AreEqual(1, items.Count);
}
[Test]
public async Task Given_Search_String_If_No_Items_Found_Return_Empty_List()
{
var items = await _client.Search("Does not exist");
Assert.IsNotNull(items);
Assert.AreEqual(0, items.Count);
}
[Test]
public async Task Give_Search_String_And_Path_Find_The_Matching_Items()
{
var items = await _client.Search("jpg", "/photos");
Assert.IsNotNull(items);
Assert.AreEqual(3, items.Count);
}
private DropNetClient _client;
private const string UserSecret = "UserSecret";
private const string UserToken = "UserToken";
private const string AppKey = "AppKey";
private const string AppSecret = "AppSecret";
}
}