Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions UnitsNet.Tests/CustomCode/AreaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,21 @@ public void Constructor_UnitSystemSI_AssignsSIUnit()
}

[Fact]
public void As_ImperialGivenSIUnitSystem_ReturnsSIValue()
public void As_GivenSIUnitSystem_ReturnsSIValue()
{
var imperialArea = new Area(2.0, AreaUnit.SquareInch);
Assert.Equal(0.00129032, imperialArea.As(UnitSystem.SI));
var squareInches = new Area(2.0, AreaUnit.SquareInch);
Assert.Equal(0.00129032, squareInches.As(UnitSystem.SI));
}

[Fact]
public void ToUnit_ImperialGivenSIUnitSystem_ReturnsSIValue()
public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity()
{
var imperialArea = new Area(2.0, AreaUnit.SquareInch);
Assert.Equal(Area.FromSquareMeters(0.00129032), imperialArea.ToUnit(UnitSystem.SI));
var squareInches = new Area(2.0, AreaUnit.SquareInch);

var inSI = squareInches.ToUnit(UnitSystem.SI);

Assert.Equal(0.00129032, inSI.Value);
Assert.Equal(AreaUnit.SquareMeter, inSI.Unit);
}
}
}
16 changes: 10 additions & 6 deletions UnitsNet.Tests/CustomCode/EnergyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,21 @@ public void Constructor_UnitSystemSI_AssignsSIUnit()
}

[Fact]
public void As_ImperialQuantityGivenSIUnitSystem_ReturnsSIValue()
public void As_GivenSIUnitSystem_ReturnsSIValue()
{
var imperialEnergy = new Energy(2.0, EnergyUnit.BritishThermalUnit);
Assert.Equal(2110.11170524, imperialEnergy.As(UnitSystem.SI));
var btus = new Energy(2.0, EnergyUnit.BritishThermalUnit);
Assert.Equal(2110.11170524, btus.As(UnitSystem.SI));
}

[Fact]
public void ToUnit_ImperialQuantityGivenSIUnitSystem_ReturnsSIValue()
public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity()
{
var imperialEnergy = new Energy(2.0, EnergyUnit.BritishThermalUnit);
Assert.Equal(Energy.FromJoules(2110.11170524), imperialEnergy.ToUnit(UnitSystem.SI));
var btus = new Energy(2.0, EnergyUnit.BritishThermalUnit);

var inSI = btus.ToUnit(UnitSystem.SI);

Assert.Equal(2110.11170524, inSI.Value);
Assert.Equal(EnergyUnit.Joule, inSI.Unit);
}
}
}
16 changes: 10 additions & 6 deletions UnitsNet.Tests/CustomCode/LengthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,21 @@ public void Constructor_UnitSystemSI_AssignsSIUnit()
}

[Fact]
public void As_ImperialQuantityGivenSIUnitSystem_ReturnsSIValue()
public void As_GivenSIUnitSystem_ReturnsSIValue()
{
var imperialLength = new Length(2.0, LengthUnit.Inch);
Assert.Equal(0.0508, imperialLength.As(UnitSystem.SI));
var inches = new Length(2.0, LengthUnit.Inch);
Assert.Equal(0.0508, inches.As(UnitSystem.SI));
}

[Fact]
public void ToUnit_ImperialQuantityGivenSIUnitSystem_ReturnsSIValue()
public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity()
{
var imperialLength = new Length(2.0, LengthUnit.Inch);
Assert.Equal(Length.FromMeters(0.0508), imperialLength.ToUnit(UnitSystem.SI));
var inches = new Length(2.0, LengthUnit.Inch);

var inSI = inches.ToUnit(UnitSystem.SI);

Assert.Equal(0.0508, inSI.Value);
Assert.Equal(LengthUnit.Meter, inSI.Unit);
}
}
}
16 changes: 10 additions & 6 deletions UnitsNet.Tests/IQuantityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public void As_GivenNullUnitSystem_ThrowsArgumentNullException()
}

[Fact]
public void As_ImperialQuantityGivenSIUnitSystem_ReturnsSIValue()
public void As_GivenSIUnitSystem_ReturnsSIValue()
{
IQuantity imperialLengthQuantity = new Length(2.0, LengthUnit.Inch);
Assert.Equal(0.0508, imperialLengthQuantity.As(UnitSystem.SI));
IQuantity inches = new Length(2.0, LengthUnit.Inch);
Assert.Equal(0.0508, inches.As(UnitSystem.SI));
}

[Fact]
Expand All @@ -45,10 +45,14 @@ public void ToUnit_GivenNullUnitSystem_ThrowsArgumentNullException()
}

[Fact]
public void ToUnit_ImperialQuantityGivenSIUnitSystem_ReturnsSIValue()
public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity()
{
IQuantity imperialLengthQuantity = new Length(2.0, LengthUnit.Inch);
Assert.Equal(Length.FromMeters(0.0508), imperialLengthQuantity.ToUnit(UnitSystem.SI));
IQuantity inches = new Length(2.0, LengthUnit.Inch);

IQuantity inSI = inches.ToUnit(UnitSystem.SI);

Assert.Equal(0.0508, inSI.Value);
Assert.Equal(LengthUnit.Meter, inSI.Unit);
}
}
}