Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update unit test framework to NUnit #6

Merged
merged 13 commits into from
Jan 25, 2013
Merged
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ packages
_Resharper* _Resharper*


# mstest test results # mstest test results
TestResults TestResult*


# files # files
*.suo *.suo
Expand Down
Binary file modified .nuget/NuGet.exe
Binary file not shown.
8 changes: 4 additions & 4 deletions .nuget/NuGet.targets
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@


<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'"> <PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows --> <!-- 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> <PackagesConfig>packages.config</PackagesConfig>
<PackagesDir>$(SolutionDir)packages</PackagesDir> <PackagesDir>$(MSBuildThisFileDirectory)..\packages</PackagesDir>
</PropertyGroup> </PropertyGroup>


<PropertyGroup> <PropertyGroup>
<!-- NuGet command --> <!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\nuget.exe</NuGetExePath> <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)NuGet.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources> <PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>


<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand> <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
Expand Down Expand Up @@ -136,4 +136,4 @@
</Code> </Code>
</Task> </Task>
</UsingTask> </UsingTask>
</Project> </Project>
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Original file line Diff line number Diff line change
@@ -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
19 changes: 5 additions & 14 deletions Client.Tests/Client.Tests.csproj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,25 +33,16 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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"> <Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath> <HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference> </Reference>
<Reference Include="RestSharp, Version=104.1.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="RestSharp, Version=104.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath> <HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="NUnit.Framework">
<HintPath>..\packages\NUnit.2.6.1\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
Expand Down Expand Up @@ -83,12 +74,12 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <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. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
</Target> </Target>
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>
11 changes: 6 additions & 5 deletions Client.Tests/DataPointModelTests.cs
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,10 @@
using System; using Client.Model;
using NUnit.Framework;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Client.Model;
using MbUnit.Framework;


namespace Client.Tests namespace Client.Tests
{ {
Expand Down Expand Up @@ -41,10 +42,10 @@ public void Unequality_Value()
public void Unequality_Null() public void Unequality_Null()
{ {
var dp1 = new DataPoint(new DateTime(2012, 1, 1, 0, 0, 1), 12.34); var dp1 = new DataPoint(new DateTime(2012, 1, 1, 0, 0, 1), 12.34);

Assert.AreNotEqual(dp1, null); Assert.AreNotEqual(dp1, null);
} }

[Test] [Test]
public void Equality_Null() public void Equality_Null()
{ {
Expand Down
25 changes: 12 additions & 13 deletions Client.Tests/DeleteTests.cs
Original file line number Original file line Diff line number Diff line change
@@ -1,12 +1,13 @@
using System; using Client.Model;
using Moq;
using NUnit.Framework;
using RestSharp;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using Client.Model;
using MbUnit.Framework;
using RestSharp;
using System.Linq.Expressions; using System.Linq.Expressions;
using Moq; using System.Text;



namespace Client.Tests namespace Client.Tests
{ {
Expand All @@ -19,13 +20,12 @@ public void SmokeTest()
var mockclient = TestCommon.GetMockRestClient(); var mockclient = TestCommon.GetMockRestClient();
var client = TestCommon.GetClient(mockclient.Object); var client = TestCommon.GetClient(mockclient.Object);



client.DeleteById("series-id", new DateTime(2012, 1, 1), new DateTime(2012, 1, 1, 1, 0, 0)); 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.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 => 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, "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-08: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, "property", "id"))));
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "value", "series-id")))); mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "value", "series-id"))));
} }
Expand All @@ -36,13 +36,12 @@ public void Key()
var mockclient = TestCommon.GetMockRestClient(); var mockclient = TestCommon.GetMockRestClient();
var client = TestCommon.GetClient(mockclient.Object); var client = TestCommon.GetClient(mockclient.Object);



client.DeleteByKey("series-key", new DateTime(2012, 1, 1), new DateTime(2012, 1, 1, 1, 0, 0)); 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.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 => 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, "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-08: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, "property", "key"))));
mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "value", "series-key")))); mockclient.Verify(cl => cl.Execute(It.Is<RestRequest>(req => TestCommon.ContainsParameter(req.Parameters, "value", "series-key"))));
} }
Expand Down
13 changes: 7 additions & 6 deletions Client.Tests/IncrementTests.cs
Original file line number Original file line Diff line number Diff line change
@@ -1,10 +1,11 @@
using System; using Client.Model;
using System.Collections.Generic; using Moq;
using Client.Model; using NUnit.Framework;
using MbUnit.Framework;
using RestSharp; using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
using Moq;


namespace Client.Tests namespace Client.Tests
{ {
Expand Down Expand Up @@ -66,4 +67,4 @@ public void RequestCount()
mockClient.Verify(cl => cl.Execute(It.IsAny<RestRequest>()), Times.Exactly(100)); mockClient.Verify(cl => cl.Execute(It.IsAny<RestRequest>()), Times.Exactly(100));
} }
} }
} }
35 changes: 14 additions & 21 deletions Client.Tests/JsonDeserializationTests.cs
Original file line number Original file line Diff line number Diff line change
@@ -1,11 +1,12 @@
using System; using Client.Model;
using Moq;
using NUnit.Framework;
using RestSharp;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Client.Model;
using MbUnit.Framework;
using Moq;
using RestSharp;


