Skip to content

Commit f303fce

Browse files
Use new C# features
1 parent f873ecd commit f303fce

26 files changed

+85
-66
lines changed

Matchmaker.Tests/AsyncMatchExpressionBuilderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public async Task<Property> MatchWithFallthroughShouldReturnEmptyEnumerableIfNoM
436436
.ExecuteWithFallthroughAsync(value)
437437
.ToListAsync();
438438

439-
return result.SequenceEqual(Enumerable.Empty<bool>()).ToProperty();
439+
return result.SequenceEqual([]).ToProperty();
440440
}
441441

442442
[Property]
@@ -776,7 +776,7 @@ public async Task<Property> MatchToFunctionWithFallthroughShouldReturnEmptyEnume
776776
.ToFunctionWithFallthrough()(value)
777777
.ToListAsync();
778778

779-
return result.SequenceEqual(Enumerable.Empty<bool>()).ToProperty();
779+
return result.SequenceEqual([]).ToProperty();
780780
}
781781

782782
[Fact]

Matchmaker.Tests/AsyncMatchExpressionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public async Task<Property> MatchWithFallthroughShouldReturnEmptyEnumerableIfNoM
353353
.ExecuteWithFallthroughAsync(value)
354354
.ToListAsync();
355355

356-
return result.SequenceEqual(Enumerable.Empty<bool>()).ToProperty();
356+
return result.SequenceEqual([]).ToProperty();
357357
}
358358

359359
[Property]
@@ -650,7 +650,7 @@ public async Task<Property> MatchToFunctionWithFallthroughShouldReturnEmptyEnume
650650
.ToFunctionWithFallthrough()(value)
651651
.ToListAsync();
652652

653-
return result.SequenceEqual(Enumerable.Empty<bool>()).ToProperty();
653+
return result.SequenceEqual([]).ToProperty();
654654
}
655655

656656
[Fact]

Matchmaker.Tests/Generators.cs

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,34 @@ public static Arbitrary<Task<string>> ArbAsyncString() =>
5353
new ArbitraryAsyncString();
5454

5555
private static IEnumerable<IPattern<string, string>> Patterns(string input) =>
56-
new List<IPattern<string, string>>
57-
{
58-
Pattern.EqualTo(input),
59-
Pattern.EqualTo(() => input),
60-
Pattern.LessThan(input),
61-
Pattern.LessThan(() => input),
62-
Pattern.LessOrEqual(input),
63-
Pattern.LessOrEqual(() => input),
64-
Pattern.GreaterThan(input),
65-
Pattern.GreaterThan(() => input),
66-
Pattern.GreaterOrEqual(() => input),
67-
Pattern.GreaterOrEqual(() => input),
68-
Pattern.Any<string>()
69-
};
56+
[
57+
Pattern.EqualTo(input),
58+
Pattern.EqualTo(() => input),
59+
Pattern.LessThan(input),
60+
Pattern.LessThan(() => input),
61+
Pattern.LessOrEqual(input),
62+
Pattern.LessOrEqual(() => input),
63+
Pattern.GreaterThan(input),
64+
Pattern.GreaterThan(() => input),
65+
Pattern.GreaterOrEqual(() => input),
66+
Pattern.GreaterOrEqual(() => input),
67+
Pattern.Any<string>()
68+
];
7069

