33using OsmSharp . API ;
44using OsmSharp . Changesets ;
55using OsmSharp . Tags ;
6- using System ;
76using System . IO ;
87using System . Linq ;
98using System . Net . Http ;
1211namespace OsmSharp . IO . API . Tests
1312{
1413 [ TestClass ]
15- [ Ignore ( "Should only be ran manually - comment-out for testing, do not check-in" ) ]
16- public class BasicAuthClientTests
14+ public class OAuth2ClientTests
1715 {
1816 private IAuthClient client ;
1917
@@ -26,7 +24,7 @@ public class BasicAuthClientTests
2624
2725 private static readonly TagsCollection ChangeSetTags = new TagsCollection ( )
2826 {
29- new Tag ( "comment" , "Running a functional test of an automated system ." ) ,
27+ new Tag ( "comment" , "Running a functional test of an automation tool ." ) ,
3028 new Tag ( "created_by" , "https://github.com/OsmSharp/osm-api-client/" ) ,
3129 new Tag ( "bot" , "yes" )
3230 } ;
@@ -37,13 +35,12 @@ public void TestInitialize()
3735 using var loggerFactory = LoggerFactory . Create ( b => b . AddConsole ( ) ) ;
3836 var logger = loggerFactory . CreateLogger ( "Tests" ) ;
3937 IClientsFactory clientFactory = new ClientsFactory ( logger , new HttpClient ( ) , ClientsFactory . DEVELOPMENT_URL ) ;
40- // Enter your user name and password here or OAuth credential below - do not check-in!
41- client = clientFactory . CreateBasicAuthClient ( "user-email" , "password" ) ;
42- //client = clientFactory.CreateOAuthClient("customerkey", "customerSecret", "token", "tokenSecret");
43- //client = clientFactory.CreateOAuth2Client("token");
38+ // Enter your OAuth2 credential below - do not check-in!
39+ client = clientFactory . CreateOAuth2Client ( "oAuth-token" ) ;
4440 }
4541
4642 [ TestMethod ]
43+ [ Ignore ( "Should only be ran manually - comment-out for testing, do not check-in" ) ]
4744 public async Task TestChangesetLifeCycle ( )
4845 {
4946 var user = await client . GetUserDetails ( ) ;
@@ -101,6 +98,7 @@ public async Task TestChangesetLifeCycle()
10198 }
10299
103100 [ TestMethod ]
101+ [ Ignore ( "Should only be ran manually - comment-out for testing, do not check-in" ) ]
104102 public async Task TestPreferences ( )
105103 {
106104 var preferences = await client . GetUserPreferences ( ) ;
@@ -122,6 +120,7 @@ public async Task TestPreferences()
122120 }
123121
124122 [ TestMethod ]
123+ [ Ignore ( "Should only be ran manually - comment-out for testing, do not check-in" ) ]
125124 public async Task TestNotes ( )
126125 {
127126 var permissions = await client . GetPermissions ( ) ;
@@ -162,6 +161,7 @@ public async Task TestNotes()
162161 }
163162
164163 [ TestMethod ]
164+ [ Ignore ( "Should only be ran manually - comment-out for testing, do not check-in" ) ]
165165 public async Task TestTraces ( )
166166 {
167167 using var gpxStream = File . Open ( "test.gpx" , FileMode . Open ) ;
@@ -171,6 +171,7 @@ public async Task TestTraces()
171171 NewGpx . Description += updatedText ;
172172 await client . UpdateTrace ( NewGpx ) ;
173173 var myTraces = await client . GetTraces ( ) ;
174+ var originalLength = myTraces . Length ;
174175 Assert . IsTrue ( myTraces ? . Length > 0 ) ;
175176 var gpxDetails = await client . GetTraceDetails ( NewGpx . Id ) ;
176177 Assert . IsNotNull ( gpxDetails ) ;
@@ -179,12 +180,9 @@ public async Task TestTraces()
179180 Assert . IsNotNull ( gpxStreamBack . Stream ) ;
180181 Assert . IsNotNull ( gpxStreamBack . FileName ) ;
181182 Assert . IsNotNull ( gpxStreamBack . ContentType ) ;
182- foreach ( var trace in myTraces )
183- {
184- await client . DeleteTrace ( trace . Id ) ;
185- }
183+ await client . DeleteTrace ( NewGpx . Id ) ;
186184 myTraces = await client . GetTraces ( ) ;
187- Assert . AreEqual ( 0 , myTraces ? . Length ) ;
185+ Assert . AreEqual ( originalLength - 1 , myTraces ? . Length ) ;
188186 }
189187 }
190188}
0 commit comments