From 7e206cd426955df3d265725d68c4c9862f2df7fb Mon Sep 17 00:00:00 2001 From: Troy Willmot Date: Tue, 9 May 2017 18:15:08 +1200 Subject: [PATCH] Add test to prove deserialisation works with empty custom properties. Updates for new version release. --- src/Main/PublishNugetPackage.cmd | 2 +- src/Main/Rssdp.nuspec | 4 +- src/Main/Shared/AssemblyInfoCommon.cs | 4 +- .../DeviceDeserialisationTests.cs | 2 +- src/Main/Test.SsdpPortable/SsdpDeviceTests.cs | 39 +++++++++++++++++++ 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/Main/PublishNugetPackage.cmd b/src/Main/PublishNugetPackage.cmd index c4f3970..bfbf8ac 100644 --- a/src/Main/PublishNugetPackage.cmd +++ b/src/Main/PublishNugetPackage.cmd @@ -1,5 +1,5 @@ @echo off echo Press any key to publish pause -".nuget\NuGet.exe" push Rssdp.3.0.1.nupkg -Source https://www.nuget.org/api/v2/package +".nuget\NuGet.exe" push Rssdp.3.0.2.nupkg -Source https://www.nuget.org/api/v2/package pause \ No newline at end of file diff --git a/src/Main/Rssdp.nuspec b/src/Main/Rssdp.nuspec index ea5d581..1afce8c 100644 --- a/src/Main/Rssdp.nuspec +++ b/src/Main/Rssdp.nuspec @@ -2,7 +2,7 @@ Rssdp - 3.0.1 + 3.0.2 Rssdp Troy Willmot Yortw @@ -12,7 +12,7 @@ false Really Simple Service Discovery Protocol - a 100% .Net implementation of the SSDP protocol for publishing custom/basic devices, and discovering all device types on a network. A 100% .Net implementation of the SSDP protocol for basic and custom device types. - Prevent unhandled/uncatchable background thread exceptions crashing calling app. + Fix for deserialisation problems when a custom property with an empty value exists in the device description document. Copyright 2017 en-AU portable xamarin ios android windowsphone winrt uwp mobile ssdp discovery device service protocol upnp netfx40 .net4 diff --git a/src/Main/Shared/AssemblyInfoCommon.cs b/src/Main/Shared/AssemblyInfoCommon.cs index 1dda5b5..b4c69ac 100644 --- a/src/Main/Shared/AssemblyInfoCommon.cs +++ b/src/Main/Shared/AssemblyInfoCommon.cs @@ -5,5 +5,5 @@ [assembly: AssemblyCopyright("Released under the MIT license; http://choosealicense.com/licenses/mit/; https://github.com/Yortw/RSSDP")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("3.0.1.0")] -[assembly: AssemblyFileVersion("3.0.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("3.0.2.0")] +[assembly: AssemblyFileVersion("3.0.2.0")] \ No newline at end of file diff --git a/src/Main/Test.SsdpPortable/DeviceDeserialisationTests.cs b/src/Main/Test.SsdpPortable/DeviceDeserialisationTests.cs index 7aa26b9..88fa440 100644 --- a/src/Main/Test.SsdpPortable/DeviceDeserialisationTests.cs +++ b/src/Main/Test.SsdpPortable/DeviceDeserialisationTests.cs @@ -240,7 +240,7 @@ public void RootDeviceDeserialisationConstructor_ThrowsOnLocation() { var rootDevice = new SsdpRootDevice(null, TimeSpan.FromMinutes(30), ""); } - + private void AssertDevicesAreSame(SsdpRootDevice originalDevice, SsdpRootDevice deserialisedDevice) { Assert.AreEqual(originalDevice.CacheLifetime, deserialisedDevice.CacheLifetime); diff --git a/src/Main/Test.SsdpPortable/SsdpDeviceTests.cs b/src/Main/Test.SsdpPortable/SsdpDeviceTests.cs index 206561e..653bc17 100644 --- a/src/Main/Test.SsdpPortable/SsdpDeviceTests.cs +++ b/src/Main/Test.SsdpPortable/SsdpDeviceTests.cs @@ -461,6 +461,45 @@ public void SsdpDevice_Constructor_DeserialisesComplexDeviceDocumentAndSkipsComp Assert.IsFalse(subDevice.CustomProperties.Contains("X_Rhapsody-Extension")); } + [TestMethod] + public void DeserialisationHandlesEmptyCustomProperties() + { + //See issue #70 in repo - empty custom properties would cause + //all following properties to be skipped. + + var docString = @" + + + 1 + 0 + + + urn:schemas-upnp-org:device:MediaServer:1 + uuid:55076f6e-6b79-1d65-a472-00059a3c7a00 + Twonky :) + + PacketVideo + http://www.pv.com + TwonkyServer + http://www.twonky.com + TwonkyServer (Windows, T-206) + 8.4 + 8.4 + +"; + + + var device = new SsdpRootDevice(new Uri("http://192.168.1.11/UPnP/DeviceDescription"), TimeSpan.FromMinutes(30), docString); + Assert.IsFalse(device.CustomProperties.Contains("pv:extension")); + Assert.AreEqual(device.Manufacturer, "PacketVideo"); + Assert.AreEqual(device.ManufacturerUrl, "http://www.pv.com"); + Assert.AreEqual(device.ModelName, "TwonkyServer"); + Assert.AreEqual(device.ModelUrl, "http://www.twonky.com"); + Assert.AreEqual(device.ModelDescription, "TwonkyServer (Windows, T-206)"); + Assert.AreEqual(device.ModelNumber, "8.4"); + Assert.AreEqual(device.SerialNumber, "8.4"); + } + #endregion #region Service Tests