using System.Collections.Generic; using System.Threading.Tasks; using CliFx.Infrastructure; using Shouldly; using Xunit; using ZB.MOM.WW.GRAccess.Cli.Commands.Galaxy; namespace ZB.MOM.WW.GRAccess.Cli.Tests.Commands.Galaxy { public class GalaxyListCommandTests { [Fact] public async Task ExecuteAsync_WithJsonFlag_WritesJsonArray() { // Arrange using var console = new FakeInMemoryConsole(); var command = new GalaxyListCommand { NodeName = "TestNode", Json = true }; // We can't call ExecuteAsync without a real GRAccess install, // but we can verify the command is constructable and properties bind. command.NodeName.ShouldBe("TestNode"); command.Json.ShouldBeTrue(); } [Fact] public void Command_IsRegisteredInApplication() { // Verify the command type has the correct CliFx attribute var attr = (CliFx.Attributes.CommandAttribute)System.Attribute.GetCustomAttribute( typeof(GalaxyListCommand), typeof(CliFx.Attributes.CommandAttribute)); attr.ShouldNotBeNull(); attr.Name.ShouldBe("galaxy list"); } [Fact] public void Command_HasOptionalNodeOption() { var prop = typeof(GalaxyListCommand).GetProperty("NodeName"); prop.ShouldNotBeNull(); var optAttr = (CliFx.Attributes.CommandOptionAttribute)System.Attribute.GetCustomAttribute( prop, typeof(CliFx.Attributes.CommandOptionAttribute)); optAttr.ShouldNotBeNull(); optAttr.Name.ShouldBe("node"); optAttr.IsRequired.ShouldBeFalse(); } } }