You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
55 lines
1.6 KiB
using System.IO.Abstractions;
|
|
using System.IO.Abstractions.Extensions;
|
|
using System.IO.Abstractions.TestingHelpers;
|
|
using AutoFixture.NUnit3;
|
|
using CliFx.Infrastructure;
|
|
using FluentAssertions;
|
|
using NSubstitute;
|
|
using NUnit.Framework;
|
|
using Recyclarr.Command;
|
|
using TestLibrary.AutoFixture;
|
|
using TrashLib;
|
|
|
|
// ReSharper disable MethodHasAsyncOverload
|
|
|
|
namespace Recyclarr.Tests.Command;
|
|
|
|
[TestFixture]
|
|
[Parallelizable(ParallelScope.All)]
|
|
public class CreateConfigCommandTest
|
|
{
|
|
[Test, AutoMockData]
|
|
public async Task Config_file_created_when_using_default_path(
|
|
[Frozen] IAppPaths paths,
|
|
[Frozen(Matching.ImplementedInterfaces)] MockFileSystem fs,
|
|
CreateConfigCommand cmd)
|
|
{
|
|
const string ymlPath = "path/recyclarr.yml";
|
|
paths.ConfigPath.Returns(ymlPath);
|
|
await cmd.ExecuteAsync(Substitute.For<IConsole>());
|
|
|
|
var file = fs.GetFile(ymlPath);
|
|
file.Should().NotBeNull();
|
|
file.Contents.Should().NotBeEmpty();
|
|
}
|
|
|
|
[Test, AutoMockData]
|
|
public async Task Config_file_created_when_using_user_specified_path(
|
|
[Frozen] IAppPaths paths,
|
|
[Frozen(Matching.ImplementedInterfaces)] MockFileSystem fs,
|
|
CreateConfigCommand cmd)
|
|
{
|
|
var ymlPath = fs.CurrentDirectory()
|
|
.SubDirectory("user")
|
|
.SubDirectory("specified")
|
|
.File("file.yml").FullName;
|
|
|
|
cmd.Path = ymlPath;
|
|
await cmd.ExecuteAsync(Substitute.For<IConsole>());
|
|
|
|
var file = fs.GetFile(ymlPath);
|
|
file.Should().NotBeNull();
|
|
file.Contents.Should().NotBeEmpty();
|
|
}
|
|
}
|