-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDigitExtensionsTests.cs
More file actions
44 lines (37 loc) · 982 Bytes
/
DigitExtensionsTests.cs
File metadata and controls
44 lines (37 loc) · 982 Bytes
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
#nullable enable
using System.Linq;
using FsCheck.Xunit;
using Xunit;
namespace StrongTypes.Tests;
public class DigitExtensionsTests
{
[Property]
public void AsDigit_DelegatesToTryCreate(char c)
{
Assert.Equal(Digit.TryCreate(c), c.AsDigit());
}
[Fact]
public void FilterDigits_ExtractsDigitsInOrder()
{
Assert.Equal(
new byte[] { 1, 2, 3, 8, 7, 6, 5, 9 },
"ASD 1 some spaces 2 with numbers 38 7 in between .6 ?:`'!@(#*&$%&^!@)$_ them59"
.FilterDigits()
.Select(d => d.Value));
}
[Fact]
public void FilterDigits_ReturnsEmpty_ForNull()
{
Assert.Empty(((string?)null).FilterDigits());
}
[Fact]
public void FilterDigits_ReturnsEmpty_ForEmptyString()
{
Assert.Empty("".FilterDigits());
}
[Fact]
public void FilterDigits_ReturnsEmpty_ForNonDigitsOnly()
{
Assert.Empty("abc XYZ !@#".FilterDigits());
}
}