Skip to content

Commit b04b876

Browse files
committed
Initial commit
1 parent b01bd7e commit b04b876

File tree

11 files changed

+828
-0
lines changed

11 files changed

+828
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{C76424F8-1563-4699-9019-A36B74FA7FF5}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>InfluxDB.Client.Test</RootNamespace>
10+
<AssemblyName>InfluxDB.Client.Test</AssemblyName>
11+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
15+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
16+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
17+
<IsCodedUITest>False</IsCodedUITest>
18+
<TestProjectType>UnitTest</TestProjectType>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="System" />
39+
</ItemGroup>
40+
<Choose>
41+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
42+
<ItemGroup>
43+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
44+
</ItemGroup>
45+
</When>
46+
<Otherwise>
47+
<ItemGroup>
48+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
49+
</ItemGroup>
50+
</Otherwise>
51+
</Choose>
52+
<ItemGroup>
53+
<Compile Include="InfluxDBClientTest.cs" />
54+
<Compile Include="Properties\AssemblyInfo.cs" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<ProjectReference Include="..\AdysTech.InfluxDB.Client.Net\AdysTech.InfluxDB.Client.Net.csproj">
58+
<Project>{31c6d4d4-86a6-4e76-9e54-f4c399140ce7}</Project>
59+
<Name>AdysTech.InfluxDB.Client.Net</Name>
60+
</ProjectReference>
61+
</ItemGroup>
62+
<Choose>
63+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
64+
<ItemGroup>
65+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
66+
<Private>False</Private>
67+
</Reference>
68+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
69+
<Private>False</Private>
70+
</Reference>
71+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
72+
<Private>False</Private>
73+
</Reference>
74+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
75+
<Private>False</Private>
76+
</Reference>
77+
</ItemGroup>
78+
</When>
79+
</Choose>
80+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
81+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
82+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
83+
Other similar extension points exist, see Microsoft.Common.targets.
84+
<Target Name="BeforeBuild">
85+
</Target>
86+
<Target Name="AfterBuild">
87+
</Target>
88+
-->
89+
</Project>
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
using System;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
4+
using AdysTech.InfluxDB.Client.Net;
5+
using System.Threading.Tasks;
6+
7+
namespace InfluxDB.Client.Test
8+
{
9+
[TestClass]
10+
public class InfluxDBClientTest
11+
{
12+
const string dbName = "testDB";
13+
const string invalidDbName = "test DB";
14+
const string dbUName = "admin";
15+
const string dbpwd = "admin";
16+
const string invalidUName = "invalid";
17+
const string influxUrl = "http://localhost:8086";
18+
const string invalidInfluxUrl = "http://localhost:8089";
19+
20+
21+
[TestMethod]
22+
[ExpectedException (typeof (ServiceUnavailableException))]
23+
public async Task TestGetInfluxDBNamesAsync_ServiceUnavailable()
24+
{
25+
var client = new InfluxDBClient (invalidInfluxUrl);
26+
var r = await client.GetInfluxDBNamesAsync ();
27+
}
28+
29+
[TestMethod]
30+
[ExpectedException (typeof (UnauthorizedAccessException))]
31+
public async Task TestGetInfluxDBNamesAsync_Auth()
32+
{
33+
var client = new InfluxDBClient (influxUrl);
34+
var r = await client.GetInfluxDBNamesAsync ();
35+
}
36+
37+
38+
[TestMethod]
39+
[ExpectedException (typeof (UnauthorizedAccessException))]
40+
public async Task TestGetInfluxDBNamesAsync_Auth2()
41+
{
42+
var client = new InfluxDBClient (influxUrl, invalidUName, dbpwd);
43+
var r = await client.GetInfluxDBNamesAsync ();
44+
}
45+
46+
47+
48+
[TestMethod]
49+
public async Task TestGetInfluxDBNamesAsync()
50+
{
51+
try
52+
{
53+
//pass 8089, which is not influx port
54+
var client = new InfluxDBClient (influxUrl, dbUName, dbpwd);
55+
var r = await client.GetInfluxDBNamesAsync ();
56+
Assert.IsTrue (r != null && r.Count > 0, "GetInfluxDBNamesAsync retunred null or empty collection");
57+
}
58+
catch ( Exception e )
59+
{
60+
Assert.Fail ("Unexpected exception of type {0} caught: {1}",
61+
e.GetType (), e.Message);
62+
return;
63+
}
64+
}
65+
66+
67+
[TestMethod]
68+
public async Task TestGetInfluxDBStructureAsync_InvalidDB()
69+
{
70+
try
71+
{
72+
//pass 8089, which is not influx port
73+
var client = new InfluxDBClient (influxUrl, dbUName, dbpwd);
74+
var r = await client.GetInfluxDBStructureAsync ("InvalidDB");
75+
Assert.IsTrue (r != null && r.Count == 0, "GetInfluxDBNamesAsync retunred null or non empty collection");
76+
}
77+
catch ( Exception e )
78+
{
79+
Assert.Fail ("Unexpected exception of type {0} caught: {1}",
80+
e.GetType (), e.Message);
81+
return;
82+
}
83+
}
84+
85+
[TestMethod]
86+
public async Task TestCreateDatabaseAsync()
87+
{
88+
try
89+
{
90+
//pass 8089, which is not influx port
91+
var client = new InfluxDBClient (influxUrl, dbUName, dbpwd);
92+
var r = await client.CreateDatabaseAsync (dbName);
93+
Assert.IsTrue (r, "CreateDatabaseAsync retunred false");
94+
}
95+
catch ( InvalidOperationException e )
96+
{
97+
StringAssert.Equals (e.Message, "database already exists");
98+
}
99+
catch ( Exception e )
100+
{
101+
102+
Assert.Fail ("Unexpected exception of type {0} caught: {1}",
103+
e.GetType (), e.Message);
104+
return;
105+
}
106+
}
107+
108+
109+
[TestMethod]
110+
[ExpectedException (typeof (ArgumentException))]
111+
public async Task TestCreateDatabaseAsync_InvalidName()
112+
{
113+
var client = new InfluxDBClient (influxUrl, dbUName, dbpwd);
114+
var r = await client.CreateDatabaseAsync (invalidDbName);
115+
}
116+
}
117+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle ("InfluxDB.Client.Test")]
9+
[assembly: AssemblyDescription ("")]
10+
[assembly: AssemblyConfiguration ("")]
11+
[assembly: AssemblyCompany ("AdysTech")]
12+
[assembly: AssemblyProduct ("InfluxDB.Client.Test")]
13+
[assembly: AssemblyCopyright ("Copyright © AdysTech 2015")]
14+
[assembly: AssemblyTrademark ("")]
15+
[assembly: AssemblyCulture ("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible (false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid ("e5e80ee9-eb39-4b17-8225-82cb19b193e3")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion ("1.0.0.0")]
36+
[assembly: AssemblyFileVersion ("1.0.0.0")]
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{31C6D4D4-86A6-4E76-9E54-F4C399140CE7}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>AdysTech.InfluxDB.Client.Net</RootNamespace>
11+
<AssemblyName>AdysTech.InfluxDB.Client.Net</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="System" />
34+
<Reference Include="System.Core" />
35+
<Reference Include="System.Net.Http" />
36+
<Reference Include="System.Xml.Linq" />
37+
<Reference Include="System.Data.DataSetExtensions" />
38+
<Reference Include="Microsoft.CSharp" />
39+
<Reference Include="System.Data" />
40+
<Reference Include="System.Xml" />
41+
</ItemGroup>
42+
<ItemGroup>
43+
<Compile Include="IInfluxDBClient.cs" />
44+
<Compile Include="InfluxDBClient.cs" />
45+
<Compile Include="Properties\AssemblyInfo.cs" />
46+
<Compile Include="ServiceUnavailableException.cs" />
47+
</ItemGroup>
48+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
49+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
50+
Other similar extension points exist, see Microsoft.Common.targets.
51+
<Target Name="BeforeBuild">
52+
</Target>
53+
<Target Name="AfterBuild">
54+
</Target>
55+
-->
56+
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace AdysTech.InfluxDB.Client.Net
8+
{
9+
public interface IInfluxDBClient
10+
{
11+
Task<List<String>> GetInfluxDBNamesAsync();
12+
Task<Dictionary<string, List<String>>> GetInfluxDBStructureAsync(string dbName);
13+
Task<bool> CreateDatabaseAsync(string dbName);
14+
Task<bool> PostValueAsync(string dbName, string measurement, long timestamp, TimePrecision precision, string tags, string field, double value);
15+
Task<bool> PostValuesAsync(string dbName, string measurement, long timestamp, TimePrecision precision, string tags, IEnumerable<string> values);
16+
Task<bool> PostRawValueAsync(string dbName, TimePrecision precision, string content);
17+
}
18+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{C2924694-CFBE-4AE4-9385-2F1AB6FF1936}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>AdysTech.InfluxDB.Client</RootNamespace>
11+
<AssemblyName>AdysTech.InfluxDB.Client</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="System" />
34+
<Reference Include="System.Core" />
35+
<Reference Include="System.Net.Http" />
36+
<Reference Include="System.Xml.Linq" />
37+
<Reference Include="System.Data.DataSetExtensions" />
38+
<Reference Include="Microsoft.CSharp" />
39+
<Reference Include="System.Data" />
40+
<Reference Include="System.Xml" />
41+
</ItemGroup>
42+
<ItemGroup>
43+
<Compile Include="InfluxDBClient.cs" />
44+
<Compile Include="Properties\AssemblyInfo.cs" />
45+
</ItemGroup>
46+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
47+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
48+
Other similar extension points exist, see Microsoft.Common.targets.
49+
<Target Name="BeforeBuild">
50+
</Target>
51+
<Target Name="AfterBuild">
52+
</Target>
53+
-->
54+
</Project>

0 commit comments

Comments
 (0)