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
7 changes: 7 additions & 0 deletions UnitsNet.Tests/CustomCode/AreaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public void AreaDividedByLengthEqualsLength()
Assert.Equal(length, Length.FromMeters(10));
}

[Fact]
public void AreaDividedByVolumeEqualsReciprocalLength()
{
ReciprocalLength reciprocalLength = Area.FromSquareMeters(50) / Volume.FromCubicMeters(5);
Assert.Equal(reciprocalLength, ReciprocalLength.FromInverseMeters(10));
}

[Fact]
public void AreaTimesMassFluxEqualsMassFlow()
{
Expand Down
14 changes: 14 additions & 0 deletions UnitsNet.Tests/CustomCode/LengthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ public void LengthDividedBySpeedEqualsDuration()
Assert.Equal(Duration.FromSeconds(10), duration);
}

[Fact]
public void LengthDividedByAreaEqualsReciprocalLength()
{
ReciprocalLength reciprocalLength = Length.FromMeters(20) / Area.FromSquareMeters(2);
Assert.Equal(ReciprocalLength.FromInverseMeters(10), reciprocalLength);
}

[Fact]
public void LengthDividedByVolumeEqualsReciprocalArea()
{
ReciprocalArea reciprocalArea = Length.FromMeters(20) / Volume.FromCubicMeters(2);
Assert.Equal(ReciprocalArea.FromInverseSquareMeters(10), reciprocalArea);
}

[Fact]
public void LengthTimesSpeedEqualsKinematicViscosity()
{
Expand Down
6 changes: 6 additions & 0 deletions UnitsNet/CustomCode/Quantities/Area.extra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ public ReciprocalArea Inverse()
return Length.FromMeters(area.SquareMeters / length.Meters);
}

/// <summary>Get <see cref="ReciprocalLength"/> from <see cref="Area"/> divided by <see cref="Volume"/>.</summary>
public static ReciprocalLength operator /(Area area, Volume volume)
{
return ReciprocalLength.FromInverseMeters(area.SquareMeters / volume.CubicMeters);
}

/// <summary>Get <see cref="MassFlow"/> from <see cref="Area"/> times <see cref="MassFlux"/>.</summary>
public static MassFlow operator *(Area area, MassFlux massFlux)
{
Expand Down
12 changes: 12 additions & 0 deletions UnitsNet/CustomCode/Quantities/Length.extra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ public static bool TryParseFeetInches(string? str, out Length result, IFormatPro
return Duration.FromSeconds(length.Meters/speed.MetersPerSecond);
}

/// <summary>Get <see cref="ReciprocalLength"/> from <see cref="Length"/> divided by <see cref="Area"/>.</summary>
public static ReciprocalLength operator /(Length length, Area area)
{
return ReciprocalLength.FromInverseMeters(length.Meters / area.SquareMeters);
}

/// <summary>Get <see cref="ReciprocalArea"/> from <see cref="Length"/> divided by <see cref="Volume"/>.</summary>
public static ReciprocalArea operator /(Length length, Volume volume)
{
return ReciprocalArea.FromInverseSquareMeters(length.Meters / volume.CubicMeters);
}

/// <summary>Get <see cref="Area"/> from <see cref="Length"/> times <see cref="Length"/>.</summary>
public static Area operator *(Length length1, Length length2)
{
Expand Down