New: Validate before deleting artist folders

This commit is contained in:
Qstick
2017-12-22 21:14:15 -05:00
parent 66d3fd17e9
commit 91afcc36c0
8 changed files with 204 additions and 5 deletions
@@ -0,0 +1,74 @@
using System;
using System.IO;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Music;
using NzbDrone.Core.Validation.Paths;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.ValidationTests
{
public class SystemFolderValidatorFixture : CoreTest<SystemFolderValidator>
{
private TestValidator<Artist> _validator;
[SetUp]
public void Setup()
{
_validator = new TestValidator<Artist>
{
v => v.RuleFor(s => s.Path).SetValidator(Subject)
};
}
[Test]
public void should_not_be_valid_if_set_to_windows_folder()
{
WindowsOnly();
var artist = Builder<Artist>.CreateNew()
.With(s => s.Path = Environment.GetFolderPath(Environment.SpecialFolder.Windows))
.Build();
_validator.Validate(artist).IsValid.Should().BeFalse();
}
[Test]
public void should_not_be_valid_if_child_of_windows_folder()
{
WindowsOnly();
var artist = Builder<Artist>.CreateNew()
.With(s => s.Path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Test"))
.Build();
_validator.Validate(artist).IsValid.Should().BeFalse();
}
[Test]
public void should_not_be_valid_if_set_to_bin_folder()
{
MonoOnly();
var artist = Builder<Artist>.CreateNew()
.With(s => s.Path = "/bin")
.Build();
_validator.Validate(artist).IsValid.Should().BeFalse();
}
[Test]
public void should_not_be_valid_if_child_of_bin_folder()
{
MonoOnly();
var artist = Builder<Artist>.CreateNew()
.With(s => s.Path = "/bin/test")
.Build();
_validator.Validate(artist).IsValid.Should().BeFalse();
}
}
}