forked from commandlineparser/commandline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringBuilderExtensionsTests.cs
More file actions
101 lines (87 loc) · 2.96 KB
/
Copy pathStringBuilderExtensionsTests.cs
File metadata and controls
101 lines (87 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System.Collections.Generic;
using System.Text;
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();
}
}
}