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
This commit is contained in:
@@ -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<PocketItem> 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()
|
||||
|
||||
@@ -45,6 +45,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.165\lib\net45\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
<package id="Microsoft.Bcl.Async" version="1.0.165" targetFramework="net45" />
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="net45" />
|
||||
<package id="Microsoft.Net.Http" version="2.2.18" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
|
||||
<package id="xunit" version="1.9.2" targetFramework="net45" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user