1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
4
- using FluentAssertions ;
5
-
6
4
using Serilog . Sinks . AzureTableStorage . Extensions ;
7
5
8
6
using Xunit ;
@@ -26,20 +24,20 @@ public void GenerateRowKeyDateTimeOffsetNow()
26
24
var dateTime = new DateTimeOffset ( 2024 , 4 , 1 , 23 , 0 , 0 , TimeSpan . FromHours ( - 5 ) ) ;
27
25
28
26
var rowKey = DefaultKeyGenerator . GenerateRowKey ( dateTime ) ;
29
- rowKey . Should ( ) . NotBeNull ( ) ;
27
+ Assert . NotNull ( rowKey ) ;
30
28
31
29
var parsed = Ulid . TryParse ( rowKey , out var ulid ) ;
32
- parsed . Should ( ) . BeTrue ( ) ;
33
- ulid . Should ( ) . NotBeNull ( ) ;
30
+ Assert . True ( parsed ) ;
31
+ Assert . NotEqual ( default , ulid ) ;
34
32
35
33
var reversed = dateTime . ToUniversalTime ( ) . ToReverseChronological ( ) ;
36
34
var ulidDate = ulid . Time ;
37
35
38
- ulidDate . Year . Should ( ) . Be ( reversed . Year ) ;
39
- ulidDate . Month . Should ( ) . Be ( reversed . Month ) ;
40
- ulidDate . Day . Should ( ) . Be ( reversed . Day ) ;
41
- ulidDate . Hour . Should ( ) . Be ( reversed . Hour ) ;
42
- ulidDate . Minute . Should ( ) . Be ( reversed . Minute ) ;
36
+ Assert . Equal ( reversed . Year , ulidDate . Year ) ;
37
+ Assert . Equal ( reversed . Month , ulidDate . Month ) ;
38
+ Assert . Equal ( reversed . Day , ulidDate . Day ) ;
39
+ Assert . Equal ( reversed . Hour , ulidDate . Hour ) ;
40
+ Assert . Equal ( reversed . Minute , ulidDate . Minute ) ;
43
41
}
44
42
45
43
@@ -49,8 +47,8 @@ public void GeneratePartitionKeyDateTimeOffsetNow()
49
47
var dateTime = new DateTimeOffset ( 2024 , 4 , 1 , 23 , 0 , 0 , TimeSpan . FromHours ( - 5 ) ) ;
50
48
51
49
var partitionKey = DefaultKeyGenerator . GeneratePartitionKey ( dateTime ) ;
52
- partitionKey . Should ( ) . NotBeNull ( ) ;
53
- partitionKey . Should ( ) . Be ( "2516902703999999999" ) ;
50
+ Assert . NotNull ( partitionKey ) ;
51
+ Assert . Equal ( "2516902703999999999" , partitionKey ) ;
54
52
}
55
53
56
54
[ Fact ]
@@ -60,17 +58,17 @@ public void GeneratePartitionKeyDateTimeNow()
60
58
var eventTime = dateTime . UtcDateTime ;
61
59
62
60
var partitionKey = DefaultKeyGenerator . GeneratePartitionKey ( eventTime ) ;
63
- partitionKey . Should ( ) . NotBeNull ( ) ;
64
- partitionKey . Should ( ) . Be ( "2516902703999999999" ) ;
61
+ Assert . NotNull ( partitionKey ) ;
62
+ Assert . Equal ( "2516902703999999999" , partitionKey ) ;
65
63
}
66
64
67
65
[ Theory ]
68
66
[ MemberData ( nameof ( GetDateRounding ) ) ]
69
67
public void GeneratePartitionKeyDateTimeNowRound ( DateTimeOffset dateTime , string expected )
70
68
{
71
69
var partitionKey = DefaultKeyGenerator . GeneratePartitionKey ( dateTime ) ;
72
- partitionKey . Should ( ) . NotBeNull ( ) ;
73
- partitionKey . Should ( ) . Be ( expected ) ;
70
+ Assert . NotNull ( partitionKey ) ;
71
+ Assert . Equal ( expected , partitionKey ) ;
74
72
}
75
73
76
74
public static IEnumerable < object [ ] > GetDateRounding ( )
@@ -108,8 +106,8 @@ public void GeneratePartitionKeyQueryDateOnly()
108
106
var date = new DateOnly ( 2024 , 4 , 1 ) ;
109
107
110
108
var partitionKeyQuery = DefaultKeyGenerator . GeneratePartitionKeyQuery ( date , TimeSpan . FromHours ( - 5 ) ) ;
111
- partitionKeyQuery . Should ( ) . NotBeNull ( ) ;
112
- partitionKeyQuery . Should ( ) . Be ( "(PartitionKey ge '2516902667999999999') and (PartitionKey lt '2516903531999999999')" ) ;
109
+ Assert . NotNull ( partitionKeyQuery ) ;
110
+ Assert . Equal ( "(PartitionKey ge '2516902667999999999') and (PartitionKey lt '2516903531999999999')" , partitionKeyQuery ) ;
113
111
}
114
112
115
113
[ Fact ]
@@ -122,8 +120,8 @@ public void GeneratePartitionKeyQueryDateTime()
122
120
var endTime = endDate . UtcDateTime ;
123
121
124
122
var partitionKeyQuery = DefaultKeyGenerator . GeneratePartitionKeyQuery ( startTime , endTime ) ;
125
- partitionKeyQuery . Should ( ) . NotBeNull ( ) ;
126
- partitionKeyQuery . Should ( ) . Be ( "(PartitionKey ge '2516902667999999999') and (PartitionKey lt '2516903531999999999')" ) ;
123
+ Assert . NotNull ( partitionKeyQuery ) ;
124
+ Assert . Equal ( "(PartitionKey ge '2516902667999999999') and (PartitionKey lt '2516903531999999999')" , partitionKeyQuery ) ;
127
125
}
128
126
129
127
[ Fact ]
@@ -133,8 +131,8 @@ public void GeneratePartitionKeyQueryDateTimeOffset()
133
131
var endTime = new DateTimeOffset ( 2024 , 4 , 2 , 0 , 0 , 0 , TimeSpan . FromHours ( - 5 ) ) ;
134
132
135
133
var partitionKeyQuery = DefaultKeyGenerator . GeneratePartitionKeyQuery ( startTime , endTime ) ;
136
- partitionKeyQuery . Should ( ) . NotBeNull ( ) ;
137
- partitionKeyQuery . Should ( ) . Be ( "(PartitionKey ge '2516902667999999999') and (PartitionKey lt '2516903531999999999')" ) ;
134
+ Assert . NotNull ( partitionKeyQuery ) ;
135
+ Assert . Equal ( "(PartitionKey ge '2516902667999999999') and (PartitionKey lt '2516903531999999999')" , partitionKeyQuery ) ;
138
136
}
139
137
140
138
}
0 commit comments