7170
private static IEnumerable<IAsyncPattern<string, string>> AsyncPatterns(string input) =>
72-
new List<IAsyncPattern<string, string>>
73-
{
74-
AsyncPattern.EqualTo(Task.FromResult(input)),
75-
AsyncPattern.EqualTo(() => Task.FromResult(input)),
76-
AsyncPattern.LessThan(Task.FromResult(input)),
77-
AsyncPattern.LessThan(() => Task.FromResult(input)),
78-
AsyncPattern.LessOrEqual(Task.FromResult(input)),
79-
AsyncPattern.LessOrEqual(() => Task.FromResult(input)),
80-
AsyncPattern.GreaterThan(Task.FromResult(input)),
81-
AsyncPattern.GreaterThan(() => Task.FromResult(input)),
82-
AsyncPattern.GreaterOrEqual(() => Task.FromResult(input)),
83-
AsyncPattern.GreaterOrEqual(() => Task.FromResult(input)),
84-
AsyncPattern.Any<string>()
85-
};
71+
[
72+
AsyncPattern.EqualTo(Task.FromResult(input)),
73+
AsyncPattern.EqualTo(() => Task.FromResult(input)),
74+
AsyncPattern.LessThan(Task.FromResult(input)),
75+
AsyncPattern.LessThan(() => Task.FromResult(input)),
76+
AsyncPattern.LessOrEqual(Task.FromResult(input)),
77+
AsyncPattern.LessOrEqual(() => Task.FromResult(input)),
78+
AsyncPattern.GreaterThan(Task.FromResult(input)),
79+
AsyncPattern.GreaterThan(() => Task.FromResult(input)),
80+
AsyncPattern.GreaterOrEqual(() => Task.FromResult(input)),
81+
AsyncPattern.GreaterOrEqual(() => Task.FromResult(input)),
82+
AsyncPattern.Any<string>()
83+
];
8684

8785
private class ArbitraryPattern : Arbitrary<IPattern<string, string>>
8886
{
@@ -105,7 +103,7 @@ private class ArbitraryPredicate : Arbitrary<Func<string, bool>>
105103
str => str == null,
106104
String.IsNullOrEmpty,
107105
str => str == "abc",
108-
str => str != null && str == str.ToLower());
106+
str => str != null && str.Equals(str, StringComparison.InvariantCultureIgnoreCase));
109107
}
110108

111109
private class ArbitraryMatcher : Arbitrary<Func<string, MatchResult<string>>>
@@ -172,7 +170,8 @@ private class ArbitraryAsyncPredicate : Arbitrary<Func<string, Task<bool>>>
172170
str => Task.FromResult(str == null),
173171
str => Task.FromResult(String.IsNullOrEmpty(str)),
174172
str => Task.FromResult(str == "abc"),
175-
str => Task.FromResult(str != null && str == str.ToLower()));
173+
str => Task.FromResult(
174+
str != null && str.Equals(str, StringComparison.InvariantCultureIgnoreCase)));
176175
}
177176

178177
private class ArbitraryAsyncMatcher : Arbitrary<Func<string, Task<MatchResult<string>>>>

Matchmaker.Tests/Linq/MatchResultExtensionsTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,24 +140,24 @@ public Property CastShouldCastValueOfCorrectTypeIfResultIsSuccessful(NonNull<str
140140
.ToProperty();
141141

142142
[Fact]
143-
public Property CastShouldSucceedIfResultContainsNull() =>
144-
MatchResult.Success<object>(null).Cast<object, string>().IsSuccessful.ToProperty();
143+
public void CastShouldSucceedIfResultContainsNull() =>
144+
MatchResult.Success<object>(null).Cast<object, string>().IsSuccessful.Should().BeTrue();
145145

146146
[Fact]
147-
public Property CastToNullableValueShouldFailIfResultContainsNull() =>
148-
MatchResult.Success<object>(null).Cast<object, int?>().IsSuccessful.ToProperty();
147+
public void CastToNullableValueShouldFailIfResultContainsNull() =>
148+
MatchResult.Success<object>(null).Cast<object, int?>().IsSuccessful.Should().BeTrue();
149149

150150
[Fact]
151-
public Property CastToValueShouldFailIfResultContainsNull() =>
152-
(!MatchResult.Success<object>(null).Cast<object, int>().IsSuccessful).ToProperty();
151+
public void CastToValueShouldFailIfResultContainsNull() =>
152+
MatchResult.Success<object>(null).Cast<object, int>().IsSuccessful.Should().BeFalse();
153153

154154
[Property]
155155
public Property CastShouldFailIfValueHasIncorrectTypeAndResultIsSuccessful(string value) =>
156156
(!MatchResult.Success<object>(value).Cast<object, int>().IsSuccessful).ToProperty();
157157

158158
[Fact]
159-
public Property CastShouldBeUnsuccessfulIfResultIsUnsuccessful() =>
160-
(!MatchResult.Failure<object>().Cast<object, string>().IsSuccessful).ToProperty();
159+
public void CastShouldBeUnsuccessfulIfResultIsUnsuccessful() =>
160+
MatchResult.Failure<object>().Cast<object, string>().IsSuccessful.Should().BeFalse();
161161

162162
[Property]
163163
public void DoShouldPerformActionIfResultIsSuccessful(string value)

Matchmaker.Tests/MatchExpressionBuilderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public Property MatchWithFallthroughShouldReturnEmptyEnumerableIfNoMatchFound(st
372372
.Case(pattern, _ => true))
373373
.ExecuteWithFallthrough(value);
374374

375-
return result.SequenceEqual(Enumerable.Empty<bool>()).ToProperty();
375+
return result.SequenceEqual([]).ToProperty();
376376
}
377377

