-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing serialisation issue with special characters in Compatibility m…
…ode.
- Loading branch information
1 parent
126554a
commit aa16635
Showing
16 changed files
with
373 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0"?> | ||
<configuration> | ||
<appSettings> | ||
<add key="AWSAccessKey" value=""/> | ||
<add key="AWSSecretKey" value=""/> | ||
</appSettings> | ||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using System; | ||
using NUnit.Framework; | ||
using XDMessaging.Messages; | ||
using XDMessaging.Serialization; | ||
|
||
namespace XDMessaging.Test | ||
{ | ||
[TestFixture] | ||
public class DataGramSerializerTests | ||
{ | ||
#region Setup/Teardown | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
serializer = new JsonSerializer(); | ||
} | ||
|
||
#endregion | ||
|
||
private const string channel = "myChannel"; | ||
private const string assemblyQualifiedName = "myAssemblyQualifiedName"; | ||
private const string message = "myMessage"; | ||
private JsonSerializer serializer; | ||
|
||
[Test] | ||
public void GivenADatagramWithSpecialCharsWhenSerializedThenSuccess() | ||
{ | ||
// arrange | ||
var specialMsg = "汉字"; | ||
var dataGram = new DataGram(channel, assemblyQualifiedName, specialMsg); | ||
|
||
// act | ||
var result = serializer.Serialize(dataGram); | ||
|
||
// assert | ||
Assert.That(result, Is.StringContaining(channel)); | ||
Assert.That(result, Is.StringContaining(specialMsg)); | ||
Assert.That(result, Is.StringContaining(assemblyQualifiedName)); | ||
Assert.That(result, Is.StringContaining("1.1")); | ||
} | ||
|
||
[Test] | ||
public void GivenADatagramWhenSerializedThenSuccess() | ||
{ | ||
// arrange | ||
var dataGram = new DataGram(channel, assemblyQualifiedName, message); | ||
|
||
// act | ||
var result = serializer.Serialize(dataGram); | ||
|
||
// assert | ||
Assert.That(result, Is.StringContaining(channel)); | ||
Assert.That(result, Is.StringContaining(message)); | ||
Assert.That(result, Is.StringContaining(assemblyQualifiedName)); | ||
Assert.That(result, Is.StringContaining("1.1")); | ||
} | ||
|
||
[Test] | ||
public void GivenASerializedDataGramVer2WhenDeserializedThenSuccess() | ||
{ | ||
// arrange | ||
const string msg = | ||
"{\"ver\":\"2.0\",\"type\":\"" + assemblyQualifiedName + "\",\"channel\":\"" + channel + | ||
"\",\"message\":\"" + message + "\"}"; | ||
|
||
// act | ||
var dataGram = serializer.Deserialize<DataGram>(msg); | ||
|
||
// assert | ||
Assert.That(dataGram, Is.Not.Null); | ||
Assert.That(dataGram.Channel, Is.EqualTo(channel)); | ||
Assert.That(dataGram.Message, Is.EqualTo(message)); | ||
Assert.That(dataGram.AssemblyQualifiedName, Is.EqualTo(assemblyQualifiedName)); | ||
Assert.That(dataGram.Version, Is.EqualTo("2.0")); | ||
} | ||
|
||
[Test] | ||
public void GivenASerializedDataGramVersion1WhenDeserializedThenSuccess() | ||
{ | ||
// arrange | ||
const string msg = "{\"ver\":\"1.0\",\"channel\":\"" + channel + "\",\"message\":\"" + message + "\"}"; | ||
|
||
// act | ||
var dataGram = serializer.Deserialize<DataGram>(msg); | ||
|
||
// assert | ||
Assert.That(dataGram, Is.Not.Null); | ||
Assert.That(dataGram.Channel, Is.EqualTo(channel)); | ||
Assert.That(dataGram.Message, Is.EqualTo(message)); | ||
Assert.That(dataGram.Version, Is.EqualTo("1.0")); | ||
string result; | ||
Assert.Throws<NotSupportedException>(() => result = dataGram.AssemblyQualifiedName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: AssemblyCompany("TheCodeKing")] | ||
[assembly: AssemblyCopyright("Copyright © 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: AssemblyVersion("5.0.2")] | ||
[assembly: AssemblyFileVersion("5.0.2")] | ||
[assembly: ComVisible(false)] | ||
[assembly: Guid("6ca3fc60-ba34-46c0-8550-9a4aa3ce8340")] | ||
|
||
#if SIGNED | ||
[assembly: AssemblyKeyFile(@"..\..\..\..\..\thecodeking.snk")] | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{6CA3FC60-BA34-46C0-8550-9A4AA3CE8340}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>XDMessaging.Test</RootNamespace> | ||
<AssemblyName>XDMessaging.Test</AssemblyName> | ||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Castle.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Moq, Version=4.5.30.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Moq.4.5.30\lib\net45\Moq.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\NUnit.3.6.0\lib\net45\nunit.framework.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="DataGramSerializerTests.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="XDMessagingClientExtensionTests.cs" /> | ||
<Compile Include="XDMessagingClientTests.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\XDMessaging\XDMessaging.csproj"> | ||
<Project>{e5a12ed6-6cd9-4758-b508-a6bb8554b7cc}</Project> | ||
<Name>XDMessaging</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using NUnit.Framework; | ||
|
||
namespace XDMessaging.Test | ||
{ | ||
[TestFixture] | ||
public class XDMessagingClientExtensionTests | ||
{ | ||
[Test] | ||
public void GivenAmazonBroadcastImplThenShouldResolveSuccess() | ||
{ | ||
// arrange | ||
var client = new XDMessagingClient(); | ||
|
||
// act | ||
var instance = client.Broadcasters.GetAmazonBroadcaster(); | ||
|
||
// assert | ||
Assert.That(instance, Is.Not.Null); | ||
} | ||
|
||
[Test] | ||
public void GivenAmazonListenerImplThenShouldResolveInstanceSuccess() | ||
{ | ||
// arrange | ||
var client = new XDMessagingClient(); | ||
|
||
// act | ||
var instance = client.Listeners.GetAmazonListener(); | ||
|
||
// assert | ||
Assert.That(instance, Is.Not.Null); | ||
} | ||
|
||
[Test] | ||
public void GivenIoStreamBroadcastImplThenShouldResolveSuccess() | ||
{ | ||
// arrange | ||
var client = new XDMessagingClient(); | ||
|
||
// act | ||
var instance = client.Broadcasters.GetIOStreamBroadcaster(); | ||
|
||
// assert | ||
Assert.That(instance, Is.Not.Null); | ||
} | ||
|
||
[Test] | ||
public void GivenIoStreamListenerImplThenShouldResolveSuccess() | ||
{ | ||
// arrange | ||
var client = new XDMessagingClient(); | ||
|
||
// act | ||
var instance = client.Listeners.GetIOStreamListener(); | ||
|
||
// assert | ||
Assert.That(instance, Is.Not.Null); | ||
} | ||
|
||
[Test] | ||
public void GivenWindowsMessagingBroadcastImplThenShouldResolveSuccess() | ||
{ | ||
// arrange | ||
var client = new XDMessagingClient(); | ||
|
||
// act | ||
var instance = client.Broadcasters.GetWindowsMessagingBroadcaster(); | ||
|
||
// assert | ||
Assert.That(instance, Is.Not.Null); | ||
} | ||
|
||
[Test] | ||
public void GivenWindowsMessagingListenerImplThenShouldResolveInstanceSuccess() | ||
{ | ||
// arrange | ||
var client = new XDMessagingClient(); | ||
|
||
// act | ||
var instance = client.Listeners.GetWindowsMessagingListener(); | ||
|
||
// assert | ||
Assert.That(instance, Is.Not.Null); | ||
} | ||
} | ||
} |
Oops, something went wrong.