Skip to content

Commit 1813011

Browse files
tmilnthorpangularsen
authored andcommitted
Updating tests (#629)
1 parent 44f8b73 commit 1813011

File tree

4 files changed

+40
-24
lines changed

4 files changed

+40
-24
lines changed

UnitsNet.Tests/CustomCode/AreaTests.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,21 @@ public void Constructor_UnitSystemSI_AssignsSIUnit()
9292
}
9393

9494
[Fact]
95-
public void As_ImperialGivenSIUnitSystem_ReturnsSIValue()
95+
public void As_GivenSIUnitSystem_ReturnsSIValue()
9696
{
97-
var imperialArea = new Area(2.0, AreaUnit.SquareInch);
98-
Assert.Equal(0.00129032, imperialArea.As(UnitSystem.SI));
97+
var squareInches = new Area(2.0, AreaUnit.SquareInch);
98+
Assert.Equal(0.00129032, squareInches.As(UnitSystem.SI));
9999
}
100100

101101
[Fact]
102-
public void ToUnit_ImperialGivenSIUnitSystem_ReturnsSIValue()
102+
public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity()
103103
{
104-
var imperialArea = new Area(2.0, AreaUnit.SquareInch);
105-
Assert.Equal(Area.FromSquareMeters(0.00129032), imperialArea.ToUnit(UnitSystem.SI));
104+
var squareInches = new Area(2.0, AreaUnit.SquareInch);
105+
106+
var inSI = squareInches.ToUnit(UnitSystem.SI);
107+
108+
Assert.Equal(0.00129032, inSI.Value);
109+
Assert.Equal(AreaUnit.SquareMeter, inSI.Unit);
106110
}
107111
}
108112
}

UnitsNet.Tests/CustomCode/EnergyTests.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,21 @@ public void Constructor_UnitSystemSI_AssignsSIUnit()
6262
}
6363

6464
[Fact]
65-
public void As_ImperialQuantityGivenSIUnitSystem_ReturnsSIValue()
65+
public void As_GivenSIUnitSystem_ReturnsSIValue()
6666
{
67-
var imperialEnergy = new Energy(2.0, EnergyUnit.BritishThermalUnit);
68-
Assert.Equal(2110.11170524, imperialEnergy.As(UnitSystem.SI));
67+
var btus = new Energy(2.0, EnergyUnit.BritishThermalUnit);
68+
Assert.Equal(2110.11170524, btus.As(UnitSystem.SI));
6969
}
7070

7171
[Fact]
72-
public void ToUnit_ImperialQuantityGivenSIUnitSystem_ReturnsSIValue()
72+
public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity()
7373
{
74-
var imperialEnergy = new Energy(2.0, EnergyUnit.BritishThermalUnit);
75-
Assert.Equal(Energy.FromJoules(2110.11170524), imperialEnergy.ToUnit(UnitSystem.SI));
74+
var btus = new Energy(2.0, EnergyUnit.BritishThermalUnit);
75+
76+
var inSI = btus.ToUnit(UnitSystem.SI);
77+
78+
Assert.Equal(2110.11170524, inSI.Value);
79+
Assert.Equal(EnergyUnit.Joule, inSI.Unit);
7680
}
7781
}
7882
}

UnitsNet.Tests/CustomCode/LengthTests.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,21 @@ public void Constructor_UnitSystemSI_AssignsSIUnit()
167167
}
168168

169169
[Fact]
170-
public void As_ImperialQuantityGivenSIUnitSystem_ReturnsSIValue()
170+
public void As_GivenSIUnitSystem_ReturnsSIValue()
171171
{
172-
var imperialLength = new Length(2.0, LengthUnit.Inch);
173-
Assert.Equal(0.0508, imperialLength.As(UnitSystem.SI));
172+
var inches = new Length(2.0, LengthUnit.Inch);
173+
Assert.Equal(0.0508, inches.As(UnitSystem.SI));
174174
}
175175

176176
[Fact]
177-
public void ToUnit_ImperialQuantityGivenSIUnitSystem_ReturnsSIValue()
177+
public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity()
178178
{
179-
var imperialLength = new Length(2.0, LengthUnit.Inch);
180-
Assert.Equal(Length.FromMeters(0.0508), imperialLength.ToUnit(UnitSystem.SI));
179+
var inches = new Length(2.0, LengthUnit.Inch);
180+
181+
var inSI = inches.ToUnit(UnitSystem.SI);
182+
183+
Assert.Equal(0.0508, inSI.Value);
184+
Assert.Equal(LengthUnit.Meter, inSI.Unit);
181185
}
182186
}
183187
}

UnitsNet.Tests/IQuantityTests.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public void As_GivenNullUnitSystem_ThrowsArgumentNullException()
2424
}
2525

2626
[Fact]
27-
public void As_ImperialQuantityGivenSIUnitSystem_ReturnsSIValue()
27+
public void As_GivenSIUnitSystem_ReturnsSIValue()
2828
{
29-
IQuantity imperialLengthQuantity = new Length(2.0, LengthUnit.Inch);
30-
Assert.Equal(0.0508, imperialLengthQuantity.As(UnitSystem.SI));
29+
IQuantity inches = new Length(2.0, LengthUnit.Inch);
30+
Assert.Equal(0.0508, inches.As(UnitSystem.SI));
3131
}
3232

3333
[Fact]
@@ -45,10 +45,14 @@ public void ToUnit_GivenNullUnitSystem_ThrowsArgumentNullException()
4545
}
4646

4747
[Fact]
48-
public void ToUnit_ImperialQuantityGivenSIUnitSystem_ReturnsSIValue()
48+
public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity()
4949
{
50-
IQuantity imperialLengthQuantity = new Length(2.0, LengthUnit.Inch);
51-
Assert.Equal(Length.FromMeters(0.0508), imperialLengthQuantity.ToUnit(UnitSystem.SI));
50+
IQuantity inches = new Length(2.0, LengthUnit.Inch);
51+
52+
IQuantity inSI = inches.ToUnit(UnitSystem.SI);
53+
54+
Assert.Equal(0.0508, inSI.Value);
55+
Assert.Equal(LengthUnit.Meter, inSI.Unit);
5256
}
5357
}
5458
}

0 commit comments

Comments
 (0)