2011-06-18 17:19:24 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2011-10-15 18:36:09 +00:00
|
|
|
|
using System.Linq;
|
2011-06-18 17:19:24 +00:00
|
|
|
|
using System.Net;
|
|
|
|
|
using System.ServiceModel.Syndication;
|
|
|
|
|
using AutoMoq;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
|
using NzbDrone.Core.Providers.Indexer;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
|
public class FluentTest : TestBase
|
|
|
|
|
{
|
|
|
|
|
[TestCase(null, "def", "def")]
|
|
|
|
|
[TestCase("", "def", "def")]
|
|
|
|
|
[TestCase("", 1, "1")]
|
|
|
|
|
[TestCase(null, "", "")]
|
|
|
|
|
[TestCase("actual", "def", "actual")]
|
|
|
|
|
public void WithDefault_success(string actual, object defaultValue, string result)
|
|
|
|
|
{
|
|
|
|
|
actual.WithDefault(defaultValue).Should().Be(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
[ExpectedException(typeof(ArgumentNullException))]
|
|
|
|
|
public void WithDefault_Fail()
|
|
|
|
|
{
|
|
|
|
|
"test".WithDefault(null);
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-28 17:12:53 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void ToBestDateTime_Yesterday()
|
|
|
|
|
{
|
|
|
|
|
var dateTime = DateTime.Today.AddDays(-1);
|
|
|
|
|
|
|
|
|
|
dateTime.ToBestDateString().Should().Be("Yesterday");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ToBestDateTime_Today()
|
|
|
|
|
{
|
|
|
|
|
var dateTime = DateTime.Today;
|
|
|
|
|
|
|
|
|
|
dateTime.ToBestDateString().Should().Be("Today");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ToBestDateTime_Tomorrow()
|
|
|
|
|
{
|
|
|
|
|
var dateTime = DateTime.Today.AddDays(1);
|
|
|
|
|
|
|
|
|
|
dateTime.ToBestDateString().Should().Be("Tomorrow");
|
|
|
|
|
}
|
2011-06-18 17:19:24 +00:00
|
|
|
|
|
2011-09-28 17:12:53 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void ToBestDateTime_DayOfWeek()
|
|
|
|
|
{
|
|
|
|
|
for (int i = 2; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
var dateTime = DateTime.Today.AddDays(i);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(dateTime.DayOfWeek);
|
|
|
|
|
dateTime.ToBestDateString().Should().Be(dateTime.DayOfWeek.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ToBestDateTime_Over_One_Week()
|
|
|
|
|
{
|
|
|
|
|
var dateTime = DateTime.Today.AddDays(8);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(dateTime.DayOfWeek);
|
|
|
|
|
dateTime.ToBestDateString().Should().Be(dateTime.ToShortDateString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ToBestDateTime_Before_Yesterday()
|
|
|
|
|
{
|
|
|
|
|
var dateTime = DateTime.Today.AddDays(-2);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(dateTime.DayOfWeek);
|
|
|
|
|
dateTime.ToBestDateString().Should().Be(dateTime.ToShortDateString());
|
|
|
|
|
}
|
2011-10-15 18:36:09 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void FreeDiskSpace()
|
|
|
|
|
{
|
|
|
|
|
//Checks to ensure that the free space on the first is greater than 0 (It should be in 99.99999999999999% of cases... I hope)
|
|
|
|
|
var di = DriveInfo.GetDrives().First().RootDirectory;
|
|
|
|
|
di.FreeDiskSpace().Should().BeGreaterThan(0);
|
|
|
|
|
}
|
2011-06-18 17:19:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|