File tree Expand file tree Collapse file tree 2 files changed +45
-2
lines changed
BitFaster.Caching.UnitTests Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using FluentAssertions ;
3
+ using Xunit ;
4
+
5
+ namespace BitFaster . Caching . UnitTests
6
+ {
7
+ public class DurationTests
8
+ {
9
+ [ Fact ]
10
+ public void RoundTripHours ( )
11
+ {
12
+ var d = Duration . FromHours ( 2 ) ;
13
+ d . ToTimeSpan ( ) . Should ( ) . BeCloseTo ( TimeSpan . FromHours ( 2 ) , TimeSpan . FromMilliseconds ( 100 ) ) ;
14
+ }
15
+
16
+ [ Fact ]
17
+ public void RoundTripDays ( )
18
+ {
19
+ var d = Duration . FromDays ( 2 ) ;
20
+ d . ToTimeSpan ( ) . Should ( ) . BeCloseTo ( TimeSpan . FromDays ( 2 ) , TimeSpan . FromMilliseconds ( 100 ) ) ;
21
+ }
22
+ }
23
+ }
Original file line number Diff line number Diff line change @@ -94,15 +94,35 @@ public static Duration FromSeconds(double value)
94
94
}
95
95
96
96
/// <summary>
97
- /// Returns a Duration that represents a specified number of milliseconds .
97
+ /// Returns a Duration that represents a specified number of minutes .
98
98
/// </summary>
99
- /// <param name="value">A number of milliseconds </param>
99
+ /// <param name="value">A number of minutes </param>
100
100
/// <returns></returns>
101
101
public static Duration FromMinutes ( double value )
102
102
{
103
103
return FromTimeSpan ( TimeSpan . FromMinutes ( value ) ) ;
104
104
}
105
105
106
+ /// <summary>
107
+ /// Returns a Duration that represents a specified number of hours.
108
+ /// </summary>
109
+ /// <param name="value">A number of hours</param>
110
+ /// <returns></returns>
111
+ public static Duration FromHours ( double value )
112
+ {
113
+ return FromTimeSpan ( TimeSpan . FromHours ( value ) ) ;
114
+ }
115
+
116
+ /// <summary>
117
+ /// Returns a Duration that represents a specified number of days.
118
+ /// </summary>
119
+ /// <param name="value">A number of days</param>
120
+ /// <returns></returns>
121
+ public static Duration FromDays ( double value )
122
+ {
123
+ return FromTimeSpan ( TimeSpan . FromDays ( value ) ) ;
124
+ }
125
+
106
126
/// <summary>
107
127
/// Adds two specified Duration instances.
108
128
/// </summary>
You can’t perform that action at this time.
0 commit comments