@@ -29,6 +29,55 @@ public partial class QuantityTests
29
29
{
30
30
public class ToString
31
31
{
32
+ [ Fact ]
33
+ public void CreatedByDefaultCtor_ReturnsValueInBaseUnit ( )
34
+ {
35
+ // double types
36
+ Assert . Equal ( "0 kg" , new Mass ( ) . ToString ( ) ) ;
37
+
38
+ // decimal types
39
+ Assert . Equal ( "0 b" , new Information ( ) . ToString ( ) ) ;
40
+
41
+ // logarithmic types
42
+ Assert . Equal ( "0 dB" , new Level ( ) . ToString ( ) ) ;
43
+ }
44
+
45
+ [ Fact ]
46
+ public void CreatedByCtorWithValue_ReturnsValueInBaseUnit ( )
47
+ {
48
+ #pragma warning disable 618
49
+ // double types
50
+ Assert . Equal ( "5 kg" , new Mass ( 5L ) . ToString ( ) ) ;
51
+ Assert . Equal ( "5 kg" , new Mass ( 5d ) . ToString ( ) ) ;
52
+ Assert . Equal ( "5 kg" , new Mass ( 5m ) . ToString ( ) ) ;
53
+
54
+ // decimal types
55
+ Assert . Equal ( "5 b" , new Information ( 5L ) . ToString ( ) ) ;
56
+ Assert . Equal ( "5 b" , new Information ( 5d ) . ToString ( ) ) ;
57
+ Assert . Equal ( "5 b" , new Information ( 5m ) . ToString ( ) ) ;
58
+
59
+ // logarithmic types
60
+ Assert . Equal ( "5 dB" , new Level ( 5L ) . ToString ( ) ) ;
61
+ Assert . Equal ( "5 dB" , new Level ( 5d ) . ToString ( ) ) ;
62
+ Assert . Equal ( "5 dB" , new Level ( 5m ) . ToString ( ) ) ;
63
+ #pragma warning restore 618
64
+ }
65
+
66
+ [ Fact ]
67
+ public void CreatedByCtorWithValueAndUnit_ReturnsValueAndUnit ( )
68
+ {
69
+ #pragma warning disable 618
70
+ // double types
71
+ Assert . Equal ( "50 hg" , new Mass ( 5 ) . ToString ( MassUnit . Hectogram ) ) ;
72
+
73
+ // decimal types
74
+ Assert . Equal ( "1 B" , new Information ( 8 ) . ToString ( InformationUnit . Byte ) ) ;
75
+
76
+ // logarithmic types
77
+ Assert . Equal ( "0.58 Np" , new Level ( 5 ) . ToString ( LevelUnit . Neper ) ) ;
78
+ #pragma warning restore 618
79
+ }
80
+
32
81
[ Fact ]
33
82
public void ReturnsTheOriginalValueAndUnit ( )
34
83
{
0 commit comments