From 0553deda4dbb2b10313c22d06fc83ccd46cbd8be Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 5 Oct 2025 11:21:37 -0400 Subject: [PATCH] Clean up formatting tests --- SabreTools.CommandLine.Test/FeatureTests.cs | 41 ++++++++++++--------- SabreTools.CommandLine/Inputs/UserInput.cs | 2 +- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/SabreTools.CommandLine.Test/FeatureTests.cs b/SabreTools.CommandLine.Test/FeatureTests.cs index 6adfe98..848d9c9 100644 --- a/SabreTools.CommandLine.Test/FeatureTests.cs +++ b/SabreTools.CommandLine.Test/FeatureTests.cs @@ -1,5 +1,4 @@ -using System.Net.NetworkInformation; -using Xunit; +using Xunit; namespace SabreTools.CommandLine.Test { @@ -91,24 +90,30 @@ namespace SabreTools.CommandLine.Test Assert.Empty(feature.Inputs); } - [Fact] - public void FormatLongDescriptionTest() + [Theory] + [InlineData(-1, -1, "a a")] + [InlineData(0, -1, "a a")] + [InlineData(-1, 0, "a a")] + [InlineData(0, 0, "a a")] + [InlineData(2, 30, " a a")] + [InlineData(4, 0, " a a")] + public void FormatStandardTest(int pre, int midpoint, string expected) { - var feature = new MockFeature("a", "a", "a", "Some long description that is normal"); - var o = feature.FormatLongDescription(pre: 0); - Assert.Equal(2, o.Count); + var feature = new MockFeature("a", "a", "a"); + string actual = feature.FormatStandard(pre, midpoint); + Assert.Equal(expected, actual); + } - feature = new MockFeature("a", "a", "a", "Some long description\nwith a newline"); - o = feature.FormatLongDescription(pre: 0); - Assert.Equal(3, o.Count); - - feature = new MockFeature("a", "a", "a", "Some long description\nwith\nmultiple\nnewlines"); - o = feature.FormatLongDescription(pre: 0); - Assert.Equal(5, o.Count); - - feature = new MockFeature("a", "a", "a", "Some long description\n - With formatting"); - o = feature.FormatLongDescription(pre: 0); - Assert.Equal(3, o.Count); + [Theory] + [InlineData("Some long description that is normal", 2)] + [InlineData("Some long description\nwith a newline", 3)] + [InlineData("Some long description\nwith\nmultiple\nnewlines", 5)] + [InlineData("Some long description\n - With formatting", 3)] + public void FormatLongDescriptionTest(string longDescription, int expectedCount) + { + var feature = new MockFeature("a", "a", "a", longDescription); + var formatted = feature.FormatLongDescription(pre: 0); + Assert.Equal(expectedCount, formatted.Count); } /// diff --git a/SabreTools.CommandLine/Inputs/UserInput.cs b/SabreTools.CommandLine/Inputs/UserInput.cs index 2179f36..ea466ae 100644 --- a/SabreTools.CommandLine/Inputs/UserInput.cs +++ b/SabreTools.CommandLine/Inputs/UserInput.cs @@ -680,7 +680,7 @@ namespace SabreTools.CommandLine.Inputs /// Positive number representing number of spaces to put in front of the feature /// Positive number representing the column where the description should start /// Formatted output string - private string FormatStandard(int pre, int midpoint) + internal string FormatStandard(int pre, int midpoint) { var output = new StringBuilder();