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.
47 lines
1.5 KiB
47 lines
1.5 KiB
using System.IO.Abstractions;
|
|
using System.Threading.Tasks;
|
|
using CliFx.Infrastructure;
|
|
using NSubstitute;
|
|
using NUnit.Framework;
|
|
using Serilog;
|
|
using Trash.CreateConfig;
|
|
|
|
// ReSharper disable MethodHasAsyncOverload
|
|
|
|
namespace Trash.Tests.CreateConfig
|
|
{
|
|
[TestFixture]
|
|
[Parallelizable(ParallelScope.All)]
|
|
public class CreateConfigCommandTest
|
|
{
|
|
[Test]
|
|
public async Task CreateConfig_DefaultPath_FileIsCreated()
|
|
{
|
|
var logger = Substitute.For<ILogger>();
|
|
var filesystem = Substitute.For<IFileSystem>();
|
|
var cmd = new CreateConfigCommand(logger, filesystem);
|
|
|
|
await cmd.ExecuteAsync(Substitute.For<IConsole>());
|
|
|
|
filesystem.File.Received().Exists(Arg.Is<string>(s => s.EndsWith("trash.yml")));
|
|
filesystem.File.Received().WriteAllText(Arg.Is<string>(s => s.EndsWith("trash.yml")), Arg.Any<string>());
|
|
}
|
|
|
|
[Test]
|
|
public async Task CreateConfig_SpecifyPath_FileIsCreated()
|
|
{
|
|
var logger = Substitute.For<ILogger>();
|
|
var filesystem = Substitute.For<IFileSystem>();
|
|
var cmd = new CreateConfigCommand(logger, filesystem)
|
|
{
|
|
Path = "some/other/path.yml"
|
|
};
|
|
|
|
await cmd.ExecuteAsync(Substitute.For<IConsole>());
|
|
|
|
filesystem.File.Received().Exists(Arg.Is("some/other/path.yml"));
|
|
filesystem.File.Received().WriteAllText(Arg.Is("some/other/path.yml"), Arg.Any<string>());
|
|
}
|
|
}
|
|
}
|