2013-10-01 23:26:28 +02:00
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Xunit;
|
|
|
|
|
using PocketSharp.Models;
|
2013-10-27 13:27:45 +01:00
|
|
|
using System.Diagnostics;
|
2013-10-01 23:26:28 +02:00
|
|
|
|
|
|
|
|
namespace PocketSharp.Tests
|
|
|
|
|
{
|
|
|
|
|
public class ReadTests : TestsBase
|
|
|
|
|
{
|
2013-10-17 14:17:48 +02:00
|
|
|
private PocketReader reader;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ReadTests() : base()
|
|
|
|
|
{
|
|
|
|
|
reader = new PocketReader();
|
|
|
|
|
}
|
2013-10-01 23:26:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2013-10-17 14:17:48 +02:00
|
|
|
public async Task ReadArticleTest()
|
2013-10-01 23:26:28 +02:00
|
|
|
{
|
2013-10-17 14:17:48 +02:00
|
|
|
PocketArticle result = await reader.Read(new PocketItem()
|
|
|
|
|
{
|
|
|
|
|
ID = 99,
|
|
|
|
|
Uri = new Uri("http://frontendplay.com/story/4/http-caching-demystified-part-2-implementation")
|
|
|
|
|
});
|
2013-10-01 23:26:28 +02:00
|
|
|
|
2013-10-17 14:17:48 +02:00
|
|
|
Assert.True(result.Content.Length > 15000);
|
|
|
|
|
}
|
2013-10-01 23:26:28 +02:00
|
|
|
|
2013-10-17 14:17:48 +02:00
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task ReadArticleWithInvalidUriTest()
|
|
|
|
|
{
|
|
|
|
|
await ThrowsAsync<PocketException>(async () =>
|
|
|
|
|
{
|
|
|
|
|
await reader.Read(new PocketItem()
|
|
|
|
|
{
|
|
|
|
|
ID = 99,
|
|
|
|
|
Uri = new Uri("http://frontendplayyyyy.com")
|
|
|
|
|
});
|
|
|
|
|
});
|
2013-10-01 23:26:28 +02:00
|
|
|
}
|
2013-10-27 13:27:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task IsBodyOnlyProperlyResolved()
|
|
|
|
|
{
|
|
|
|
|
PocketArticle result = await reader.Read(new PocketItem()
|
|
|
|
|
{
|
|
|
|
|
ID = 99,
|
|
|
|
|
Uri = new Uri("http://calebjacob.com/tooltipster/")
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Assert.True(result.Content.Substring(0, 4) == "<div");
|
|
|
|
|
}
|
2013-10-01 23:26:28 +02:00
|
|
|
}
|
|
|
|
|
}
|