应文浩wenhao.ying@xiaobao100.com bce2612b64 feat: 完善具体实现
2026-04-06 15:25:34 +08:00

44 lines
1.2 KiB
C#

using Xunit;
using FluentAssertions;
using NSubstitute;
using FreeCode.Commands;
using FreeCode.Core.Enums;
using FreeCode.Core.Models;
using FreeCode.Tests.Unit.Helpers;
namespace FreeCode.Tests.Unit.Commands;
public sealed class ExitCommandTests
{
[Fact]
public void ExitCommand_ExposesExpectedMetadata()
{
var command = new ExitCommand();
command.Name.Should().Be("exit");
command.Aliases.Should().Equal("quit");
command.Description.Should().Be("Exit the application.");
}
[Fact]
public async Task ExecuteAsync_ReturnsSuccessfulExitResult()
{
var command = new ExitCommand();
var result = await command.ExecuteAsync(new CommandContext(Environment.CurrentDirectory, new SimpleServiceProvider()));
result.Success.Should().BeTrue();
result.Output.Should().Be("Exit requested.");
}
[Fact]
public void ExitCommand_UsesLocalCategoryAndAlwaysAvailability()
{
var command = new ExitCommand();
command.Category.Should().Be(CommandCategory.Local);
command.Availability.Should().Be(CommandAvailability.Always);
command.IsEnabled().Should().BeTrue();
}
}