namespace Client.Tests namespace Client.Tests
{ {
Expand All @@ -22,23 +23,23 @@ public void SmokeTest()
{ {
var jsonResponse = new RestResponse 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); 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] [Test]
public void Long() public void Long()
{ {
var jsonResponse = new RestResponse 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); 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);
} }
} }


Expand All @@ -59,9 +60,6 @@ public void SmokeTest()
}; };


var result = JsonDeserializationTests.deserializer.Deserialize<Series>(jsonResponse); 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); Assert.AreEqual(series, result);
} }


Expand All @@ -72,7 +70,7 @@ public void Name()
{ {
Content = "{\"id\":\"series-id\",\"key\":\"series-key\",\"name\":\"series-name\",\"attributes\":{},\"tags\":[]}" Content = "{\"id\":\"series-id\",\"key\":\"series-key\",\"name\":\"series-name\",\"attributes\":{},\"tags\":[]}"
}; };

var result = JsonDeserializationTests.deserializer.Deserialize<Series>(jsonResponse); var result = JsonDeserializationTests.deserializer.Deserialize<Series>(jsonResponse);
Assert.AreEqual("series-name", result.Name); Assert.AreEqual("series-name", result.Name);
} }
Expand All @@ -84,8 +82,8 @@ public void Tags()
{ {
Content = "{\"id\":\"series-id\",\"key\":\"series-key\",\"name\":\"\",\"attributes\":{},\"tags\":[\"tag1\",\"tag2\"]}" 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(2, result.Tags.Count);
Assert.AreEqual("tag1", result.Tags[0]); Assert.AreEqual("tag1", result.Tags[0]);
Assert.AreEqual("tag2", result.Tags[1]); Assert.AreEqual("tag2", result.Tags[1]);
Expand All @@ -98,7 +96,7 @@ public void Attributes()
{ {
Content = "{\"id\":\"series-id\",\"key\":\"series-key\",\"name\":\"\",\"attributes\":{\"key1\":\"val1\",\"key2\":\"val2\"},\"tags\":[]}" Content = "{\"id\":\"series-id\",\"key\":\"series-key\",\"name\":\"\",\"attributes\":{\"key1\":\"val1\",\"key2\":\"val2\"},\"tags\":[]}"
}; };

var result = JsonDeserializationTests.deserializer.Deserialize<Series>(jsonResponse); var result = JsonDeserializationTests.deserializer.Deserialize<Series>(jsonResponse);
Assert.AreEqual(2, result.Attributes.Count); Assert.AreEqual(2, result.Attributes.Count);
Assert.AreEqual("val1", result.Attributes["key1"]); Assert.AreEqual("val1", result.Attributes["key1"]);
Expand Down Expand Up @@ -172,12 +170,7 @@ public void EmptySummary()


var result = JsonDeserializationTests.deserializer.Deserialize<DataSet>(jsonResponse); var result = JsonDeserializationTests.deserializer.Deserialize<DataSet>(jsonResponse);
Assert.AreEqual(0, result.Summary.Count); Assert.AreEqual(0, result.Summary.Count);


} }
} }
} }



} }
17 changes: 9 additions & 8 deletions Client.Tests/JsonSerializationTests.cs
Original file line number Original file line Diff line number Diff line change
@@ -1,11 +1,12 @@
using System; using Client.Model;
using Moq;
using NUnit.Framework;
using RestSharp;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Client.Model;
using MbUnit.Framework;
using Moq;
using RestSharp;


namespace Client.Tests namespace Client.Tests
{ {
Expand All @@ -22,7 +23,7 @@ public void SmokeTest()
{ {
var dp = new DataPoint(new DateTime(2012, 1, 1, 0, 0, 1), 12.34); var dp = new DataPoint(new DateTime(2012, 1, 1, 0, 0, 1), 12.34);
var result = JsonSerializationTests.serializer.Serialize(dp); 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] [Test]
Expand All @@ -31,7 +32,7 @@ public void EmptyValue()
var dp = new DataPoint(); var dp = new DataPoint();
var result = JsonSerializationTests.serializer.Serialize(dp); var result = JsonSerializationTests.serializer.Serialize(dp);


Assert.Contains(result, ":0.0"); StringAssert.Contains(":0.0", result);
} }
} }


Expand Down Expand Up @@ -135,7 +136,7 @@ public void SmokeTest()
var bds = new BulkDataSet(new DateTime(2012, 1, 1), data); var bds = new BulkDataSet(new DateTime(2012, 1, 1), data);
var result = JsonSerializationTests.serializer.Serialize(bds); 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);
} }
} }
} }
Expand Down
Loading