make Test playlists; refactored PocketItem inline lists (setters are working now);
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<Playlist Version="1.0"><Add Test="PocketSharp.Tests.AddTests.AddSimpleItemWithUriOnly" /><Add Test="PocketSharp.Tests.GetTests.AreStatisticsRetrieved" /><Add Test="PocketSharp.Tests.GetTests.InvalidSearchReturnsNoResult" /><Add Test="PocketSharp.Tests.AccountTests.AreInvalidRegistrationsBlocked" /><Add Test="PocketSharp.Tests.GetTests.AreLimitsRetrieved" /><Add Test="PocketSharp.Tests.GetTests.InvalidSearchByTagsReturnsNoResult" /><Add Test="PocketSharp.Tests.ModifyTagsTests.AreTagsReplaced" /><Add Test="PocketSharp.Tests.GetTests.ItemContainsUri" /><Add Test="PocketSharp.Tests.GetTests.IsItemRetrievedById" /><Add Test="PocketSharp.Tests.GetTests.InvalidRetrievalReturnsNoResults" /><Add Test="PocketSharp.Tests.ModifyTests.IsAnItemFavoritedAndUnfavorited" /><Add Test="PocketSharp.Tests.GetTests.SearchByTagsReturnsResult" /><Add Test="PocketSharp.Tests.GetTests.RetrieveTagsReturnsResult" /><Add Test="PocketSharp.Tests.GetTests.SearchReturnsResult" /><Add Test="PocketSharp.Tests.ModifyTagsTests.AreTagsAddedAndDeletedToAnItem" /><Add Test="PocketSharp.Tests.GetTests.AreItemsRetrieved" /><Add Test="PocketSharp.Tests.ReadTests.IsBodyOnlyProperlyResolved" /><Add Test="PocketSharp.Tests.ModifyTagsTests.AreAllTagsRemovedFromItem" /><Add Test="PocketSharp.Tests.GetTests.IsNewPocketItemListGeneratorWorking" /><Add Test="PocketSharp.Tests.AccountTests.IsUserRegistered" /><Add Test="PocketSharp.Tests.ReadTests.ReadArticleWithInvalidUriTest" /><Add Test="PocketSharp.Tests.AddTests.AddComplexItem" /><Add Test="PocketSharp.Tests.ModifyTests.IsAnItemArchivedAndUnarchived" /><Add Test="PocketSharp.Tests.GetTests.AreFilteredItemsRetrieved" /><Add Test="PocketSharp.Tests.ReadTests.ReadArticleTest" /><Add Test="PocketSharp.Tests.ModifyTests.IsAnItemDeleted" /><Add Test="PocketSharp.Tests.GetTests.RetrieveWithMultipleFilters" /></Playlist>
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using PocketSharp.Models;
|
||||
|
||||
@@ -147,7 +148,7 @@ namespace PocketSharp.Tests
|
||||
[Fact]
|
||||
public async Task AreStatisticsRetrieved()
|
||||
{
|
||||
PocketStatistics statistics = await client.Statistics();
|
||||
PocketStatistics statistics = await client.GetUserStatistics();
|
||||
|
||||
Assert.True(statistics.CountAll > 0);
|
||||
}
|
||||
@@ -160,5 +161,15 @@ namespace PocketSharp.Tests
|
||||
|
||||
Assert.True(limits.RateLimitForConsumerKey > 9999);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task IsNewPocketItemListGeneratorWorking()
|
||||
{
|
||||
List<PocketItem> items = await client.Get(count: 1, tag: "pocket");
|
||||
PocketItem item = items[0];
|
||||
|
||||
Assert.True(item.Tags.Find(i => i.Name == "pocket") != null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<Playlist Version="1.0"><Add Test="PocketSharp.Tests.StressTests.Are0ItemsRetrievedProperly" /><Add Test="PocketSharp.Tests.StressTests.Are100ItemsRetrievedProperly" /><Add Test="PocketSharp.Tests.StressTests.Are10000ItemsRetrievedProperly" /><Add Test="PocketSharp.Tests.StressTests.IsSearchedSuccessfullyOn10000Items" /><Add Test="PocketSharp.Tests.StressTests.Are1000ItemsRetrievedProperly" /></Playlist>
|
||||
@@ -25,37 +25,35 @@ namespace PocketSharp.Tests
|
||||
);
|
||||
|
||||
urls = File.ReadAllLines("../../url-10000.csv").Select(item => item.Split(',')[1]);
|
||||
|
||||
//await FillAccount(598, 10000);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task Are100ItemsRetrievedProperly()
|
||||
{
|
||||
|
||||
// await FillAccount(1257, 10000);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Are1000ItemsRetrievedProperly()
|
||||
public async Task Are1000ItemsRetrievedProperly()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Are10000ItemsRetrievedProperly()
|
||||
public async Task Are10000ItemsRetrievedProperly()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Are0ItemsRetrievedProperly()
|
||||
public async Task Are0ItemsRetrievedProperly()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsSearchedSuccessfullyOn10000Items()
|
||||
public async Task IsSearchedSuccessfullyOn10000Items()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -200,65 +200,44 @@ namespace PocketSharp.Models
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the _ tag dictionary.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The _ tag dictionary.
|
||||
/// </value>
|
||||
[JsonProperty("tags")]
|
||||
private Dictionary<string, PocketTag> _TagDictionary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the _ image dictionary.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The _ image dictionary.
|
||||
/// </value>
|
||||
[JsonProperty("images")]
|
||||
private Dictionary<string, PocketImage> _ImageDictionary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the _ video dictionary.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The _ video dictionary.
|
||||
/// </value>
|
||||
[JsonProperty("videos")]
|
||||
private Dictionary<string, PocketVideo> _VideoDictionary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the _ author dictionary.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The _ author dictionary.
|
||||
/// </value>
|
||||
[JsonProperty("authors")]
|
||||
private Dictionary<string, PocketAuthor> _AuthorDictionary { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tags.
|
||||
/// Gets or sets the tags.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The tags.
|
||||
/// </value>
|
||||
[JsonIgnore]
|
||||
public List<PocketTag> Tags
|
||||
{
|
||||
get { return Utilities.DictionaryToList<PocketTag>(_TagDictionary); }
|
||||
}
|
||||
[JsonProperty("tags")]
|
||||
[JsonConverter(typeof(ObjectToArrayConverter<PocketTag>))]
|
||||
public List<PocketTag> Tags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the images.
|
||||
/// Gets or sets the images.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The images.
|
||||
/// </value>
|
||||
[JsonIgnore]
|
||||
public List<PocketImage> Images
|
||||
{
|
||||
get { return Utilities.DictionaryToList<PocketImage>(_ImageDictionary); }
|
||||
}
|
||||
[JsonProperty("images")]
|
||||
[JsonConverter(typeof(ObjectToArrayConverter<PocketImage>))]
|
||||
public List<PocketImage> Images { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the videos.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The videos.
|
||||
/// </value>
|
||||
[JsonProperty("videos")]
|
||||
[JsonConverter(typeof(ObjectToArrayConverter<PocketVideo>))]
|
||||
public List<PocketVideo> Videos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the authors.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The authors.
|
||||
/// </value>
|
||||
[JsonProperty("authors")]
|
||||
[JsonConverter(typeof(ObjectToArrayConverter<PocketAuthor>))]
|
||||
public List<PocketAuthor> Authors { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lead image.
|
||||
@@ -271,29 +250,5 @@ namespace PocketSharp.Models
|
||||
{
|
||||
get { return Images != null && Images.Count > 0 ? Images[0] : null; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the videos.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The videos.
|
||||
/// </value>
|
||||
[JsonIgnore]
|
||||
public List<PocketVideo> Videos
|
||||
{
|
||||
get { return Utilities.DictionaryToList<PocketVideo>(_VideoDictionary); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the authors.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The authors.
|
||||
/// </value>
|
||||
[JsonIgnore]
|
||||
public List<PocketAuthor> Authors
|
||||
{
|
||||
get { return Utilities.DictionaryToList<PocketAuthor>(_AuthorDictionary); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,20 +3,20 @@ using PropertyChanged;
|
||||
|
||||
namespace PocketSharp.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Tag
|
||||
/// </summary>
|
||||
[JsonObject]
|
||||
[ImplementPropertyChanged]
|
||||
public class PocketTag
|
||||
{
|
||||
/// <summary>
|
||||
/// Tag
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
[JsonObject]
|
||||
[ImplementPropertyChanged]
|
||||
public class PocketTag
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The name.
|
||||
/// </value>
|
||||
[JsonProperty("tag")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
/// <value>
|
||||
/// The name.
|
||||
/// </value>
|
||||
[JsonProperty("tag")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,38 +4,38 @@ using PropertyChanged;
|
||||
|
||||
namespace PocketSharp.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Video
|
||||
/// </summary>
|
||||
[JsonObject]
|
||||
[ImplementPropertyChanged]
|
||||
public class PocketVideo
|
||||
{
|
||||
/// <summary>
|
||||
/// Video
|
||||
/// Gets or sets the ID.
|
||||
/// </summary>
|
||||
[JsonObject]
|
||||
[ImplementPropertyChanged]
|
||||
public class PocketVideo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the ID.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The ID.
|
||||
/// </value>
|
||||
[JsonProperty("video_id")]
|
||||
public string ID { get; set; }
|
||||
/// <value>
|
||||
/// The ID.
|
||||
/// </value>
|
||||
[JsonProperty("video_id")]
|
||||
public string ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the external ID.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The external ID.
|
||||
/// </value>
|
||||
[JsonProperty("vid")]
|
||||
public string ExternalID { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the external ID.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The external ID.
|
||||
/// </value>
|
||||
[JsonProperty("vid")]
|
||||
public string ExternalID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the URI.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The URI.
|
||||
/// </value>
|
||||
[JsonProperty("src")]
|
||||
public Uri Uri { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the URI.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The URI.
|
||||
/// </value>
|
||||
[JsonProperty("src")]
|
||||
public Uri Uri { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace PocketSharp
|
||||
{
|
||||
@@ -70,4 +73,31 @@ namespace PocketSharp
|
||||
return objectType == typeof(int);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class ObjectToArrayConverter<T> : CustomCreationConverter<List<T>> where T : new()
|
||||
{
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
List<T> result = new List<T>();
|
||||
JObject jObject = JObject.Load(reader);
|
||||
T target;
|
||||
|
||||
// Populate the object properties
|
||||
foreach (KeyValuePair<string, JToken> item in jObject)
|
||||
{
|
||||
target = new T();
|
||||
serializer.Populate(item.Value.CreateReader(), target);
|
||||
result.Add(target);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override List<T> Create(Type objectType)
|
||||
{
|
||||
return new List<T>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user