diff --git a/PocketSharp.Tests/AddTests.cs b/PocketSharp.Tests/AddTests.cs index 1153554..b980e4d 100644 --- a/PocketSharp.Tests/AddTests.cs +++ b/PocketSharp.Tests/AddTests.cs @@ -1,8 +1,8 @@ -using System; -using System.Threading.Tasks; +using PocketSharp.Models; +using System; using System.Collections.Generic; +using System.Threading.Tasks; using Xunit; -using PocketSharp.Models; namespace PocketSharp.Tests { @@ -24,6 +24,19 @@ namespace PocketSharp.Tests } + [Fact] + public async Task ItemWithInstableImagesIsAdded() + { + var uri = new Uri("http://www.valoronline.com.br"); + + PocketItem item = await client.Add(uri); + + Assert.Equal(uri, item.Uri); + + itemsToDelete.Add(item.ID); + } + + [Fact] public async Task AddComplexItem() { @@ -39,7 +52,7 @@ namespace PocketSharp.Tests items.ForEach(itm => { - if(itm.ID == item.ID) + if (itm.ID == item.ID) { itemDesired = itm; } diff --git a/PocketSharp.Tests/DefaultAccount.playlist b/PocketSharp.Tests/DefaultAccount.playlist index 8cf559d..4d904f6 100644 --- a/PocketSharp.Tests/DefaultAccount.playlist +++ b/PocketSharp.Tests/DefaultAccount.playlist @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/PocketSharp.Tests/StressTests.cs b/PocketSharp.Tests/StressTests.cs index 3a2936b..d9667f9 100644 --- a/PocketSharp.Tests/StressTests.cs +++ b/PocketSharp.Tests/StressTests.cs @@ -30,7 +30,7 @@ namespace PocketSharp.Tests [Fact] public async Task Are100IdingtemsRetrievedProperly() { - await FillAccount(8360, 10000); + await FillAccount(9273, 10000); } [Fact] diff --git a/PocketSharp/PocketClient.cs b/PocketSharp/PocketClient.cs index 5434e67..5a60451 100644 --- a/PocketSharp/PocketClient.cs +++ b/PocketSharp/PocketClient.cs @@ -199,7 +199,8 @@ namespace PocketSharp { new BoolConverter(), new UnixDateTimeConverter(), - new NullableIntConverter() + new NullableIntConverter(), + new UriConverter() } } ); diff --git a/PocketSharp/Properties/AssemblyInfo.cs b/PocketSharp/Properties/AssemblyInfo.cs index e385ee7..b2a357c 100644 --- a/PocketSharp/Properties/AssemblyInfo.cs +++ b/PocketSharp/Properties/AssemblyInfo.cs @@ -1,7 +1,4 @@ -using System.Resources; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; +using System.Reflection; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information @@ -25,5 +22,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.2.2")] -[assembly: AssemblyFileVersion("2.2.2")] \ No newline at end of file +[assembly: AssemblyVersion("3.0.0")] +[assembly: AssemblyFileVersion("3.0.0 RC1")] \ No newline at end of file diff --git a/PocketSharp/Utilities/JsonExtensions.cs b/PocketSharp/Utilities/JsonExtensions.cs index 839dc58..82203ee 100644 --- a/PocketSharp/Utilities/JsonExtensions.cs +++ b/PocketSharp/Utilities/JsonExtensions.cs @@ -3,7 +3,6 @@ using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; -using System.Diagnostics; namespace PocketSharp { @@ -40,7 +39,7 @@ namespace PocketSharp public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if(reader.Value.ToString() == "0") + if (reader.Value.ToString() == "0") { return null; } @@ -76,6 +75,38 @@ namespace PocketSharp + public class UriConverter : JsonConverter + { + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.String && Uri.IsWellFormedUriString(reader.Value.ToString(), UriKind.Absolute)) + { + return new Uri(reader.Value.ToString()); + } + + return null; + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + if (value == null) + { + writer.WriteNull(); + } + else if (value is Uri) + { + writer.WriteValue(((Uri)value).OriginalString); + } + } + + public override bool CanConvert(Type objectType) + { + return objectType.Equals(typeof(Uri)); + } + } + + + public class ObjectToArrayConverter : CustomCreationConverter> where T : new() { public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)