|
3 | 3 | using System.IO; |
4 | 4 | using System.Linq; |
5 | 5 | using FsCheck; |
| 6 | +using FsCheck.Fluent; |
6 | 7 |
|
7 | 8 | namespace BenchmarkDotNetAnalyser.Tests.Unit |
8 | 9 | { |
9 | 10 | public static class AlphanumericStringArbitrary |
10 | 11 | { |
11 | | - public static Arbitrary<string> GetArbitrary() => Arb.Default.NonEmptyString().Generator |
12 | | - .Where(s => s.Get.All(c => char.IsDigit(c) || char.IsLetter(c))) |
13 | | - .Select(s => s.Get) |
| 12 | + public static Arbitrary<string> GetArbitrary() => ArbMap.Default.ArbFor<string>().Generator |
| 13 | + .Where(s => !string.IsNullOrEmpty(s)) |
| 14 | + .Where(s => s.All(c => char.IsDigit(c) || char.IsLetter(c))) |
14 | 15 | .ToArbitrary(); |
15 | 16 | } |
16 | 17 |
|
17 | 18 | public static class NonIntegerStringArbitrary |
18 | 19 | { |
19 | | - public static Arbitrary<string> GetArbitrary() => Arb.Default.NonEmptyString().Generator |
20 | | - .Where(s => !int.TryParse(s.Get, out _)) |
21 | | - .Select(s => s.Get) |
| 20 | + public static Arbitrary<string> GetArbitrary() => ArbMap.Default.ArbFor<string>().Generator |
| 21 | + .Where(s => !string.IsNullOrEmpty(s)) |
| 22 | + .Where(s => !int.TryParse(s, out _)) |
22 | 23 | .ToArbitrary(); |
23 | 24 | } |
24 | 25 |
|
25 | 26 | public static class NonDecimalStringArbitrary |
26 | 27 | { |
27 | | - public static Arbitrary<string> GetArbitrary() => Arb.Default.NonEmptyString().Generator |
28 | | - .Where(s => !decimal.TryParse(s.Get, out _)) |
29 | | - .Select(s => s.Get) |
| 28 | + public static Arbitrary<string> GetArbitrary() => ArbMap.Default.ArbFor<string>().Generator |
| 29 | + .Where(s => !string.IsNullOrEmpty(s)) |
| 30 | + .Where(s => !decimal.TryParse(s, out _)) |
30 | 31 | .ToArbitrary(); |
31 | 32 | } |
32 | 33 |
|
@@ -62,10 +63,10 @@ public static class InvalidPathArbitrary |
62 | 63 | public static Arbitrary<string> GetArbitrary() |
63 | 64 | { |
64 | 65 | var disallowed = new HashSet<string>() { ".", "/", @"\"}; |
65 | | - return Arb.Default.NonEmptyString().Generator |
66 | | - .Where(s => !disallowed.Contains(s.Get) && |
67 | | - !s.Get.All(c => char.IsDigit(c) || char.IsLetter(c))) |
68 | | - .Select(s => s.Get) |
| 66 | + return ArbMap.Default.ArbFor<string>().Generator |
| 67 | + .Where(s => !string.IsNullOrEmpty(s)) |
| 68 | + .Where(s => !disallowed.Contains(s) && |
| 69 | + !s.All(c => char.IsDigit(c) || char.IsLetter(c))) |
69 | 70 | .ToArbitrary(); |
70 | 71 | } |
71 | 72 | } |
|
0 commit comments