From b7b92d87ed8b6625bdc8de8b010ef940b0795366 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Wed, 2 Jul 2014 15:31:38 +0200 Subject: [PATCH] sliiim --- PocketSharp.Tests/GetTests.cs | 32 ++++++------ PocketSharp.Tests/StressTests.cs | 24 +++++++-- PocketSharp/Models/PocketItem.cs | 66 ------------------------- PocketSharp/Utilities/JsonExtensions.cs | 2 +- 4 files changed, 36 insertions(+), 88 deletions(-) diff --git a/PocketSharp.Tests/GetTests.cs b/PocketSharp.Tests/GetTests.cs index 9aca240..beeff98 100644 --- a/PocketSharp.Tests/GetTests.cs +++ b/PocketSharp.Tests/GetTests.cs @@ -33,23 +33,23 @@ namespace PocketSharp.Tests Assert.True(item.Uri == itemDuplicate.Uri); } - [Fact] - public async Task IsItemJsonPopulated() - { - List items = (await client.Get()).ToList(); - string schemaJson = @"{ - 'description': 'PocketItem', - 'type': 'object' - }"; +// [Fact] +// public async Task IsItemJsonPopulated() +// { +// List items = (await client.Get()).ToList(); +// string schemaJson = @"{ +// 'description': 'PocketItem', +// 'type': 'object' +// }"; - JsonSchema schema = JsonSchema.Parse(schemaJson); - foreach (var pocketItem in items) - { - Assert.True(!string.IsNullOrWhiteSpace(pocketItem.Json)); - var jObject = JObject.Parse(pocketItem.Json); - Assert.True(jObject.IsValid(schema)); - } - } +// JsonSchema schema = JsonSchema.Parse(schemaJson); +// foreach (var pocketItem in items) +// { +// Assert.True(!string.IsNullOrWhiteSpace(pocketItem.Json)); +// var jObject = JObject.Parse(pocketItem.Json); +// Assert.True(jObject.IsValid(schema)); +// } +// } [Fact] public async Task AreFilteredItemsRetrieved() diff --git a/PocketSharp.Tests/StressTests.cs b/PocketSharp.Tests/StressTests.cs index 30fa7c1..4da2dc3 100644 --- a/PocketSharp.Tests/StressTests.cs +++ b/PocketSharp.Tests/StressTests.cs @@ -105,13 +105,27 @@ namespace PocketSharp.Tests string[] tag; Random rnd = new Random(); - foreach (string url in urls.Skip(offset).Take(count)) + var items = urls.Skip(offset).Take(count) + .Select((value, idx) => new { Value = value, Index = idx }) + .GroupBy(item => item.Index / 100, item => item.Value) + .Cast>(); + + foreach (IEnumerable urlGroup in items) { - r = rnd.Next(tags.Length); - r2 = rnd.Next(tags.Length); - tag = new string[] { tags[r], tags[r2] }; - await client.Add(new Uri("http://" + url), tag); + await Task.WhenAll(urlGroup.Select(url => + { + r = rnd.Next(tags.Length); + r2 = rnd.Next(tags.Length); + tag = new string[] { tags[r], tags[r2] }; + return client.Add(new Uri("http://" + url), tag); + })); } } + + [Fact] + public async Task Fillll() + { + await FillAccount(11000, 89999); + } } } \ No newline at end of file diff --git a/PocketSharp/Models/PocketItem.cs b/PocketSharp/Models/PocketItem.cs index 197c664..a0df39c 100644 --- a/PocketSharp/Models/PocketItem.cs +++ b/PocketSharp/Models/PocketItem.cs @@ -168,15 +168,6 @@ namespace PocketSharp.Models [JsonProperty("is_article")] public bool IsArticle { get; set; } - /// - /// Gets or sets a value indicating whether this instance has image. - /// - /// - /// true if this instance has image; otherwise, false. - /// - [JsonProperty("has_image")] - private PocketBoolean? _HasImage { get; set; } - /// /// Gets or sets a value indicating whether this instance has video. /// @@ -186,21 +177,6 @@ namespace PocketSharp.Models [JsonProperty("has_video")] private PocketBoolean? _HasVideo { get; set; } - /// - /// Gets a value indicating whether [has image]. - /// - /// - /// true if [has image]; otherwise, false. - /// - [JsonIgnore] - public bool HasImage - { - get - { - return _HasImage == PocketBoolean.Yes || _HasImage == PocketBoolean.IsType; - } - } - /// /// Gets a value indicating whether [has video]. /// @@ -231,21 +207,6 @@ namespace PocketSharp.Models } } - /// - /// Gets a value indicating whether [is image]. - /// - /// - /// true if [is image]; otherwise, false. - /// - [JsonIgnore] - public bool IsImage - { - get - { - return _HasImage == PocketBoolean.IsType; - } - } - /// /// Gets or sets the word count. /// @@ -283,24 +244,6 @@ namespace PocketSharp.Models [JsonProperty("time_updated")] public DateTime? UpdateTime { get; set; } - /// - /// Gets or sets the read time. - /// - /// - /// The read time. - /// - [JsonProperty("time_read")] - public DateTime? ReadTime { get; set; } - - /// - /// Gets or sets the favorite time. - /// - /// - /// The favorite time. - /// - [JsonProperty("time_favorited")] - public DateTime? FavoriteTime { get; set; } - /// /// Gets or sets the tags as comma-separated strings. /// @@ -365,15 +308,6 @@ namespace PocketSharp.Models get { return Images != null && Images.Count() > 0 ? Images.First() : null; } } - /// - /// Gets and sets the JSON the model was deserialized from - /// - /// - /// Model's original JSON representation - /// - [JsonIgnore] - public string Json { get; set; } - /// /// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. /// diff --git a/PocketSharp/Utilities/JsonExtensions.cs b/PocketSharp/Utilities/JsonExtensions.cs index 0a4e55a..79c1966 100644 --- a/PocketSharp/Utilities/JsonExtensions.cs +++ b/PocketSharp/Utilities/JsonExtensions.cs @@ -190,7 +190,7 @@ namespace PocketSharp var jObject = JObject.ReadFrom(reader); var pocketItem = new PocketItem(); serializer.Populate(jObject.CreateReader(), pocketItem); - pocketItem.Json = jObject.ToString(); + //pocketItem.Json = jObject.ToString(); return pocketItem; }