Skip to content

Commit

Permalink
Merge pull request #102 from Tapanila/protobuf
Browse files Browse the repository at this point in the history
Protobuf
  • Loading branch information
Tapanila authored May 21, 2017
2 parents 9b92e9e + ab871de commit d2ef099
Show file tree
Hide file tree
Showing 46 changed files with 3,149 additions and 206 deletions.
16 changes: 6 additions & 10 deletions SharpCaster.Console/SharpCaster.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Google.Protobuf, Version=3.3.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.3.0\lib\net45\Google.Protobuf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
<Private>True</Private>
Expand All @@ -47,16 +51,8 @@
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="protobuf-net, Version=2.0.0.668, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\protobuf-net-sharpcaster.2.0.0.668\lib\portable46-net451+win81+wpa81\protobuf-net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Rssdp.Native, Version=2.0.0.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Rssdp.2.0.0.5\lib\net40\Rssdp.Native.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Rssdp.Portable, Version=2.0.0.4, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Rssdp.2.0.0.5\lib\net40\Rssdp.Portable.dll</HintPath>
<Reference Include="Rssdp, Version=3.5.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Rssdp.3.5.4\lib\net45\Rssdp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Sockets.Plugin, Version=2.0.2.0, Culture=neutral, processorArchitecture=MSIL">
Expand Down
4 changes: 2 additions & 2 deletions SharpCaster.Console/packages.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.Protobuf" version="3.3.0" targetFramework="net452" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net452" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net452" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net452" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net452" />
<package id="protobuf-net-sharpcaster" version="2.0.0.668" targetFramework="net452" />
<package id="Rssdp" version="2.0.0.5" targetFramework="net452" />
<package id="Rssdp" version="3.5.4" targetFramework="net452" />
<package id="Sharpcaster.SocketsForPCL" version="2.0.4" targetFramework="net452" />
</packages>
12 changes: 6 additions & 6 deletions SharpCaster.Simple.Android/SharpCaster.Simple.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
</PropertyGroup>
<ItemGroup>
<Reference Include="Google.Protobuf, Version=3.3.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.3.0\lib\netstandard1.0\Google.Protobuf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net45+win8+wpa81\Microsoft.Threading.Tasks.dll</HintPath>
<Private>True</Private>
Expand All @@ -53,12 +57,8 @@
</Reference>
<Reference Include="Mono.Android" />
<Reference Include="mscorlib" />
<Reference Include="Rssdp.Native, Version=2.0.0.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Rssdp.2.0.0.5\lib\monoandroid\Rssdp.Native.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Rssdp.Portable, Version=2.0.0.4, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Rssdp.2.0.0.5\lib\monoandroid\Rssdp.Portable.dll</HintPath>
<Reference Include="Rssdp, Version=3.5.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Rssdp.3.5.4\lib\monoandroid\Rssdp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Sockets.Plugin, Version=2.0.2.0, Culture=neutral, processorArchitecture=MSIL">
Expand Down
27 changes: 26 additions & 1 deletion SharpCaster.Simple.Android/packages.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.Protobuf" version="3.3.0" targetFramework="monoandroid70" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="monoandroid60" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="monoandroid60" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="monoandroid60" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="monoandroid60" />
<package id="Rssdp" version="2.0.0.5" targetFramework="monoandroid70" />
<package id="Rssdp" version="3.5.4" targetFramework="monoandroid70" />
<package id="Sharpcaster.SocketsForPCL" version="2.0.4" targetFramework="monoandroid70" />
<package id="System.Collections" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Diagnostics.Tools" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.Globalization" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.IO" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Linq" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Linq.Expressions" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Net.Http" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Net.Primitives" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Net.Sockets" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.ObjectModel" version="4.0.12" targetFramework="monoandroid70" />
<package id="System.Reflection" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Reflection.Extensions" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.Runtime" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.0.0" targetFramework="monoandroid70" />
<package id="System.Text.Encoding" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Text.Encoding.Extensions" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Text.RegularExpressions" version="4.1.0" targetFramework="monoandroid70" />
<package id="System.Threading" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Threading.Tasks" version="4.0.11" targetFramework="monoandroid70" />
<package id="System.Threading.Timer" version="4.0.1" targetFramework="monoandroid70" />
<package id="System.Xml.ReaderWriter" version="4.0.11" targetFramework="monoandroid70" />
</packages>
17 changes: 4 additions & 13 deletions SharpCaster.Simple/SharpCaster.Simple.nuget.targets
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">C:\Users\habakker\Documents\Source\SharpCaster\SharpCaster.Simple\project.lock.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\habakker\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">ProjectJson</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.1.0</NuGetToolVersion>
<PropertyGroup Condition="'$(NuGetPackageRoot)' == ''">
<NuGetPackageRoot>$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)microsoft.bcl.build\1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.bcl.build\1.0.21\build\Microsoft.Bcl.Build.targets')" />
<ImportGroup>
<Import Project="$(NuGetPackageRoot)\Microsoft.Bcl.Build\1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('$(NuGetPackageRoot)\Microsoft.Bcl.Build\1.0.21\build\Microsoft.Bcl.Build.targets')" />
</ImportGroup>
</Project>
9 changes: 5 additions & 4 deletions SharpCaster.Simple/project.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"dependencies": {
"Google.Protobuf": "3.3.0",
"Microsoft.Bcl.Build": "1.0.21",
"Microsoft.Net.Http": "2.2.29",
"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.3",
"Newtonsoft.Json": "9.0.1",
"protobuf-net-sharpcaster": "2.0.0.668",
"Rssdp": "2.0.0.5",
"sharpcaster.SocketsForPCL": "2.0.4"
"Rssdp": "3.5.4",
"sharpcaster.SocketsForPCL": "2.0.4",
"System.Xml.ReaderWriter": "4.3.0"
},
"frameworks": {
"uap10.0": {}
Expand Down
8 changes: 2 additions & 6 deletions SharpCaster.Test/ChromecastTester.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Linq;
using SharpCaster.Controllers;
using SharpCaster.Services;
using Xunit;
Expand All @@ -12,7 +8,7 @@ namespace SharpCaster.Test
{
public class ChromecastTester
{
private ChromecastService _chromecastService;
private readonly ChromecastService _chromecastService;
public ChromecastTester()
{
_chromecastService = ChromecastService.Current;
Expand Down
2 changes: 1 addition & 1 deletion SharpCaster.Test/DeviceLocatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace SharpCaster.Test
{
public class DeviceLocatorTest
{
private ChromecastService _chromecastService;
private readonly ChromecastService _chromecastService;
public DeviceLocatorTest()
{
_chromecastService = ChromecastService.Current;
Expand Down
52 changes: 39 additions & 13 deletions SharpCaster.Test/ProtoBufTester.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text;
using SharpCaster.Models;
using Xunit;

Expand All @@ -16,39 +12,69 @@ public void Connect_Should_Be_Serialized_Well()
var connectMessage = MessageFactory.Connect();
connectMessage.Namespace = "urn:x-cast:com.google.cast.tp.connection";
var bytes = connectMessage.ToProto();
Assert.Equal(bytes, new byte[] { 0, 0, 0, 88, 8, 0, 18, 8, 115, 101, 110, 100, 101, 114, 45, 48, 26, 10, 114, 101, 99, 101, 105, 118, 101, 114, 45, 48, 34, 40, 117, 114, 110, 58, 120, 45, 99, 97, 115, 116, 58, 99, 111, 109, 46, 103, 111, 111, 103, 108, 101, 46, 99, 97, 115, 116, 46, 116, 112, 46, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 40, 0, 50, 18, 123, 34, 116, 121, 112, 101, 34, 58, 34, 67, 79, 78, 78, 69, 67, 84, 34, 125 });
var expectedBytes = new byte[]
{
0, 0, 0, 88, 8, 0, 18, 8, 115, 101, 110, 100, 101, 114, 45, 48, 26, 10, 114, 101, 99, 101, 105, 118,
101, 114, 45, 48, 34, 40, 117, 114, 110, 58, 120, 45, 99, 97, 115, 116, 58, 99, 111, 109, 46, 103, 111,
111, 103, 108, 101, 46, 99, 97, 115, 116, 46, 116, 112, 46, 99, 111, 110, 110, 101, 99, 116, 105, 111,
110, 40, 0, 50, 18, 123, 34, 116, 121, 112, 101, 34, 58, 34, 67, 79, 78, 78, 69, 67, 84, 34, 125
};
Assert.Equal(bytes, expectedBytes);
}

[Fact]
public void Ping_Should_Be_Serialized_Well()
{
var pingMessage = MessageFactory.Ping;
var bytes = pingMessage.ToProto();
Assert.Equal(bytes, new byte[] { 0, 0, 0, 43, 8, 0, 18, 8, 115, 101, 110, 100, 101, 114, 45, 48, 26, 10, 114, 101, 99, 101, 105, 118, 101, 114, 45, 48, 40, 0, 50, 15, 123, 34, 116, 121, 112, 101, 34, 58, 34, 80, 73, 78, 71, 34, 125 });
var expectedBytes = new byte[]
{
0, 0, 0, 43, 8, 0, 18, 8, 115, 101, 110, 100, 101, 114, 45, 48, 26, 10, 114, 101, 99, 101, 105, 118, 101,
114, 45, 48, 40, 0, 50, 15, 123, 34, 116, 121, 112, 101, 34, 58, 34, 80, 73, 78, 71, 34, 125
};
Assert.Equal(bytes, expectedBytes);
}

[Fact]
public void Close_Should_Be_Serialized_Well()
{
var closeMessage = MessageFactory.Close;
var bytes = closeMessage.ToProto();
Assert.Equal(bytes, new byte[] { 0, 0, 0, 44, 8, 0, 18, 8, 115, 101, 110, 100, 101, 114, 45, 48, 26, 10, 114, 101, 99, 101, 105, 118, 101, 114, 45, 48, 40, 0, 50, 16, 123, 34, 116, 121, 112, 101, 34, 58, 34, 67, 76, 79, 83, 69, 34, 125 });
var expectedBytes = new byte[]
{
0, 0, 0, 44, 8, 0, 18, 8, 115, 101, 110, 100, 101, 114, 45, 48, 26, 10, 114, 101, 99, 101, 105, 118, 101,
114, 45, 48, 40, 0, 50, 16, 123, 34, 116, 121, 112, 101, 34, 58, 34, 67, 76, 79, 83, 69, 34, 125
};
Assert.Equal(bytes, expectedBytes);
}

[Fact]
public void Volume_Level_Should_Be_Serialized_Well()
{
var volumeLevel = MessageFactory.Volume(0.7);
var volumeLevel = MessageFactory.Volume(0.7, 100);
var bytes = volumeLevel.ToProto();
Assert.Equal(bytes, new byte[] { 0, 0, 0, 94, 8, 0, 18, 8, 115, 101, 110, 100, 101, 114, 45, 48, 26, 10, 114, 101, 99, 101, 105, 118, 101, 114, 45, 48, 40, 0, 50, 66, 123, 34, 118, 111, 108, 117, 109, 101, 34, 58, 123, 34, 108, 101, 118, 101, 108, 34, 58, 48, 46, 55, 125, 44, 34, 114, 101, 113, 117, 101, 115, 116, 73, 100, 34, 58, 53, 53, 52, 55, 54, 51, 57, 50, 53, 44, 34, 116, 121, 112, 101, 34, 58, 34, 83, 69, 84, 95, 86, 79, 76, 85, 77, 69, 34, 125 });
var expectedBytes = new byte[]
{
0, 0, 0, 88, 8, 0, 18, 8, 115, 101, 110, 100, 101, 114, 45, 48, 26, 10, 114, 101, 99, 101, 105, 118, 101,
114, 45, 48, 40, 0, 50, 60, 123, 34, 118, 111, 108, 117, 109, 101, 34, 58, 123, 34, 108, 101, 118, 101,
108, 34, 58, 48, 46, 55, 125, 44, 34, 114, 101, 113, 117, 101, 115, 116, 73, 100, 34, 58, 49, 48, 48, 44,
34, 116, 121, 112, 101, 34, 58, 34, 83, 69, 84, 95, 86, 79, 76, 85, 77, 69, 34, 125
};
Assert.Equal(bytes, expectedBytes);
}

[Fact]
public void Volume_Mute_Should_Be_Serialized_Well()
{
var volumeMuted = MessageFactory.Volume(true);
var volumeMuted = MessageFactory.Volume(true, 100);
var bytes = volumeMuted.ToProto();
Assert.Equal(bytes, new byte[] { 0, 0, 0, 96, 8, 0, 18, 8, 115, 101, 110, 100, 101, 114, 45, 48, 26, 10, 114, 101, 99, 101, 105, 118, 101, 114, 45, 48, 40, 0, 50, 68, 123, 34, 118, 111, 108, 117, 109, 101, 34, 58, 123, 34, 109, 117, 116, 101, 100, 34, 58, 116, 114, 117, 101, 125, 44, 34, 114, 101, 113, 117, 101, 115, 116, 73, 100, 34, 58, 50, 48, 51, 53, 51, 56, 52, 49, 53, 56, 44, 34, 116, 121, 112, 101, 34, 58, 34, 83, 69, 84, 95, 86, 79, 76, 85, 77, 69, 34, 125 });
var expectedBytes = new byte[]
{
0, 0, 0, 89, 8, 0, 18, 8, 115, 101, 110, 100, 101, 114, 45, 48, 26, 10, 114, 101, 99, 101, 105, 118, 101,
114, 45, 48, 40, 0, 50, 61, 123, 34, 118, 111, 108, 117, 109, 101, 34, 58, 123, 34, 109, 117, 116, 101,
100, 34, 58, 116, 114, 117, 101, 125, 44, 34, 114, 101, 113, 117, 101, 115, 116, 73, 100, 34, 58, 49, 48,
48, 44, 34, 116, 121, 112, 101, 34, 58, 34, 83, 69, 84, 95, 86, 79, 76, 85, 77, 69, 34, 125
};
Assert.Equal(bytes, expectedBytes);
}

private static string PrintBytes(byte[] byteArray)
Expand Down
Loading

0 comments on commit d2ef099

Please sign in to comment.