/
GoodreadsProxySearchFixture.cs
69 lines (57 loc) · 2.17 KB
/
GoodreadsProxySearchFixture.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Http;
using NzbDrone.Core.Http;
using NzbDrone.Core.MetadataSource.Goodreads;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.MetadataSource.Goodreads
{
[TestFixture]
public class GoodreadsProxySearchFixture : CoreTest<GoodreadsSearchProxy>
{
[SetUp]
public void Setup()
{
UseRealHttp();
Mocker.GetMock<ICachedHttpResponseService>()
.Setup(x => x.Get<List<SearchJsonResource>>(It.IsAny<HttpRequest>(), It.IsAny<bool>(), It.IsAny<TimeSpan>()))
.Returns((HttpRequest request, bool useCache, TimeSpan ttl) => Mocker.Resolve<IHttpClient>().Get<List<SearchJsonResource>>(request));
}
[TestCase("Robert Harris", 575)]
[TestCase("Lyndsay Ely", 8056539)]
[TestCase("Elisa Puricelli Guerra", 4481805)]
public void successful_author_search(string title, int expected)
{
var result = Subject.Search(title);
result.Should().NotBeEmpty();
result[0].Author.Id.Should().Be(expected);
ExceptionVerification.IgnoreWarns();
}
[TestCase("Harry Potter and the sorcerer's stone a summary of the novel", 23314781)]
[TestCase("B0192CTMYG", 61209488)]
[TestCase("9780439554930", 48517161)]
public void successful_book_search(string title, int expected)
{
var result = Subject.Search(title);
result.Should().NotBeEmpty();
result[0].BookId.Should().Be(expected);
ExceptionVerification.IgnoreWarns();
}
[TestCase("readarrid:")]
[TestCase("readarrid: 99999999999999999999")]
[TestCase("readarrid: 0")]
[TestCase("readarrid: -12")]
[TestCase("readarrid: aaaa")]
[TestCase("adjalkwdjkalwdjklawjdlKAJD")]
public void no_author_search_result(string term)
{
var result = Subject.Search(term);
result.Should().BeEmpty();
ExceptionVerification.IgnoreWarns();
}
}
}