fixed some tests.

pull/23/head
kay.one 12 years ago
parent a6a4932b44
commit ada326af59

@ -47,7 +47,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
private void GivenSpecifications(params Mock<IDecisionEngineSpecification>[] mocks) private void GivenSpecifications(params Mock<IDecisionEngineSpecification>[] mocks)
{ {
Mocker.SetConstant(mocks.Select(c => c.Object)); Mocker.SetConstant<IEnumerable<IRejectWithReason>>(mocks.Select(c => c.Object));
} }
[Test] [Test]
@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3); GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3);
Subject.GetRssDecision(_parseResults); Subject.GetRssDecision(_parseResults).ToList();
_fail1.Verify(c => c.IsSatisfiedBy(_parseResults[0]), Times.Once()); _fail1.Verify(c => c.IsSatisfiedBy(_parseResults[0]), Times.Once());
_fail2.Verify(c => c.IsSatisfiedBy(_parseResults[0]), Times.Once()); _fail2.Verify(c => c.IsSatisfiedBy(_parseResults[0]), Times.Once());

@ -1,27 +1,18 @@
 using System;
using System.Linq;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions; using FluentAssertions;
using Moq;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests namespace NzbDrone.Core.Test.DecisionEngineTests
{ {
[TestFixture] [TestFixture]
public class AllowedReleaseGroupSpecificationFixture : CoreTest public class AllowedReleaseGroupSpecificationFixture : CoreTest<AllowedReleaseGroupSpecification>
{ {
private EpisodeParseResult parseResult; private EpisodeParseResult parseResult;
@ -43,29 +34,25 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test] [Test]
public void should_be_true_when_allowedReleaseGroups_is_empty() public void should_be_true_when_allowedReleaseGroups_is_empty()
{ {
//Mocker.GetMock<IConfigService>().SetupGet(s => s.AllowedReleaseGroups).Returns(String.Empty); Subject.IsSatisfiedBy(parseResult).Should().BeTrue();
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
} }
[Test] [Test]
public void should_be_true_when_allowedReleaseGroups_is_nzbs_releaseGroup() public void should_be_true_when_allowedReleaseGroups_is_nzbs_releaseGroup()
{ {
//Mocker.GetMock<IConfigService>().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD"); Subject.IsSatisfiedBy(parseResult).Should().BeTrue();
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
} }
[Test] [Test]
public void should_be_true_when_allowedReleaseGroups_contains_nzbs_releaseGroup() public void should_be_true_when_allowedReleaseGroups_contains_nzbs_releaseGroup()
{ {
//Mocker.GetMock<IConfigService>().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD, LOL"); Subject.IsSatisfiedBy(parseResult).Should().BeTrue();
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
} }
[Test] [Test]
public void should_be_false_when_allowedReleaseGroups_does_not_contain_nzbs_releaseGroup() public void should_be_false_when_allowedReleaseGroups_does_not_contain_nzbs_releaseGroup()
{ {
//Mocker.GetMock<IConfigService>().SetupGet(s => s.AllowedReleaseGroups).Returns("LOL,DTD"); Subject.IsSatisfiedBy(parseResult).Should().BeFalse();
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeFalse();
} }
} }
} }

@ -12,7 +12,7 @@ using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.Download.DownloadClientTests namespace NzbDrone.Core.Test.Download.DownloadClientTests
{ {
[TestFixture] [TestFixture]
public class BlackholeProviderFixture : CoreTest public class BlackholeProviderFixture : CoreTest<BlackholeProvider>
{ {
private const string nzbUrl = "http://www.nzbs.com/url"; private const string nzbUrl = "http://www.nzbs.com/url";
private const string title = "some_nzb_title"; private const string title = "some_nzb_title";
@ -39,9 +39,9 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
[Test] [Test]
public void DownloadNzb_should_download_file_if_it_doesnt_exist() public void DownloadNzb_should_download_file_if_it_doesnt_exist()
{ {
Mocker.Resolve<BlackholeProvider>().DownloadNzb(nzbUrl, title, false).Should().BeTrue(); Subject.DownloadNzb(nzbUrl, title, false).Should().BeTrue();
Mocker.GetMock<HttpProvider>().Verify(c => c.DownloadFile(nzbUrl, nzbPath),Times.Once()); Mocker.GetMock<HttpProvider>().Verify(c => c.DownloadFile(nzbUrl, nzbPath), Times.Once());
} }
[Test] [Test]
@ -49,7 +49,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
{ {
WithExistingFile(); WithExistingFile();
Mocker.Resolve<BlackholeProvider>().DownloadNzb(nzbUrl, title, false).Should().BeTrue(); Subject.DownloadNzb(nzbUrl, title, false).Should().BeTrue();
Mocker.GetMock<HttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never()); Mocker.GetMock<HttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
} }
@ -59,8 +59,8 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
{ {
WithFailedDownload(); WithFailedDownload();
Mocker.Resolve<BlackholeProvider>().DownloadNzb(nzbUrl, title, false).Should().BeFalse(); Subject.DownloadNzb(nzbUrl, title, false).Should().BeFalse();
ExceptionVerification.ExpectedWarns(1); ExceptionVerification.ExpectedWarns(1);
} }
@ -70,7 +70,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]"; var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]";
var expectedFilename = Path.Combine(blackHoleFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb"); var expectedFilename = Path.Combine(blackHoleFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb");
Mocker.Resolve<BlackholeProvider>().DownloadNzb(nzbUrl, illegalTitle, false).Should().BeTrue(); Subject.DownloadNzb(nzbUrl, illegalTitle, false).Should().BeTrue();
Mocker.GetMock<HttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once()); Mocker.GetMock<HttpProvider>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename), Times.Once());
} }

@ -230,6 +230,10 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="..\Libraries\Sqlite\sqlite3.dll">
<Link>sqlite3.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="App_Data\Config.xml"> <Content Include="App_Data\Config.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
@ -260,9 +264,6 @@
<Content Include="Files\JsonError.txt"> <Content Include="Files\JsonError.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Include="SQLite.Interop.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Files\RSS\nzbx_search.json"> <None Include="Files\RSS\nzbx_search.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
@ -355,7 +356,8 @@
</PreBuildEvent> </PreBuildEvent>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<PostBuildEvent>xcopy /s /y "$(SolutionDir)\Libraries\Sqlite\*.*" "$(TargetDir)"</PostBuildEvent> <PostBuildEvent>
</PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\nuget.targets" /> <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

Loading…
Cancel
Save