Skip to content

Commit

Permalink
updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
odyth committed Aug 29, 2014
1 parent 71fb8b5 commit eaf888c
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 60 deletions.
Binary file added lib/nunit.framework.dll
Binary file not shown.
34 changes: 23 additions & 11 deletions msgpack-sharp-tests/SerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public enum TestEnum
[Test]
public void TestAsMaps()
{
MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Map;
AnimalMessage msg = AnimalMessage.CreateTestMessage();
byte[] payload = msg.ToMsgPack(true);
byte[] payload = msg.ToMsgPack();
Assert.IsNotNull(payload);
Assert.AreNotEqual(0, payload.Length);
AnimalMessage restored = MsgPackSerializer.Deserialize<AnimalMessage>(payload);
Expand All @@ -29,7 +30,8 @@ public void TestAsMaps()

[Test]
public void TestNestedObject ()
{
{
MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Array;
var obj = new SerializationTestObject();
byte[] msg = MsgPackSerializer.SerializeObject(obj);
var desiz = MsgPackSerializer.Deserialize<SerializationTestObject>(msg);
Expand All @@ -47,7 +49,8 @@ public void TestNestedObject ()

[Test]
public void TestDictionary()
{
{
MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Array;
TestGenericDictionary<bool, bool>(true, false);
// BREAKS TestGenericDictionary<int, object>(int.MinValue, new object());
TestGenericDictionary<string, string>("TESTKEY", "TESTVAL");
Expand Down Expand Up @@ -95,7 +98,8 @@ private void TestGenericDictionary<Key, Value> (Key testKey, Value testValue)

[Test]
public void TestList()
{
{
MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Array;
TestGenericList<bool>(true, false);
// BREAKS TestGenericList<object>(new object(), null);
TestGenericList<string>("TESTKEY", "TESTVAL");
Expand Down Expand Up @@ -145,7 +149,8 @@ private void TestGenericList<T> (T entry1, T entry2)

[Test]
public void TestDeserializationOfMixedTypeDictionary()
{
{
MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Array;
var obj = new Dictionary<string, object> {
{ "Boolean", false },
{ "String", "string" },
Expand All @@ -163,7 +168,9 @@ public void TestDeserializationOfMixedTypeDictionary()
}

[Test]
public void TestMixedTypeDictionaryRoundTrip() {
public void TestMixedTypeDictionaryRoundTrip()
{
MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Array;
var obj = new Dictionary<string, object> {
{ "Boolean", false },
{ "String", "string" },
Expand All @@ -180,7 +187,8 @@ public void TestMixedTypeDictionaryRoundTrip() {

[Test]
public void TestCompat()
{
{
MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Array;
AnimalMessage msg = AnimalMessage.CreateTestMessage();
byte[] payload = msg.ToMsgPack();
string msgFilename = Path.Combine(Environment.CurrentDirectory, "animal.msg");
Expand All @@ -195,7 +203,8 @@ public void TestCompat()

[Test]
public void TestLimits()
{
{
MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Array;
TestLimit(5);
//TestLimit(20);
}
Expand All @@ -220,7 +229,8 @@ private void TestLimit(int count)

[Test]
public void TestNulls()
{
{
MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Array;
var msg = AnimalMessage.CreateTestMessage();
msg.AnimalColor = null;
byte[] payload = msg.ToMsgPack();
Expand All @@ -232,7 +242,8 @@ public void TestNulls()

[Test]
public void TestRoundTripPrimitives()
{
{
MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Array;
TestRoundTrip(0);
TestRoundTrip(127);

Expand All @@ -258,7 +269,8 @@ private void TestRoundTrip(int intVal)

[Test]
public void TestRoundTripComplexTypes()
{
{
MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Array;
AnimalMessage msg = AnimalMessage.CreateTestMessage();

byte[] payload = msg.ToMsgPack();
Expand Down
100 changes: 51 additions & 49 deletions msgpack-sharp-tests/msgpack-sharp-tests.csproj
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0587C796-0B5E-4A36-B197-6C40232D4FD1}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>scopely.msgpacksharp.tests</RootNamespace>
<AssemblyName>msgpack-sharp-tests</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.framework" />
</ItemGroup>
<ItemGroup>
<Compile Include="AnimalMessage.cs" />
<Compile Include="AnimalColor.cs" />
<Compile Include="SerializationTests.cs" />
<Compile Include="Habitat.cs" />
<Compile Include="SerializationTestObject.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\msgpack-sharp\msgpack-sharp.csproj">
<Project>{765753B8-A9EB-4DD1-B0F0-D478E54E9ACB}</Project>
<Name>msgpack-sharp</Name>
</ProjectReference>
</ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0587C796-0B5E-4A36-B197-6C40232D4FD1}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>scopely.msgpacksharp.tests</RootNamespace>
<AssemblyName>msgpack-sharp-tests</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.framework">
<HintPath>..\lib\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AnimalMessage.cs" />
<Compile Include="AnimalColor.cs" />
<Compile Include="SerializationTests.cs" />
<Compile Include="Habitat.cs" />
<Compile Include="SerializationTestObject.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\msgpack-sharp\msgpack-sharp.csproj">
<Project>{765753B8-A9EB-4DD1-B0F0-D478E54E9ACB}</Project>
<Name>msgpack-sharp</Name>
</ProjectReference>
</ItemGroup>
</Project>

0 comments on commit eaf888c

Please sign in to comment.