-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve spacing in HelpText * Make new spacing an option * Refactor * Extend logic to PostOptions * Add XML docs
- Loading branch information
1 parent
ce3011c
commit 0148bda
Showing
4 changed files
with
378 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
tests/CommandLine.Tests/Unit/StringBuilderExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using FluentAssertions; | ||
using CommandLine.Infrastructure; | ||
|
||
namespace CommandLine.Tests.Unit | ||
{ | ||
public class StringBuilderExtensionsTests | ||
{ | ||
private static StringBuilder _sb = new StringBuilder("test string"); | ||
private static StringBuilder _emptySb = new StringBuilder(); | ||
private static StringBuilder _nullSb = null; | ||
|
||
public static IEnumerable<object[]> GoodStartsWithData => new [] | ||
{ | ||
new object[] { "t" }, | ||
new object[] { "te" }, | ||
new object[] { "test " }, | ||
new object[] { "test string" } | ||
}; | ||
|
||
public static IEnumerable<object[]> BadTestData => new [] | ||
{ | ||
new object[] { null }, | ||
new object[] { "" }, | ||
new object[] { "xyz" }, | ||
new object[] { "some long test string" } | ||
}; | ||
|
||
public static IEnumerable<object[]> GoodEndsWithData => new[] | ||
{ | ||
new object[] { "g" }, | ||
new object[] { "ng" }, | ||
new object[] { " string" }, | ||
new object[] { "test string" } | ||
}; | ||
|
||
|
||
|
||
[Theory] | ||
[MemberData(nameof(GoodStartsWithData))] | ||
[MemberData(nameof(BadTestData))] | ||
public void StartsWith_null_builder_returns_false(string input) | ||
{ | ||
_nullSb.SafeStartsWith(input).Should().BeFalse(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(GoodStartsWithData))] | ||
[MemberData(nameof(BadTestData))] | ||
public void StartsWith_empty_builder_returns_false(string input) | ||
{ | ||
_emptySb.SafeStartsWith(input).Should().BeFalse(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(GoodStartsWithData))] | ||
public void StartsWith_good_data_returns_true(string input) | ||
{ | ||
_sb.SafeStartsWith(input).Should().BeTrue(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(BadTestData))] | ||
public void StartsWith_bad_data_returns_false(string input) | ||
{ | ||
_sb.SafeStartsWith(input).Should().BeFalse(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(GoodEndsWithData))] | ||
[MemberData(nameof(BadTestData))] | ||
public void EndsWith_null_builder_returns_false(string input) | ||
{ | ||
_nullSb.SafeEndsWith(input).Should().BeFalse(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(GoodEndsWithData))] | ||
[MemberData(nameof(BadTestData))] | ||
public void EndsWith_empty_builder_returns_false(string input) | ||
{ | ||
_emptySb.SafeEndsWith(input).Should().BeFalse(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(GoodEndsWithData))] | ||
public void EndsWith_good_data_returns_true(string input) | ||
{ | ||
_sb.SafeEndsWith(input).Should().BeTrue(); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(BadTestData))] | ||
public void EndsWith_bad_data_returns_false(string input) | ||
{ | ||
_sb.SafeEndsWith(input).Should().BeFalse(); | ||
} | ||
} | ||
} |
Oops, something went wrong.