2011-01-29 07:10:22 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Gallio.Framework;
|
|
|
|
|
using MbUnit.Framework;
|
|
|
|
|
using MbUnit.Framework.ContractVerifiers;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
2011-04-04 05:50:12 +02:00
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-01-29 07:10:22 +01:00
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using SubSonic.Repository;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class IndexerProviderTest
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void AllIndexers()
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// TODO: Add test logic here
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
//Setup
|
|
|
|
|
var list = new List<Indexer>();
|
2011-01-29 21:03:47 +01:00
|
|
|
|
list.Add(new Indexer { IndexerName = "Test1", RssUrl = "http://www.test1.com/rss.php", Enabled = true, Order = 1 });
|
|
|
|
|
list.Add(new Indexer { IndexerName = "Test2", RssUrl = "http://www.test2.com/rss.php", Enabled = false, Order = 4 });
|
|
|
|
|
list.Add(new Indexer { IndexerName = "Test3", RssUrl = "http://www.test3.com/rss.php", Enabled = true, Order = 3 });
|
|
|
|
|
list.Add(new Indexer { IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2 });
|
2011-01-29 07:10:22 +01:00
|
|
|
|
|
|
|
|
|
var repo = new Mock<IRepository>();
|
2011-03-17 08:40:23 +01:00
|
|
|
|
var config = new Mock<IConfigProvider>();
|
2011-01-29 07:10:22 +01:00
|
|
|
|
repo.Setup(r => r.All<Indexer>()).Returns(list.AsQueryable());
|
|
|
|
|
|
2011-03-17 08:40:23 +01:00
|
|
|
|
var target = new IndexerProvider(repo.Object, config.Object);
|
2011-01-29 07:10:22 +01:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = target.AllIndexers();
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
|
2011-01-29 21:03:47 +01:00
|
|
|
|
Assert.AreEqual(result.Last().IndexerName, "Test2");
|
2011-01-29 07:10:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void EnabledIndexers()
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
// TODO: Add test logic here
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
//Setup
|
|
|
|
|
var list = new List<Indexer>();
|
2011-01-29 21:03:47 +01:00
|
|
|
|
list.Add(new Indexer { IndexerName = "Test1", RssUrl = "http://www.test1.com/rss.php", Enabled = true, Order = 1 });
|
|
|
|
|
list.Add(new Indexer { IndexerName = "Test2", RssUrl = "http://www.test2.com/rss.php", Enabled = false, Order = 4 });
|
|
|
|
|
list.Add(new Indexer { IndexerName = "Test3", RssUrl = "http://www.test3.com/rss.php", Enabled = true, Order = 3 });
|
|
|
|
|
list.Add(new Indexer { IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2 });
|
2011-01-29 07:10:22 +01:00
|
|
|
|
|
|
|
|
|
var repo = new Mock<IRepository>();
|
2011-03-17 08:40:23 +01:00
|
|
|
|
var config = new Mock<IConfigProvider>();
|
2011-01-29 07:10:22 +01:00
|
|
|
|
repo.Setup(r => r.All<Indexer>()).Returns(list.AsQueryable());
|
|
|
|
|
|
2011-03-17 08:40:23 +01:00
|
|
|
|
var target = new IndexerProvider(repo.Object, config.Object);
|
2011-01-29 07:10:22 +01:00
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = target.EnabledIndexers();
|
|
|
|
|
|
|
|
|
|
//Assert
|
2011-01-29 21:03:47 +01:00
|
|
|
|
Assert.AreEqual(result.First().IndexerName, "Test1");
|
|
|
|
|
Assert.AreEqual(result.Last().IndexerName, "Test3");
|
2011-01-29 07:10:22 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|