From ec006b298def42a5742923ec5877e3419336518d Mon Sep 17 00:00:00 2001 From: Stephen Erstad Date: Tue, 4 Mar 2014 22:35:50 -0600 Subject: [PATCH] Added test for Json property for PocketItem Tested that the Json property is set on the retrieved PocketItems and that they represent a JSON object --- PocketSharp.Tests/GetTests.cs | 21 ++++++++++++++++++++- PocketSharp.Tests/PocketSharp.Tests.csproj | 4 ++++ PocketSharp.Tests/packages.config | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/PocketSharp.Tests/GetTests.cs b/PocketSharp.Tests/GetTests.cs index 3029ac7..1d56f63 100644 --- a/PocketSharp.Tests/GetTests.cs +++ b/PocketSharp.Tests/GetTests.cs @@ -1,4 +1,6 @@ -using PocketSharp.Models; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Schema; +using PocketSharp.Models; using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -30,6 +32,23 @@ namespace PocketSharp.Tests Assert.True(item.Uri == itemDuplicate.Uri); } + [Fact] + public async Task IsItemJsonPopulated() + { + List items = await client.Get(); + 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)); + } + } [Fact] public async Task AreFilteredItemsRetrieved() diff --git a/PocketSharp.Tests/PocketSharp.Tests.csproj b/PocketSharp.Tests/PocketSharp.Tests.csproj index 3cac580..087d610 100644 --- a/PocketSharp.Tests/PocketSharp.Tests.csproj +++ b/PocketSharp.Tests/PocketSharp.Tests.csproj @@ -45,6 +45,10 @@ False ..\packages\Microsoft.Bcl.Async.1.0.165\lib\net45\Microsoft.Threading.Tasks.Extensions.dll + + False + ..\packages\Newtonsoft.Json.5.0.8\lib\net45\Newtonsoft.Json.dll + diff --git a/PocketSharp.Tests/packages.config b/PocketSharp.Tests/packages.config index 2cb6d7a..2cb5ded 100644 --- a/PocketSharp.Tests/packages.config +++ b/PocketSharp.Tests/packages.config @@ -4,5 +4,6 @@ + \ No newline at end of file