@@ -16,6 +16,8 @@ namespace Dropbox.Api.Tests
1616
1717 using Microsoft . VisualStudio . TestTools . UnitTesting ;
1818
19+ using Dropbox . Api . Auth ;
20+
1921 /// <summary>
2022 /// The test class for Dropbox API.
2123 /// </summary>
@@ -27,11 +29,29 @@ public class DropboxApiTests
2729 /// </summary>
2830 public static DropboxClient Client ;
2931
32+ /// <summary>
33+ /// The Dropbox team client.
34+ /// </summary>
35+ public static DropboxTeamClient TeamClient ;
36+
37+ /// <summary>
38+ /// The Dropbox app client.
39+ /// </summary>
40+ public static DropboxAppClient AppClient ;
41+
3042 [ ClassInitialize ]
3143 public static void Initialize ( TestContext context )
3244 {
33- var token = context . Properties [ "accessToken" ] . ToString ( ) ;
34- Client = new DropboxClient ( token ) ;
45+ var userToken = context . Properties [ "userAccessToken" ] . ToString ( ) ;
46+ Client = new DropboxClient ( userToken ) ;
47+
48+ var teamToken = context . Properties [ "teamAccessToken" ] . ToString ( ) ;
49+ TeamClient = new DropboxTeamClient ( teamToken ) ;
50+
51+ var appKey = context . Properties [ "appKey" ] . ToString ( ) ;
52+ var appSecret = context . Properties [ "appSecret" ] . ToString ( ) ;
53+
54+ AppClient = new DropboxAppClient ( appKey , appSecret ) ;
3555 }
3656
3757
@@ -174,6 +194,61 @@ public async Task TestRequestId()
174194 }
175195 }
176196
197+ /// Test team auth.
198+ /// </summary>
199+ /// <returns>The <see cref="Task"/></returns>
200+ [ TestMethod ]
201+ public async Task TestTeamAuth ( )
202+ {
203+ var result = await TeamClient . Team . GetInfoAsync ( ) ;
204+ Assert . IsNotNull ( result . TeamId ) ;
205+ Assert . IsNotNull ( result . Name ) ;
206+ }
207+
208+ /// Test team auth select user.
209+ /// </summary>
210+ /// <returns>The <see cref="Task"/></returns>
211+ [ TestMethod ]
212+ public async Task TestTeamAuthSelectUser ( )
213+ {
214+ var result = await TeamClient . Team . MembersListAsync ( ) ;
215+ var memberId = result . Members [ 0 ] . Profile . TeamMemberId ;
216+
217+ var userClient = TeamClient . AsMember ( memberId ) ;
218+ var account = await userClient . Users . GetCurrentAccountAsync ( ) ;
219+ Assert . AreEqual ( account . TeamMemberId , memberId ) ;
220+ }
221+
222+ /// Test app auth.
223+ /// </summary>
224+ /// <returns>The <see cref="Task"/></returns>
225+ [ TestMethod ]
226+ public async Task TestAppAuth ( )
227+ {
228+ try
229+ {
230+ var result = await AppClient . Auth . TokenFromOauth1Async ( "foo" , "bar" ) ;
231+ }
232+ catch ( ApiException < TokenFromOAuth1Error > )
233+ {
234+ }
235+ }
236+
237+ /// Test no auth.
238+ /// </summary>
239+ /// <returns>The <see cref="Task"/></returns>
240+ [ TestMethod ]
241+ public async Task TestNoAuth ( )
242+ {
243+ var result = await Client . Files . ListFolderAsync ( "" , recursive : true ) ;
244+ var cursor = result . Cursor ;
245+
246+ var task = Client . Files . ListFolderLongpollAsync ( cursor ) ;
247+ await Client . Files . UploadAsync ( "/foo.txt" , body : GetStream ( "abc" ) ) ;
248+ var response = await task ;
249+ Assert . IsTrue ( response . Changes ) ;
250+ }
251+
177252 /// <summary>
178253 /// Converts string to a memory stream.
179254 /// </summary>
0 commit comments