feat: initial cli implementation

This commit is contained in:
Stevan Freeborn
2026-04-17 15:28:59 -05:00
parent ab57ac5a13
commit ba927c0e18
41 changed files with 1124 additions and 17 deletions
@@ -0,0 +1,51 @@
using System.CommandLine;
using Microsoft.Extensions.Hosting;
using Moq;
using StevanFreeborn.Extensions.Configuration.Secure.Cli.Commands;
namespace StevanFreeborn.Extensions.Configuration.Secure.Cli.Tests.Unit;
public class SecureConfigCliTests
{
private readonly Mock<IHostApplicationLifetime> _mockLifetime = new();
private readonly Mock<ICommandFactory> _mockCommandFactory = new();
public SecureConfigCliTests()
{
_mockCommandFactory.Setup(m => m.Create()).Returns(new Command("test-command"));
}
[Fact]
public void Constructor_WhenCalled_ItShouldCallCreateOnAllFactoriesPassedIn()
{
var sut = new SecureConfigCli(["secure-config"], _mockLifetime.Object, [_mockCommandFactory.Object]);
_mockCommandFactory.Verify(static m => m.Create(), Times.Once());
}
[Fact]
public async Task StartAsync_WhenCalled_ItShouldRunTheCLI()
{
// Arrange
var sut = new SecureConfigCli(["secure-config", "--help"], _mockLifetime.Object, [_mockCommandFactory.Object]);
// Act
await sut.StartAsync(CancellationToken.None);
// Assert
_mockLifetime.Verify(m => m.StopApplication(), Times.Once());
}
[Fact]
public async Task StopAsync_WhenCalled_ItShouldNotThrowException()
{
var sut = new SecureConfigCli(["secure-config"], _mockLifetime.Object, [_mockCommandFactory.Object]);
var act = async () => await sut.StopAsync(CancellationToken.None);
await act.Should().NotThrowAsync();
}
}