-
-
Notifications
You must be signed in to change notification settings - Fork 242
/
DiscographySpecificationFixture.cs
82 lines (73 loc) · 2.87 KB
/
DiscographySpecificationFixture.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
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Music;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests
{
[TestFixture]
public class DiscographySpecificationFixture : CoreTest<DiscographySpecification>
{
private RemoteAlbum _remoteAlbum;
[SetUp]
public void Setup()
{
var artist = Builder<Artist>.CreateNew().With(s => s.Id = 1234).Build();
_remoteAlbum = new RemoteAlbum
{
ParsedAlbumInfo = new ParsedAlbumInfo
{
Discography = true
},
Albums = Builder<Album>.CreateListOfSize(3)
.All()
.With(e => e.ReleaseDate = DateTime.UtcNow.AddDays(-8))
.With(s => s.ArtistId = artist.Id)
.BuildList(),
Artist = artist,
Release = new ReleaseInfo
{
Title = "Artist.Discography.1978.2005.FLAC-RlsGrp"
}
};
Mocker.GetMock<IAlbumService>().Setup(s => s.AlbumsBetweenDates(It.IsAny<DateTime>(), It.IsAny<DateTime>(), false))
.Returns(new List<Album>());
}
[Test]
public void should_return_true_if_is_not_a_discography()
{
_remoteAlbum.ParsedAlbumInfo.Discography = false;
_remoteAlbum.Albums.Last().ReleaseDate = DateTime.UtcNow.AddDays(+2);
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
}
[Test]
public void should_return_true_if_all_albums_have_released()
{
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
}
[Test]
public void should_return_true_if_all_albums_will_have_released_in_the_next_24_hours()
{
_remoteAlbum.Albums.Last().ReleaseDate = DateTime.UtcNow.AddHours(23);
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
}
[Test]
public void should_return_false_if_one_album_has_not_released()
{
_remoteAlbum.Albums.Last().ReleaseDate = DateTime.UtcNow.AddDays(+2);
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
}
[Test]
public void should_return_false_if_an_album_does_not_have_an_release_date()
{
_remoteAlbum.Albums.Last().ReleaseDate = null;
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
}
}
}