forked from samjudson/flickr-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
136 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,124 +1,136 @@ | ||
using System; | ||
using System.Text; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
using FlickrNet; | ||
using System.Reactive.Subjects; | ||
using System.Reactive.Linq; | ||
|
||
namespace FlickrNetTest.Async | ||
{ | ||
[TestFixture] | ||
[Category("AccessTokenRequired")] | ||
public class StatsAsyncTests | ||
{ | ||
[Test] | ||
public void StatsGetCollectionDomainsAsyncTest() | ||
{ | ||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<StatDomainCollection>>(); | ||
f.StatsGetCollectionDomainsAsync(d, 1, 25, r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
Assert.IsFalse(result.HasError); | ||
} | ||
|
||
[Test] | ||
public void StatsGetPhotoDomainsAsyncTest() | ||
{ | ||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<StatDomainCollection>>(); | ||
f.StatsGetPhotoDomainsAsync(d, 1, 25, r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
Assert.IsFalse(result.HasError); | ||
} | ||
|
||
[Test] | ||
public void StatsGetPhotostreamDomainsAsyncTest() | ||
{ | ||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<StatDomainCollection>>(); | ||
f.StatsGetPhotostreamDomainsAsync(d, 1, 25, r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
Assert.IsFalse(result.HasError); | ||
} | ||
|
||
[Test] | ||
public void StatsGetPhotosetDomainsAsyncTest() | ||
{ | ||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<StatDomainCollection>>(); | ||
f.StatsGetPhotosetDomainsAsync(d, 1, 25, r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
Assert.IsFalse(result.HasError); | ||
} | ||
|
||
|
||
[Test] | ||
public void StatsGetCollectionStatsAsyncTest() | ||
{ | ||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
var collection = f.CollectionsGetTree().First(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<Stats>>(); | ||
f.StatsGetCollectionStatsAsync(d, collection.CollectionId, r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
Assert.IsFalse(result.HasError); | ||
|
||
} | ||
|
||
[Test] | ||
public void StatsGetPhotoStatsAsyncTest() | ||
{ | ||
Flickr.CacheDisabled = true; | ||
|
||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<Stats>>(); | ||
f.StatsGetPhotoStatsAsync(d, "7176125763", r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
if (result.HasError) throw result.Error; | ||
|
||
Assert.IsFalse(result.HasError); | ||
} | ||
|
||
[Test] | ||
public void StatsGetPhotostreamStatsAsyncTest() | ||
{ | ||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<Stats>>(); | ||
f.StatsGetPhotostreamStatsAsync(d, r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
Assert.IsFalse(result.HasError); | ||
|
||
Assert.IsTrue(result.Result.Views > 0, "Views should be greater than 0"); | ||
} | ||
} | ||
} | ||
using System; | ||
using System.Text; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
using FlickrNet; | ||
using System.Reactive.Subjects; | ||
using System.Reactive.Linq; | ||
using Shouldly; | ||
|
||
namespace FlickrNetTest.Async | ||
{ | ||
[TestFixture] | ||
[Category("AccessTokenRequired")] | ||
public class StatsAsyncTests | ||
{ | ||
[Test] | ||
public void StatsGetCollectionDomainsAsyncTest() | ||
{ | ||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<StatDomainCollection>>(); | ||
f.StatsGetCollectionDomainsAsync(d, 1, 25, r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
Assert.IsFalse(result.HasError); | ||
} | ||
|
||
[Test] | ||
public void StatsGetPhotoDomainsAsyncTest() | ||
{ | ||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<StatDomainCollection>>(); | ||
f.StatsGetPhotoDomainsAsync(d, 1, 25, r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
Assert.IsFalse(result.HasError); | ||
} | ||
|
||
[Test] | ||
public void StatsGetPhotostreamDomainsAsyncTest() | ||
{ | ||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<StatDomainCollection>>(); | ||
f.StatsGetPhotostreamDomainsAsync(d, 1, 25, r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
Assert.IsFalse(result.HasError); | ||
} | ||
|
||
[Test] | ||
public void StatsGetPhotosetDomainsAsyncTest() | ||
{ | ||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<StatDomainCollection>>(); | ||
f.StatsGetPhotosetDomainsAsync(d, 1, 25, r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
Assert.IsFalse(result.HasError); | ||
} | ||
|
||
|
||
[Test] | ||
public void StatsGetCollectionStatsAsyncTest() | ||
{ | ||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
var collection = f.CollectionsGetTree().First(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<Stats>>(); | ||
f.StatsGetCollectionStatsAsync(d, collection.CollectionId, r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
Assert.IsFalse(result.HasError); | ||
|
||
} | ||
|
||
[Test] | ||
public void StatsGetPhotoStatsAsyncTest() | ||
{ | ||
Flickr.CacheDisabled = true; | ||
|
||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
DateTime d = DateTime.Today.AddDays(-7); | ||
|
||
var w = new AsyncSubject<FlickrResult<Stats>>(); | ||
f.StatsGetPhotoStatsAsync(d, "7176125763", r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
if (result.HasError) throw result.Error; | ||
|
||
Assert.IsFalse(result.HasError); | ||
} | ||
|
||
[Test] | ||
public void StatsGetPhotostreamStatsAsyncTest() | ||
{ | ||
Flickr f = TestData.GetAuthInstance(); | ||
|
||
var range = Enumerable.Range(7, 5); | ||
var list = new List<Stats>(); | ||
|
||
foreach(var i in range) | ||
{ | ||
var d = DateTime.Today.AddDays(-i); | ||
|
||
var w = new AsyncSubject<FlickrResult<Stats>>(); | ||
f.StatsGetPhotostreamStatsAsync(d, r => { w.OnNext(r); w.OnCompleted(); }); | ||
|
||
var result = w.Next().First(); | ||
|
||
result.HasError.ShouldBe(false); | ||
result.Result.ShouldNotBe(null); | ||
|
||
list.Add(result.Result); | ||
} | ||
|
||
list.Count.ShouldBe(5); | ||
list.ShouldContain(s => s.Views > 0); | ||
} | ||
} | ||
} |