Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update unit test framework to NUnit #6

Merged
merged 13 commits into from

2 participants

@myagley
Owner

Updating to NUnit was required to get the client to build and test under mono.

@maddenpj maddenpj commented on the diff
Client/TempoClient.csproj
@@ -37,7 +37,7 @@
<HintPath>..\packages\Newtonsoft.Json.4.5.7\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
- <HintPath>..\packages\RestSharp.103.1\lib\net4\RestSharp.dll</HintPath>
+ <HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath>

We should remember to indicate the rest sharp version bump when we deploy the package to nuget. Nuget page still shows 103

@myagley Owner
myagley added a note

Yeah, I had to do that because the client and tests were using different versions of RestSharp and it wouldn't compile in mono. I could downgrade to 103.1 for the tests.

Was the client using 103 or 104? We might as well bump it up

@myagley Owner
myagley added a note

Yeah, it was using 103, the tests were on 104.

Let's bump it up and see if anything breaks, I don't think 103 -> 104 is a breaking change

@myagley Owner
myagley added a note

Ok, we can handle it when the release is cut.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@maddenpj maddenpj merged commit fbfe1bb into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  .gitignore
@@ -5,7 +5,7 @@ packages
_Resharper*
# mstest test results
-TestResults
+TestResult*
# files
*.suo
View
BIN  .nuget/NuGet.exe
Binary file not shown
View
8 .nuget/NuGet.targets
@@ -30,14 +30,14 @@
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
- <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
+ <NuGetToolsPath>$(MSBuildThisFileDirectory)</NuGetToolsPath>
<PackagesConfig>packages.config</PackagesConfig>
- <PackagesDir>$(SolutionDir)packages</PackagesDir>
+ <PackagesDir>$(MSBuildThisFileDirectory)..\packages</PackagesDir>
</PropertyGroup>
<PropertyGroup>
<!-- NuGet command -->
- <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\nuget.exe</NuGetExePath>
+ <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)NuGet.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
@@ -136,4 +136,4 @@
</Code>
</Task>
</UsingTask>
-</Project>
+</Project>
View
11 .travis.yml
@@ -0,0 +1,11 @@
+language: c
+
+install:
+ - ./scripts/install-mono.sh
+
+script:
+ - sudo apt-get install cmake mono-devel mono-gmcs
+
+notifications:
+ email:
+ - tech@tempo-db.com
View
19 Client.Tests/Client.Tests.csproj
@@ -33,18 +33,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Gallio, Version=3.3.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL">
- <HintPath>..\packages\mbunit.3.3.454.0\lib\net40\Gallio.dll</HintPath>
- </Reference>
- <Reference Include="Gallio40, Version=3.3.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL">
- <HintPath>..\packages\mbunit.3.3.454.0\lib\net40\Gallio40.dll</HintPath>
- </Reference>
- <Reference Include="MbUnit, Version=3.3.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL">
- <HintPath>..\packages\mbunit.3.3.454.0\lib\net40\MbUnit.dll</HintPath>
- </Reference>
- <Reference Include="MbUnit40, Version=3.3.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL">
- <HintPath>..\packages\mbunit.3.3.454.0\lib\net40\MbUnit40.dll</HintPath>
- </Reference>
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
@@ -52,6 +40,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath>
</Reference>
+ <Reference Include="NUnit.Framework">
+ <HintPath>..\packages\NUnit.2.6.1\lib\nunit.framework.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -83,7 +74,7 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+ <Import Project="$(SolutionDir).nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
@@ -91,4 +82,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
View
11 Client.Tests/DataPointModelTests.cs
@@ -1,9 +1,10 @@
-using System;
+using Client.Model;
+using NUnit.Framework;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Client.Model;
-using MbUnit.Framework;
+
namespace Client.Tests
{
@@ -41,10 +42,10 @@ public void Unequality_Value()
public void Unequality_Null()
{
var dp1 = new DataPoint(new DateTime(2012, 1, 1, 0, 0, 1), 12.34);
-
+
Assert.AreNotEqual(dp1, null);
}
-
+
[Test]
public void Equality_Null()
{
View
25 Client.Tests/DeleteTests.cs
@@ -1,12 +1,13 @@
-using System;
+using Client.Model;
+using Moq;
+using NUnit.Framework;
+using RestSharp;
+using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using Client.Model;
-using MbUnit.Framework;
-using RestSharp;
using System.Linq.Expressions;
-using Moq;
+using System.Text;
+
namespace Client.Tests
{
@@ -19,13 +20,12 @@ public void SmokeTest()
var mockclient = TestCommon.GetMockRestClient();
var client = TestCommon.GetClient(mockclient.Object);
-
client.DeleteById("series-id", new DateTime(2012, 1, 1), new DateTime(2012, 1, 1, 1, 0, 0));
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => req.Method == Method.DELETE)));
- mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => req.Resource == "/series/{property}/{value}/data")));
- mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "start", "2012-01-01T00:00:00.000-08:00"))));
- mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "end", "2012-01-01T01:00:00.000-08:00"))));
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => req.Resource == "/series/{property}/{value}/data")));
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "start", "2012-01-01T00:00:00.000-06:00"))));
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "end", "2012-01-01T01:00:00.000-06:00"))));
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "property", "id"))));
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "value", "series-id"))));
}
@@ -36,13 +36,12 @@ public void Key()
var mockclient = TestCommon.GetMockRestClient();
var client = TestCommon.GetClient(mockclient.Object);
-
client.DeleteByKey("series-key", new DateTime(2012, 1, 1), new DateTime(2012, 1, 1, 1, 0, 0));
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => req.Method == Method.DELETE)));
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => req.Resource == "/series/{property}/{value}/data")));
- mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "start", "2012-01-01T00:00:00.000-08:00"))));
- mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "end", "2012-01-01T01:00:00.000-08:00"))));
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "start", "2012-01-01T00:00:00.000-06:00"))));
+ mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "end", "2012-01-01T01:00:00.000-06:00"))));
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "property", "key"))));
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "value", "series-key"))));
}
View
13 Client.Tests/IncrementTests.cs
@@ -1,10 +1,11 @@
-using System;
-using System.Collections.Generic;
-using Client.Model;
-using MbUnit.Framework;
+using Client.Model;
+using Moq;
+using NUnit.Framework;
using RestSharp;
+using System;
+using System.Collections.Generic;
using System.Linq.Expressions;
-using Moq;
+
namespace Client.Tests
{
@@ -66,4 +67,4 @@ public void RequestCount()
mockClient.Verify(cl => cl.Execute(It.IsAny<RestRequest>()), Times.Exactly(100));
}
}
-}
+}
View
35 Client.Tests/JsonDeserializationTests.cs
@@ -1,11 +1,12 @@
-using System;
+using Client.Model;
+using Moq;
+using NUnit.Framework;
+using RestSharp;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Client.Model;
-using MbUnit.Framework;
-using Moq;
-using RestSharp;
+
namespace Client.Tests
{
@@ -22,11 +23,11 @@ public void SmokeTest()
{
var jsonResponse = new RestResponse
{
- Content = "{\"t\":\"2012-01-01T00:00:01.000-08:00\",\"v\":12.34}"
+ Content = "{\"t\":\"2012-01-01T00:00:01.000+00:00\",\"v\":12.34}"
};
var result = JsonDeserializationTests.deserializer.Deserialize<DataPoint>(jsonResponse);
- Assert.AreEqual(new DataPoint(new DateTime(2012, 1, 1, 0, 0, 1, DateTimeKind.Local), 12.34), result);
+ Assert.AreEqual(new DataPoint(new DateTime(2012, 1, 1, 0, 0, 1).ToLocalTime(), 12.34), result);
}
[Test]
@@ -34,11 +35,11 @@ public void Long()
{
var jsonResponse = new RestResponse
{
- Content = "{\"t\":\"2012-01-01T00:00:01.000-08:00\",\"v\":1234}"
+ Content = "{\"t\":\"2012-01-01T00:00:01.000+00:00\",\"v\":1234}"
};
var result = JsonDeserializationTests.deserializer.Deserialize<DataPoint>(jsonResponse);
- Assert.AreEqual(new DataPoint(new DateTime(2012, 1, 1, 0, 0, 1, DateTimeKind.Local), 1234.0), result);
+ Assert.AreEqual(new DataPoint(new DateTime(2012, 1, 1, 0, 0, 1).ToLocalTime(), 1234.0), result);
}
}
@@ -59,9 +60,6 @@ public void SmokeTest()
};
var result = JsonDeserializationTests.deserializer.Deserialize<Series>(jsonResponse);
- Console.WriteLine(series.Name == null);
- Console.WriteLine(series.Tags == null);
- Console.WriteLine(result.Tags == null);
Assert.AreEqual(series, result);
}
@@ -72,7 +70,7 @@ public void Name()
{
Content = "{\"id\":\"series-id\",\"key\":\"series-key\",\"name\":\"series-name\",\"attributes\":{},\"tags\":[]}"
};
-
+
var result = JsonDeserializationTests.deserializer.Deserialize<Series>(jsonResponse);
Assert.AreEqual("series-name", result.Name);
}
@@ -84,8 +82,8 @@ public void Tags()
{
Content = "{\"id\":\"series-id\",\"key\":\"series-key\",\"name\":\"\",\"attributes\":{},\"tags\":[\"tag1\",\"tag2\"]}"
};
-
- var result = JsonDeserializationTests.deserializer.Deserialize<Series>(jsonResponse);
+
+ var result = JsonDeserializationTests.deserializer.Deserialize<Series>(jsonResponse);
Assert.AreEqual(2, result.Tags.Count);
Assert.AreEqual("tag1", result.Tags[0]);
Assert.AreEqual("tag2", result.Tags[1]);
@@ -98,7 +96,7 @@ public void Attributes()
{
Content = "{\"id\":\"series-id\",\"key\":\"series-key\",\"name\":\"\",\"attributes\":{\"key1\":\"val1\",\"key2\":\"val2\"},\"tags\":[]}"
};
-
+
var result = JsonDeserializationTests.deserializer.Deserialize<Series>(jsonResponse);
Assert.AreEqual(2, result.Attributes.Count);
Assert.AreEqual("val1", result.Attributes["key1"]);
@@ -172,12 +170,7 @@ public void EmptySummary()
var result = JsonDeserializationTests.deserializer.Deserialize<DataSet>(jsonResponse);
Assert.AreEqual(0, result.Summary.Count);
-
-
}
}
}
-
-
-
}
View
17 Client.Tests/JsonSerializationTests.cs
@@ -1,11 +1,12 @@
-using System;
+using Client.Model;
+using Moq;
+using NUnit.Framework;
+using RestSharp;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Client.Model;
-using MbUnit.Framework;
-using Moq;
-using RestSharp;
+
namespace Client.Tests
{
@@ -22,7 +23,7 @@ public void SmokeTest()
{
var dp = new DataPoint(new DateTime(2012, 1, 1, 0, 0, 1), 12.34);
var result = JsonSerializationTests.serializer.Serialize(dp);
- Assert.AreEqual("{\"t\":\"2012-01-01T00:00:01.000-08:00\",\"v\":12.34}", result);
+ Assert.AreEqual("{\"t\":\"2012-01-01T00:00:01.000-06:00\",\"v\":12.34}", result);
}
[Test]
@@ -31,7 +32,7 @@ public void EmptyValue()
var dp = new DataPoint();
var result = JsonSerializationTests.serializer.Serialize(dp);
- Assert.Contains(result, ":0.0");
+ StringAssert.Contains(":0.0", result);
}
}
@@ -135,7 +136,7 @@ public void SmokeTest()
var bds = new BulkDataSet(new DateTime(2012, 1, 1), data);
var result = JsonSerializationTests.serializer.Serialize(bds);
- Assert.AreEqual("{\"t\":\"2012-01-01T00:00:00.000-08:00\",\"data\":[{\"id\":\"id1\",\"v\":12.34},{\"key\":\"mykey\",\"v\":56.78},{\"id\":\"id2\",\"v\":90.12}]}", result);
+ Assert.AreEqual("{\"t\":\"2012-01-01T00:00:00.000-06:00\",\"data\":[{\"id\":\"id1\",\"v\":12.34},{\"key\":\"mykey\",\"v\":56.78},{\"id\":\"id2\",\"v\":90.12}]}", result);
}
}
}
View
52 Client.Tests/ReadTests.cs
@@ -1,16 +1,17 @@
-using System;
-using System.Collections.Generic;
-using System.Linq.Expressions;
-using Client.Model;
-using MbUnit.Framework;
+using Client.Model;
using Moq;
+using NUnit.Framework;
using RestSharp;
+using System;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+
namespace Client.Tests
{
- [TestFixture]
- public class ReadTests
- {
+ [TestFixture]
+ public class ReadTests
+ {
[TestFixture]
class SingleRead
{
@@ -40,7 +41,7 @@ public void RequestMethod()
var mockclient = TestCommon.GetMockRestClient<DataSet>(new DataSet());
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.ReadByKey("testkey", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Raw());
+ client.ReadByKey("testkey", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Raw());
Expression<Func<RestRequest, bool>> assertion = req => req.Method == Method.GET;
mockclient.Verify(cl => cl.Execute<DataSet>(It.Is<RestRequest>(assertion)));
@@ -51,10 +52,12 @@ public void RequestStartTime()
{
var mockclient = TestCommon.GetMockRestClient<DataSet>(new DataSet());
var client = TestCommon.GetClient(mockclient.Object);
+ var start = new DateTime(2012, 6, 23);
+ var end = new DateTime(2012, 6, 24);
- var results = client.ReadByKey("testkey", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Raw());
+ client.ReadByKey("testkey", start, end, IntervalParameter.Raw());
- Expression<Func<RestRequest, bool>> assertion = req => TestCommon.ContainsParameter(req.Parameters, "start", "2012-06-23T00:00:00.000-07:00");
+ Expression<Func<RestRequest, bool>> assertion = req => TestCommon.ContainsParameter(req.Parameters, "start", "2012-06-23T00:00:00.000-05:00");
mockclient.Verify(cl => cl.Execute<DataSet>(It.Is<RestRequest>(assertion)));
}
@@ -63,10 +66,12 @@ public void RequestEndTime()
{
var mockclient = TestCommon.GetMockRestClient<DataSet>(new DataSet());
var client = TestCommon.GetClient(mockclient.Object);
+ var start = new DateTime(2012, 6, 23);
+ var end = new DateTime(2012, 6, 24);
- var results = client.ReadByKey("testkey", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Raw());
+ client.ReadByKey("testkey", start, end, IntervalParameter.Raw());
- Expression<Func<RestRequest, bool>> assertion = req => TestCommon.ContainsParameter(req.Parameters, "end", "2012-06-24T00:00:00.000-07:00");
+ Expression<Func<RestRequest, bool>> assertion = req => TestCommon.ContainsParameter(req.Parameters, "end", "2012-06-24T00:00:00.000-05:00");
mockclient.Verify(cl => cl.Execute<DataSet>(It.Is<RestRequest>(assertion)));
}
@@ -76,12 +81,11 @@ public void RequestUrl()
var mockclient = TestCommon.GetMockRestClient<DataSet>(new DataSet());
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.ReadByKey("testkey", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Raw());
+ client.ReadByKey("testkey", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Raw());
mockclient.Verify(cl => cl.Execute<DataSet>(It.Is<RestRequest>(req => req.Resource == "/series/{property}/{value}/data")));
mockclient.Verify(cl => cl.Execute<DataSet>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "property", "key"))));
mockclient.Verify(cl => cl.Execute<DataSet>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "value", "testkey"))));
-
}
[Test]
@@ -90,7 +94,7 @@ public void RequestInterval()
var mockclient = TestCommon.GetMockRestClient<DataSet>(new DataSet());
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.ReadByKey("testkey", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Raw());
+ client.ReadByKey("testkey", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Raw());
Expression<Func<RestRequest, bool>> assertion = req => TestCommon.ContainsParameter(req.Parameters, "interval", "raw");
mockclient.Verify(cl => cl.Execute<DataSet>(It.Is<RestRequest>(assertion)));
@@ -102,7 +106,7 @@ public void RequestMethod_Id()
var mockclient = TestCommon.GetMockRestClient<DataSet>(new DataSet());
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.ReadById("testid", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Raw());
+ client.ReadById("testid", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Raw());
mockclient.Verify(cl => cl.Execute<DataSet>(It.Is<RestRequest>(req => req.Resource == "/series/{property}/{value}/data")));
mockclient.Verify(cl => cl.Execute<DataSet>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "property", "id"))));
@@ -115,7 +119,7 @@ public void RequestInterval1Hour()
var mockclient = TestCommon.GetMockRestClient<DataSet>(new DataSet());
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.ReadByKey("testkey", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Hours(1));
+ client.ReadByKey("testkey", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Hours(1));
Expression<Func<RestRequest, bool>> assertion = req => TestCommon.ContainsParameter(req.Parameters, "interval", "1hour");
mockclient.Verify(cl => cl.Execute<DataSet>(It.Is<RestRequest>(assertion)));
@@ -127,7 +131,7 @@ public void RequestFunction()
var mockclient = TestCommon.GetMockRestClient<DataSet>(new DataSet());
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.ReadByKey("testkey", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Hours(1), FoldingFunction.Sum);
+ client.ReadByKey("testkey", new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), IntervalParameter.Hours(1), FoldingFunction.Sum);
Expression<Func<RestRequest, bool>> assertion = req => TestCommon.ContainsParameter(req.Parameters, "function", "sum");
mockclient.Verify(cl => cl.Execute<DataSet>(It.Is<RestRequest>(assertion)));
@@ -141,10 +145,10 @@ class MultipleReads
[Test]
public void SmokeTest()
{
- List<DataSet> ret = new List<DataSet> {
+ List<DataSet> ret = new List<DataSet> {
new DataSet
{
- Series = new Series { Key = "series1" }
+ Series = new Series { Key = "series1" }
},
new DataSet
{
@@ -172,7 +176,7 @@ public void RequestUrl()
var filter = new Filter();
filter.AddKey("series1");
filter.AddKey("series2");
- var results = client.ReadMultipleSeries(new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), filter, IntervalParameter.Raw());
+ client.ReadMultipleSeries(new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), filter, IntervalParameter.Raw());
Expression<Func<RestRequest, bool>> assertion = req => req.Resource == "/data/";
mockclient.Verify(cl => cl.Execute<List<DataSet>>(It.Is<RestRequest>(assertion)));
@@ -188,11 +192,11 @@ public void RequestFilter()
var filter = new Filter();
filter.AddKey("series1");
filter.AddKey("series2");
- var results = client.ReadMultipleSeries(new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), filter, IntervalParameter.Raw());
+ client.ReadMultipleSeries(new DateTime(2012, 06, 23), new DateTime(2012, 06, 24), filter, IntervalParameter.Raw());
mockclient.Verify(cl => cl.Execute<List<DataSet>>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "key", "series1"))));
mockclient.Verify(cl => cl.Execute<List<DataSet>>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "key", "series2"))));
}
}
}
-}
+}
View
9 Client.Tests/SeriesModelTests.cs
@@ -1,9 +1,10 @@
-using System;
+using Client.Model;
+using NUnit.Framework;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Client.Model;
-using MbUnit.Framework;
+
namespace Client.Tests
{
@@ -62,7 +63,7 @@ public void Unequality_Id()
Assert.AreNotEqual(s1, s2);
}
-
+
[Test]
public void Unequality_Key()
{
View
45 Client.Tests/SeriesTests.cs
@@ -1,9 +1,10 @@
-using System;
-using System.Collections.Generic;
-using Client.Model;
-using MbUnit.Framework;
+using Client.Model;
using Moq;
+using NUnit.Framework;
using RestSharp;
+using System;
+using System.Collections.Generic;
+
namespace Client.Tests
{
@@ -54,7 +55,7 @@ public void RequestMethod()
var mockclient = TestCommon.GetMockRestClient<Series>(series);
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.CreateSeries("series-key");
+ client.CreateSeries("series-key");
mockclient.Verify(cl => cl.Execute<Series>(It.Is<RestRequest>(req => req.Method == Method.POST)));
}
@@ -70,7 +71,7 @@ public void RequestUrl()
var mockclient = TestCommon.GetMockRestClient<Series>(series);
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.CreateSeries("series-key");
+ client.CreateSeries("series-key");
mockclient.Verify(cl => cl.Execute<Series>(It.Is<RestRequest>(req => req.Resource == "/series/")));
}
@@ -86,11 +87,10 @@ public void RequestParameters()
var mockclient = TestCommon.GetMockRestClient<Series>(series);
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.CreateSeries("series-key");
-
+ client.CreateSeries("series-key");
+
mockclient.Verify(cl => cl.Execute<Series>(It.Is<RestRequest>(req => TestCommon.ContainsParameterByPattern(req.Parameters, "application/json", "series-key"))));
}
-
}
[TestFixture]
@@ -121,7 +121,7 @@ public void RequestMethod()
var mockclient = TestCommon.GetMockRestClient<Series>(series);
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.GetSeriesById("series-id");
+ client.GetSeriesById("series-id");
mockclient.Verify(cl => cl.Execute<Series>(It.Is<RestRequest>(req => req.Method == Method.GET)));
}
@@ -136,7 +136,7 @@ public void RequestUrl()
var mockclient = TestCommon.GetMockRestClient<Series>(series);
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.GetSeriesById("series-id");
+ client.GetSeriesById("series-id");
mockclient.Verify(cl => cl.Execute<Series>(It.Is<RestRequest>(req => req.Resource == "/series/id/{id}")));
}
@@ -151,7 +151,7 @@ public void RequestParameters()
var mockclient = TestCommon.GetMockRestClient<Series>(series);
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.GetSeriesById("series-id");
+ client.GetSeriesById("series-id");
mockclient.Verify(cl => cl.Execute<Series>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "id", "series-id"))));
}
@@ -181,7 +181,7 @@ public void KeyRequestMethod()
var mockclient = TestCommon.GetMockRestClient<Series>(series);
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.GetSeriesByKey("series-key");
+ client.GetSeriesByKey("series-key");
mockclient.Verify(cl => cl.Execute<Series>(It.Is<RestRequest>(req => req.Method == Method.GET)));
}
@@ -196,7 +196,7 @@ public void KeyRequestUrl()
var mockclient = TestCommon.GetMockRestClient<Series>(series);
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.GetSeriesByKey("series-key");
+ client.GetSeriesByKey("series-key");
mockclient.Verify(cl => cl.Execute<Series>(It.Is<RestRequest>(req => req.Resource == "/series/key/{key}")));
}
@@ -211,11 +211,10 @@ public void KeyRequestParameters()
var mockclient = TestCommon.GetMockRestClient<Series>(series);
var client = TestCommon.GetClient(mockclient.Object);
- var results = client.GetSeriesByKey("series-key");
+ client.GetSeriesByKey("series-key");
mockclient.Verify(cl => cl.Execute<Series>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "key", "series-key"))));
}
-
}
@@ -248,7 +247,7 @@ public void RequestMethod()
var mockclient = TestCommon.GetMockRestClient<List<Series>>(new List<Series> { series });
var client = TestCommon.GetClient(mockclient.Object);
- var result = client.ListSeries();
+ client.ListSeries();
mockclient.Verify(cl => cl.Execute<List<Series>>(It.Is<RestRequest>(req => req.Method == Method.GET)));
}
@@ -263,7 +262,7 @@ public void RequestUrl()
var mockclient = TestCommon.GetMockRestClient<List<Series>>(new List<Series> { series });
var client = TestCommon.GetClient(mockclient.Object);
- var result = client.ListSeries();
+ client.ListSeries();
mockclient.Verify(cl => cl.Execute<List<Series>>(It.Is<RestRequest>(req => req.Resource == "/series")));
}
@@ -282,7 +281,7 @@ public void Filter()
filter.AddTag("tag1");
filter.AddTag("tag2");
- var result = client.ListSeries(filter);
+ client.ListSeries(filter);
mockclient.Verify(cl => cl.Execute<List<Series>>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "attr[key1]", "value1"))));
mockclient.Verify(cl => cl.Execute<List<Series>>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "attr[key2]", "value2"))));
@@ -329,7 +328,7 @@ public void RequestMethod()
var mockclient = TestCommon.GetMockRestClient<Series>(seriesResponse);
var client = TestCommon.GetClient(mockclient.Object);
- var result = client.UpdateSeries(seriesResponse);
+ client.UpdateSeries(seriesResponse);
mockclient.Verify(cl => cl.Execute<Series>(It.Is<RestRequest>(req => req.Method == Method.PUT)));
}
@@ -347,12 +346,10 @@ public void RequestUrl()
var mockclient = TestCommon.GetMockRestClient<Series>(seriesResponse);
var client = TestCommon.GetClient(mockclient.Object);
- var result = client.UpdateSeries(seriesResponse);
+ client.UpdateSeries(seriesResponse);
mockclient.Verify(cl => cl.Execute<Series>(It.Is<RestRequest>(req => req.Resource == "/series/id/{id}/")));
mockclient.Verify(cl => cl.Execute<Series>(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "id", "series-id"))));
}
}
-
-
-}
+}
View
10 Client.Tests/TestCommon.cs
@@ -1,15 +1,17 @@
-using System;
+using Moq;
+using RestSharp;
+using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
-using Moq;
-using RestSharp;
+
namespace Client.Tests
{
+
class TestCommon
{
- public static Client GetClient(RestClient restClient = null)
+ public static Client GetClient(RestClient restClient)
{
return new Client("api-key", "api-secret", restClient: restClient);
}
View
75 Client.Tests/WriteTests.cs
@@ -1,69 +1,70 @@
-using System;
-using System.Collections.Generic;
-using Client.Model;
-using MbUnit.Framework;
+using Client.Model;
+using Moq;
+using NUnit.Framework;
using RestSharp;
+using System;
+using System.Collections.Generic;
using System.Linq.Expressions;
-using Moq;
+
namespace Client.Tests
{
- [TestFixture]
- public class WriteTests
- {
- [Test]
- public void RequestMethod()
- {
+ [TestFixture]
+ public class WriteTests
+ {
+ [Test]
+ public void RequestMethod()
+ {
var mockclient = TestCommon.GetMockRestClient();
var client = TestCommon.GetClient(mockclient.Object);
- var data = new List<DataPoint>();
- double valueToAdd = new Random().NextDouble()*1000D;
- data.Add(new DataPoint(DateTime.Now, valueToAdd));
- client.WriteByKey("testkey", data);
+ var data = new List<DataPoint>();
+ double valueToAdd = new Random().NextDouble() * 1000D;
+ data.Add(new DataPoint(DateTime.Now, valueToAdd));
+ client.WriteByKey("testkey", data);
Expression<Func<RestRequest, bool>> assertion = req => req.Method == Method.POST;
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(assertion)));
- }
+ }
[Test]
- public void IncludesPoints()
- {
+ public void IncludesPoints()
+ {
var mockclient = TestCommon.GetMockRestClient();
var client = TestCommon.GetClient(mockclient.Object);
- var data = new List<DataPoint>();
- data.Add(new DataPoint(new DateTime(2012,12,12), 12.34));
+ var data = new List<DataPoint>();
+ data.Add(new DataPoint(new DateTime(2012,12,12), 12.34));
data.Add(new DataPoint(new DateTime(2012, 12, 12, 0, 0, 1), 56.78));
data.Add(new DataPoint(new DateTime(2012, 12, 12, 0, 0, 2), 90.12));
- client.WriteByKey("testkey", data);
+ client.WriteByKey("testkey", data);
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameterByPattern(req.Parameters, "application/json", "12.34"))));
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameterByPattern(req.Parameters, "application/json", "56.78"))));
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameterByPattern(req.Parameters, "application/json", "90.12"))));
}
- [Test]
- public void RequestCount()
- {
+ [Test]
+ public void RequestCount()
+ {
var numPoints = 100;
var mockClient = TestCommon.GetMockRestClient();
var client = TestCommon.GetClient(mockClient.Object);
var baseDateTime = new DateTime(2012, 06, 23);
- for (int i = 0; i < numPoints; i++)
- {
- var points = new List<BulkPoint>
- {
- new BulkKeyPoint("testkey1", 12.555D * new Random().NextDouble()),
- new BulkKeyPoint("testkey2", 555D * new Random().NextDouble())
- };
+ for (int i = 0; i < numPoints; i++)
+ {
+ var points = new List<BulkPoint>
+ {
+ new BulkKeyPoint("testkey1", 12.555D * new Random().NextDouble()),
+ new BulkKeyPoint("testkey2", 555D * new Random().NextDouble())
+ };
- var dataSet = new BulkDataSet(baseDateTime.AddMinutes(5*i), points);
- client.WriteBulkData(dataSet);
- }
+ var dataSet = new BulkDataSet(baseDateTime.AddMinutes(5*i), points);
+ client.WriteBulkData(dataSet);
+ }
mockClient.Verify(cl => cl.Execute(It.IsAny<RestRequest>()), Times.Exactly(100));
- }
- }
-}
+ }
+ }
+}
View
5 Client.Tests/packages.config
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="mbunit" version="3.3.454.0" />
<package id="Moq" version="4.0.10827" targetFramework="net40" />
<package id="RestSharp" version="104.1" targetFramework="net40" />
-</packages>
+ <package id="NUnit" version="2.6.1" />
+ <package id="NUnit.Runners" version="2.6.1" />
+</packages>
View
6 Client/TempoClient.csproj
@@ -37,7 +37,7 @@
<HintPath>..\packages\Newtonsoft.Json.4.5.7\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
- <HintPath>..\packages\RestSharp.103.1\lib\net4\RestSharp.dll</HintPath>
+ <HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath>