378378
[Property]
@@ -707,7 +707,7 @@ public Property MatchToFunctionWithFallthroughShouldReturnEmptyEnumerableIfNoMat
707707
.Case(pattern, _ => true))
708708
.ToFunctionWithFallthrough()(value);
709709

710-
return result.SequenceEqual(Enumerable.Empty<bool>()).ToProperty();
710+
return result.SequenceEqual([]).ToProperty();
711711
}
712712

713713
[Fact]

Matchmaker.Tests/MatchExpressionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public Property MatchWithFallthroughShouldReturnEmptyEnumerableIfNoMatchFound(st
292292
.Case(pattern, _ => true)
293293
.ExecuteWithFallthrough(value);
294294

295-
return result.SequenceEqual(Enumerable.Empty<bool>()).ToProperty();
295+
return result.SequenceEqual([]).ToProperty();
296296
}
297297

298298
[Property]
@@ -583,7 +583,7 @@ public Property MatchToFunctionWithFallthroughShouldReturnEmptyEnumerableIfNoMat
583583
.Case(pattern, _ => true)
584584
.ToFunctionWithFallthrough()(value);
585585

586-
return result.SequenceEqual(Enumerable.Empty<bool>()).ToProperty();
586+
return result.SequenceEqual([]).ToProperty();
587587
}
588588

589589
[Fact]

Matchmaker.Tests/Patterns/Async/EqualToTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Matchmaker.Patterns.Async;
22

33
public class EqualToTests
44
{
5-
private static readonly IEqualityComparer<string> StringEqualityComparer = EqualityComparer<string>.Default;
5+
private static readonly EqualityComparer<string> StringEqualityComparer = EqualityComparer<string>.Default;
66

77
[Property]
88
public Property EqualToShouldNeverReturnNull(Task<string> x) =>

Matchmaker.Tests/Patterns/Async/GreaterOrEqualTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Matchmaker.Patterns.Async;
22

33
public class GreaterOrEqualTests
44
{
5-
private static readonly IComparer<string> StringComparer = Comparer<string>.Default;
5+
private static readonly Comparer<string> StringComparer = Comparer<string>.Default;
66

77
[Property]
88
public Property GreaterOrEqualShouldNeverReturnNull(Task<string> x) =>

Matchmaker.Tests/Patterns/Async/GreaterThanTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Matchmaker.Patterns.Async;
22

33
public class GreaterThanTests
44
{
5-
private static readonly IComparer<string> StringComparer = Comparer<string>.Default;
5+
private static readonly Comparer<string> StringComparer = Comparer<string>.Default;
66

77
[Property]
88
public Property GreaterThanShouldNeverReturnNull(Task<string> x) =>

Matchmaker.Tests/Patterns/Async/LessOrEqualTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Matchmaker.Patterns.Async;
22

33
public class LessOrEqualTests
44
{
5-
private static readonly IComparer<string> StringComparer = Comparer<string>.Default;
5+
private static readonly Comparer<string> StringComparer = Comparer<string>.Default;
66

77
[Property]
88
public Property LessOrEqualShouldNeverReturnNull(Task<string> x) =>

0 commit comments

Comments
 (0)