@@ -10,6 +10,7 @@ namespace InfluxDB.Client.Test
1010 public class InfluxDBClientTest
1111 {
1212 const string dbName = "testDB" ;
13+ const string measurementName = "TestMeasurement" ;
1314 const string invalidDbName = "test DB" ;
1415 const string dbUName = "admin" ;
1516 const string dbpwd = "admin" ;
@@ -50,7 +51,7 @@ public async Task TestGetInfluxDBNamesAsync()
5051 {
5152 try
5253 {
53- //pass 8089, which is not influx port
54+
5455 var client = new InfluxDBClient ( influxUrl , dbUName , dbpwd ) ;
5556 var r = await client . GetInfluxDBNamesAsync ( ) ;
5657 Assert . IsTrue ( r != null && r . Count > 0 , "GetInfluxDBNamesAsync retunred null or empty collection" ) ;
@@ -69,7 +70,7 @@ public async Task TestGetInfluxDBStructureAsync_InvalidDB()
6970 {
7071 try
7172 {
72- //pass 8089, which is not influx port
73+
7374 var client = new InfluxDBClient ( influxUrl , dbUName , dbpwd ) ;
7475 var r = await client . GetInfluxDBStructureAsync ( "InvalidDB" ) ;
7576 Assert . IsTrue ( r != null && r . Count == 0 , "GetInfluxDBNamesAsync retunred null or non empty collection" ) ;
@@ -82,12 +83,20 @@ public async Task TestGetInfluxDBStructureAsync_InvalidDB()
8283 }
8384 }
8485
86+ [ TestMethod ]
87+ [ ExpectedException ( typeof ( ArgumentException ) ) ]
88+ public async Task TestCreateDatabaseAsync_InvalidName ( )
89+ {
90+ var client = new InfluxDBClient ( influxUrl , dbUName , dbpwd ) ;
91+ var r = await client . CreateDatabaseAsync ( invalidDbName ) ;
92+ }
93+
8594 [ TestMethod ]
8695 public async Task TestCreateDatabaseAsync ( )
8796 {
8897 try
8998 {
90- //pass 8089, which is not influx port
99+
91100 var client = new InfluxDBClient ( influxUrl , dbUName , dbpwd ) ;
92101 var r = await client . CreateDatabaseAsync ( dbName ) ;
93102 Assert . IsTrue ( r , "CreateDatabaseAsync retunred false" ) ;
@@ -105,13 +114,23 @@ public async Task TestCreateDatabaseAsync()
105114 }
106115 }
107116
108-
109117 [ TestMethod ]
110- [ ExpectedException ( typeof ( ArgumentException ) ) ]
111- public async Task TestCreateDatabaseAsync_InvalidName ( )
118+ public async Task TestPostValueAsync ( )
112119 {
113- var client = new InfluxDBClient ( influxUrl , dbUName , dbpwd ) ;
114- var r = await client . CreateDatabaseAsync ( invalidDbName ) ;
120+ try
121+ {
122+ var client = new InfluxDBClient ( influxUrl , dbUName , dbpwd ) ;
123+ var r = await client . PostValueAsync ( dbName , measurementName , DateTime . Now . ToEpoch ( TimePrecision . Seconds ) , TimePrecision . Seconds , "testTag=testTagValue" , "Temp" , 33.05 ) ;
124+ Assert . IsTrue ( r , "PostValueAsync retunred false" ) ;
125+ }
126+ catch ( Exception e )
127+ {
128+
129+ Assert . Fail ( "Unexpected exception of type {0} caught: {1}" ,
130+ e . GetType ( ) , e . Message ) ;
131+ return ;
132+ }
115133 }
134+
116135 }
117136}
0 commit comments