Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/RipSharp.Tests/Core/ConfigFileLocatorTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.IO;

using AwesomeAssertions;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Core;
namespace RipSharp.Tests.Core;

public class ConfigFileLocatorTests
{
Expand Down
131 changes: 131 additions & 0 deletions src/RipSharp.Tests/Core/PrerequisiteCheckerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
namespace RipSharp.Tests.Core;

public class PrerequisiteCheckerTests
{
[Fact]
public void GetMissingTools_WhenPathIsEmpty_ReturnsAllRequiredTools()
{
var missing = PrerequisiteChecker.GetMissingTools(null, isWindows: false, _ => false);

missing.Should().Contain(PrerequisiteChecker.RequiredTools);
}

[Theory]
[MemberData(nameof(NonWindowsAllPresentCases))]
public void GetMissingTools_WhenNonWindowsPathsContainTools_ReturnsNoneMissing(string pathValue, string[] existingFiles)
{
var missing = PrerequisiteChecker.GetMissingTools(pathValue, isWindows: false, CreateSet(existingFiles).Contains);

missing.Should().BeEmpty();
}

[Theory]
[MemberData(nameof(NonWindowsMissingCases))]
public void GetMissingTools_WhenNonWindowsMissingTool_ReturnsMissingTool(string pathValue, string[] existingFiles, string expectedMissing)
{
var missing = PrerequisiteChecker.GetMissingTools(pathValue, isWindows: false, CreateSet(existingFiles).Contains);

missing.Should().ContainSingle().Which.Should().Be(expectedMissing);
}

[Theory]
[MemberData(nameof(WindowsAllPresentCases))]
public void GetMissingTools_WhenWindowsPathsContainExecutableExtensions_ReturnsNoneMissing(string pathValue, string[] existingFiles)
{
var missing = PrerequisiteChecker.GetMissingTools(pathValue, isWindows: true, CreateSet(existingFiles).Contains);

missing.Should().BeEmpty();
}

[Theory]
[MemberData(nameof(WindowsMissingCases))]
public void GetMissingTools_WhenWindowsMissingTool_ReturnsMissingTool(string pathValue, string[] existingFiles, string expectedMissing)
{
var missing = PrerequisiteChecker.GetMissingTools(pathValue, isWindows: true, CreateSet(existingFiles).Contains);

missing.Should().ContainSingle().Which.Should().Be(expectedMissing);
}

public static IEnumerable<object[]> NonWindowsAllPresentCases()
{
yield return new object[]
{
BuildPath("/usr/local/bin", "/usr/bin"),
new[] { Path.Combine("/usr/bin", "makemkvcon"), Path.Combine("/usr/local/bin", "ffmpeg") }
};

yield return new object[]
{
BuildPath("/usr/bin", "/opt/bin"),
new[] { Path.Combine("/usr/bin", "makemkvcon"), Path.Combine("/opt/bin", "ffmpeg") }
};

yield return new object[]
{
BuildPath("/opt/homebrew/bin", "/usr/local/bin"),
new[] { Path.Combine("/opt/homebrew/bin", "ffmpeg"), Path.Combine("/usr/local/bin", "makemkvcon") }
};
}

public static IEnumerable<object[]> NonWindowsMissingCases()
{
yield return new object[]
{
BuildPath("/usr/bin", "/opt/bin"),
new[] { Path.Combine("/opt/bin", "ffmpeg") },
"makemkvcon"
};

yield return new object[]
{
BuildPath("/usr/bin", "/opt/bin"),
new[] { Path.Combine("/usr/bin", "makemkvcon") },
"ffmpeg"
};

yield return new object[]
{
BuildPath("/opt/homebrew/bin", "/usr/local/bin"),
new[] { Path.Combine("/opt/homebrew/bin", "ffmpeg") },
"makemkvcon"
};
}

public static IEnumerable<object[]> WindowsAllPresentCases()
{
var baseDir = Path.Combine("C_Tools");
yield return new object[]
{
BuildPath(baseDir),
new[] { Path.Combine(baseDir, "makemkvcon.exe"), Path.Combine(baseDir, "ffmpeg.cmd") }
};
}

public static IEnumerable<object[]> WindowsMissingCases()
{
var baseDir = Path.Combine("C_Tools");
yield return new object[]
{
BuildPath(baseDir),
new[] { Path.Combine(baseDir, "makemkvcon.exe") },
"ffmpeg"
};

yield return new object[]
{
BuildPath(baseDir),
new[] { Path.Combine(baseDir, "ffmpeg.exe") },
"makemkvcon"
};
}

private static string BuildPath(params string[] parts)
{
return string.Join(Path.PathSeparator, parts);
}

private static HashSet<string> CreateSet(IEnumerable<string> paths)
{
return new HashSet<string>(paths, StringComparer.OrdinalIgnoreCase);
}
}
11 changes: 1 addition & 10 deletions src/RipSharp.Tests/Core/RipOptionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
using System;
using System.IO;

using AwesomeAssertions;

using BugZapperLabs.RipSharp;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Core;
namespace RipSharp.Tests.Core;

public class RipOptionsTests
{
Expand Down
4 changes: 4 additions & 0 deletions src/RipSharp.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
global using BugZapperLabs.RipSharp.Models;
global using BugZapperLabs.RipSharp.Services;
global using BugZapperLabs.RipSharp.Utilities;

global using NSubstitute;

global using Xunit;
6 changes: 1 addition & 5 deletions src/RipSharp.Tests/MakeMkv/MakeMkvProtocolTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using AwesomeAssertions;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.MakeMkv;
namespace RipSharp.Tests.MakeMkv;

public class MakeMkvProtocolTests
{
Expand Down
12 changes: 1 addition & 11 deletions src/RipSharp.Tests/Metadata/MetadataServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

using AwesomeAssertions;

using NSubstitute;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Metadata;
namespace RipSharp.Tests.Metadata;

public class MetadataServiceTests : IDisposable
{
Expand Down
12 changes: 1 addition & 11 deletions src/RipSharp.Tests/Metadata/OmdbMetadataProviderTests.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
using System;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

using AwesomeAssertions;

using NSubstitute;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Metadata;
namespace RipSharp.Tests.Metadata;

public class OmdbMetadataProviderTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Collections.Generic;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Metadata;
namespace RipSharp.Tests.Metadata;

public class TitleVariationGeneratorEdgeCasesTests
{
Expand Down
6 changes: 1 addition & 5 deletions src/RipSharp.Tests/Metadata/TitleVariationGeneratorTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Collections.Generic;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Metadata;
namespace RipSharp.Tests.Metadata;

public class TitleVariationGeneratorTests
{
Expand Down
12 changes: 1 addition & 11 deletions src/RipSharp.Tests/Metadata/TmdbMetadataProviderTests.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
using System;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

using AwesomeAssertions;

using NSubstitute;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Metadata;
namespace RipSharp.Tests.Metadata;

public class TmdbMetadataProviderTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Reflection;

using AwesomeAssertions;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Services;
namespace RipSharp.Tests.Services;

public class DiscRipperOverallProgressTests
{
Expand Down
7 changes: 1 addition & 6 deletions src/RipSharp.Tests/Services/DiscRipperRipSummaryTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Reflection;

using AwesomeAssertions;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Services;
namespace RipSharp.Tests.Services;

public class DiscRipperRipSummaryTests
{
Expand Down
12 changes: 1 addition & 11 deletions src/RipSharp.Tests/Services/DiscRipperTitleSuffixTests.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

using AwesomeAssertions;

using NSubstitute;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Services;
namespace RipSharp.Tests.Services;

public class DiscRipperTitleSuffixTests
{
Expand Down
6 changes: 1 addition & 5 deletions src/RipSharp.Tests/Services/DiscTypeDetectorTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Collections.Generic;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Services;
namespace RipSharp.Tests.Services;

public class DiscTypeDetectorTests
{
Expand Down
2 changes: 1 addition & 1 deletion src/RipSharp.Tests/Utilities/CursorManagerTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BugZapperLabs.RipSharp.Tests.Utilities;
namespace RipSharp.Tests.Utilities;

public class CursorManagerTests
{
Expand Down
6 changes: 1 addition & 5 deletions src/RipSharp.Tests/Utilities/DurationFormatterTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using AwesomeAssertions;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Utilities;
namespace RipSharp.Tests.Utilities;

public class DurationFormatterTests
{
Expand Down
8 changes: 1 addition & 7 deletions src/RipSharp.Tests/Utilities/FileNamingTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System.IO;

using AwesomeAssertions;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Utilities;
namespace RipSharp.Tests.Utilities;

public class FileNamingTests
{
Expand Down
7 changes: 1 addition & 6 deletions src/RipSharp.Tests/Utilities/SpectreProgressDisplayTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Reflection;

using AwesomeAssertions;

using Xunit;

namespace BugZapperLabs.RipSharp.Tests.Utilities;
namespace RipSharp.Tests.Utilities;

public class SpectreProgressDisplayTests
{
Expand Down
4 changes: 0 additions & 4 deletions src/RipSharp/Abstractions/IMakeMkvService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Threading;
using System.Threading.Tasks;

namespace BugZapperLabs.RipSharp.Abstractions;

public interface IMakeMkvService
Expand Down
2 changes: 0 additions & 2 deletions src/RipSharp/Abstractions/IMetadataProvider.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Threading.Tasks;

namespace BugZapperLabs.RipSharp.Abstractions;

public interface IMetadataProvider
Expand Down
2 changes: 0 additions & 2 deletions src/RipSharp/Abstractions/ITvEpisodeTitleProvider.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Threading.Tasks;

namespace BugZapperLabs.RipSharp.Abstractions;

public interface ITvEpisodeTitleProvider
Expand Down
2 changes: 0 additions & 2 deletions src/RipSharp/Core/AppConfig.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Microsoft.Extensions.Configuration;

namespace BugZapperLabs.RipSharp.Core;

public class AppConfig
Expand Down
3 changes: 0 additions & 3 deletions src/RipSharp/Core/ConfigFileLocator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;

namespace BugZapperLabs.RipSharp.Core;
Expand Down
Loading