We should remember to indicate the rest sharp version bump when we deploy the package to nuget. Nuget page still shows 103

@myagley Owner
myagley added a note

Yeah, I had to do that because the client and tests were using different versions of RestSharp and it wouldn't compile in mono. I could downgrade to 103.1 for the tests.

Was the client using 103 or 104? We might as well bump it up

@myagley Owner
myagley added a note

Yeah, it was using 103, the tests were on 104.

Let's bump it up and see if anything breaks, I don't think 103 -> 104 is a breaking change

@myagley Owner
myagley added a note

Ok, we can handle it when the release is cut.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -66,7 +66,7 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+ <Import Project="$(SolutionDir).nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
@@ -74,4 +74,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
View
4 Client/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="4.5.7" />
- <package id="RestSharp" version="103.1" />
-</packages>
+ <package id="RestSharp" version="104.1" />
+</packages>
View
20 Makefile
@@ -0,0 +1,20 @@
+.PHONY: compile compile-test clean clean-build clean-test
+
+compile:
+ xbuild Client/TempoClient.csproj
+
+compile-test: compile
+ xbuild Client.Tests/Client.Tests.csproj
+
+test: compile-test
+ mono packages/NUnit.Runners.2.6.1/tools/nunit-console.exe Client.Tests/bin/Debug/Client.Tests.dll
+
+clean-build:
+ rm -rf Client/bin
+ rm -rf Client/obj
+
+clean-test:
+ rm -rf Client.Tests/bin
+ rm -rf Client.Tests/obj
+
+clean: clean-build clean-test
Something went wrong with that request. Please try again.