diff --git a/OnixLabs.Core/IValueComparable.cs b/OnixLabs.Core/IValueComparable.cs
index 921fdeb..29b24bb 100644
--- a/OnixLabs.Core/IValueComparable.cs
+++ b/OnixLabs.Core/IValueComparable.cs
@@ -20,8 +20,8 @@ namespace OnixLabs.Core;
/// Defines an extension to the default and interfaces,
/// including equality, inequality, greater than, greater than or equal, less than, and less than or equal operators.
///
-/// The underlying type of the objects to compare.
-public interface IValueComparable : IComparable, IComparable where T : IValueComparable
+/// The underlying type of the objects to compare.
+public interface IValueComparable : IComparable, IComparable where TSelf : IValueComparable
{
///
/// Performs an equality comparison between two object instances.
@@ -29,7 +29,7 @@ public interface IValueComparable : IComparable, IComparable where T :
/// The left-hand instance to compare.
/// The right-hand instance to compare.
/// Returns if the left-hand instance is equal to the right-hand instance; otherwise, .
- public static abstract bool operator ==(T left, T right);
+ public static abstract bool operator ==(TSelf left, TSelf right);
///
/// Performs an inequality comparison between two object instances.
@@ -37,7 +37,7 @@ public interface IValueComparable : IComparable, IComparable where T :
/// The left-hand instance to compare.
/// The right-hand instance to compare.
/// Returns if the left-hand instance is not equal to the right-hand instance; otherwise, .
- public static abstract bool operator !=(T left, T right);
+ public static abstract bool operator !=(TSelf left, TSelf right);
///
/// Performs a greater than comparison between two object instances.
@@ -45,7 +45,7 @@ public interface IValueComparable : IComparable, IComparable where T :
/// The left-hand instance to compare.
/// The right-hand instance to compare.
/// Returns if the left-hand instance is greater than the right-hand instance; otherwise, .
- public static abstract bool operator >(T left, T right);
+ public static abstract bool operator >(TSelf left, TSelf right);
///
/// Performs a greater than or equal comparison between two object instances.
@@ -53,7 +53,7 @@ public interface IValueComparable : IComparable, IComparable where T :
/// The left-hand instance to compare.
/// The right-hand instance to compare.
/// Returns if the left-hand instance is greater than or equal to the right-hand instance; otherwise, .
- public static abstract bool operator >=(T left, T right);
+ public static abstract bool operator >=(TSelf left, TSelf right);
///
/// Performs a less than comparison between two object instances.
@@ -61,7 +61,7 @@ public interface IValueComparable : IComparable, IComparable where T :
/// The left-hand instance to compare.
/// The right-hand instance to compare.
/// Returns if the left-hand instance is less than the right-hand instance; otherwise, .
- public static abstract bool operator <(T left, T right);
+ public static abstract bool operator <(TSelf left, TSelf right);
///
/// Performs a less than or equal comparison between two object instances.
@@ -69,5 +69,5 @@ public interface IValueComparable : IComparable, IComparable where T :
/// The left-hand instance to compare.
/// The right-hand instance to compare.
/// Returns if the left-hand instance is less than or equal to the right-hand instance; otherwise, .
- public static abstract bool operator <=(T left, T right);
+ public static abstract bool operator <=(TSelf left, TSelf right);
}
diff --git a/OnixLabs.Core/IValueEquatable.cs b/OnixLabs.Core/IValueEquatable.cs
index 0a9e7a6..5d4bbe4 100644
--- a/OnixLabs.Core/IValueEquatable.cs
+++ b/OnixLabs.Core/IValueEquatable.cs
@@ -19,8 +19,8 @@ namespace OnixLabs.Core;
///
/// Defines an extension to the default interface, including equality and inequality operators.
///
-/// The underlying type of the objects to compare.
-public interface IValueEquatable : IEquatable where T : IValueEquatable
+/// The underlying type of the objects to compare.
+public interface IValueEquatable : IEquatable where TSelf : IValueEquatable
{
///
/// Performs an equality comparison between two object instances.
@@ -28,7 +28,7 @@ public interface IValueEquatable : IEquatable where T : IValueEquatable
/// The left-hand instance to compare.
/// The right-hand instance to compare.
/// Returns if the left-hand instance is equal to the right-hand instance; otherwise, .
- public static abstract bool operator ==(T? left, T? right);
+ public static abstract bool operator ==(TSelf? left, TSelf? right);
///
/// Performs an inequality comparison between two object instances.
@@ -36,5 +36,5 @@ public interface IValueEquatable : IEquatable where T : IValueEquatable
/// The left-hand instance to compare.
/// The right-hand instance to compare.
/// Returns if the left-hand instance is not equal to the right-hand instance; otherwise, .
- public static abstract bool operator !=(T? left, T? right);
+ public static abstract bool operator !=(TSelf? left, TSelf? right);
}
diff --git a/OnixLabs.Core/Text/IBaseValue.cs b/OnixLabs.Core/Text/IBaseValue.cs
index 103c244..5dc42a2 100644
--- a/OnixLabs.Core/Text/IBaseValue.cs
+++ b/OnixLabs.Core/Text/IBaseValue.cs
@@ -40,4 +40,4 @@ public interface IBaseValue : IBinaryConvertible, ISpanFormattable
///
/// Defines a generic base encoding representation.
///
-public interface IBaseValue : IValueEquatable, ISpanParsable, IBaseValue where T : struct, IBaseValue;
+public interface IBaseValue : IValueEquatable, ISpanParsable, IBaseValue where TSelf : struct, IBaseValue;
diff --git a/OnixLabs.Playground/OnixLabs.Playground.csproj b/OnixLabs.Playground/OnixLabs.Playground.csproj
index 3c25aa1..bbd8a80 100644
--- a/OnixLabs.Playground/OnixLabs.Playground.csproj
+++ b/OnixLabs.Playground/OnixLabs.Playground.csproj
@@ -8,6 +8,7 @@
+
diff --git a/OnixLabs.Units.UnitTests/AreaTests.cs b/OnixLabs.Units.UnitTests/AreaTests.cs
new file mode 100644
index 0000000..2be164c
--- /dev/null
+++ b/OnixLabs.Units.UnitTests/AreaTests.cs
@@ -0,0 +1,771 @@
+// Copyright 2020-2025 ONIXLabs
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using System;
+using System.Globalization;
+using OnixLabs.Numerics;
+
+namespace OnixLabs.Units.UnitTests;
+
+public sealed class AreaTests
+{
+ // IEEE-754 binary floating-point arithmetic causes small discrepancies in calculation, therefore we need a tolerance.
+ private const double Tolerance = 1e+106;
+
+ [Fact(DisplayName = "Area.Zero should produce the expected result")]
+ public void AreaZeroShouldProduceExpectedResult()
+ {
+ // Given / When
+ Area area = Area.Zero;
+
+ // Then
+ Assert.Equal(0.0, area.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareQuectometers should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1.0)]
+ [InlineData(2.5, 2.5)]
+ public void AreaFromSquareQuectometersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareQuectometers(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareRontometers should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e6)]
+ [InlineData(2.5, 2.5e6)]
+ public void AreaFromSquareRontometersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareRontometers(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareYoctometers should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e12)]
+ [InlineData(2.5, 2.5e12)]
+ public void AreaFromSquareYoctometersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareYoctometers(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareZeptometers should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e18)]
+ [InlineData(2.5, 2.5e18)]
+ public void AreaFromSquareZeptometersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareZeptometers(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareAttometers should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e24)]
+ [InlineData(2.5, 2.5e24)]
+ public void AreaFromSquareAttometersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareAttometers(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareFemtometers should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e30)]
+ [InlineData(2.5, 2.5e30)]
+ public void AreaFromSquareFemtometersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareFemtometers(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquarePicometers should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e36)]
+ [InlineData(2.5, 2.5e36)]
+ public void AreaFromSquarePicometersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquarePicometers(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareNanometers should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e42)]
+ [InlineData(2.5, 2.5e42)]
+ public void AreaFromSquareNanometersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareNanometers(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareMicrometers should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e48)]
+ [InlineData(2.5, 2.5e48)]
+ public void AreaFromSquareMicrometersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareMicrometers(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareMillimeters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e54)]
+ [InlineData(2.5, 2.5e54)]
+ public void AreaFromSquareMillimetersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareMillimeters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareCentimeters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e56)]
+ [InlineData(2.5, 2.5e56)]
+ public void AreaFromSquareCentimetersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareCentimeters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareDecimeters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e58)]
+ [InlineData(2.5, 2.5e58)]
+ public void AreaFromSquareDecimetersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareDecimeters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareMeters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e60)]
+ [InlineData(2.5, 2.5e60)]
+ public void AreaFromSquareMetersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareMeters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareDecameters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e62)]
+ [InlineData(2.5, 2.5e62)]
+ public void AreaFromSquareDecametersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareDecameters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareHectometers should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e64)]
+ [InlineData(2.5, 2.5e64)]
+ public void AreaFromSquareHectometersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareHectometers(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareKilometers should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e66)]
+ [InlineData(2.5, 2.5e66)]
+ public void AreaFromSquareKilometersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareKilometers(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareMegameters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e72)]
+ [InlineData(2.5, 2.5e72)]
+ public void AreaFromSquareMegametersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareMegameters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareGigameters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e78)]
+ [InlineData(2.5, 2.5e78)]
+ public void AreaFromSquareGigametersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareGigameters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareTerameters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e84)]
+ [InlineData(2.5, 2.5e84)]
+ public void AreaFromSquareTerametersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareTerameters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquarePetameters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e90)]
+ [InlineData(2.5, 2.5e90)]
+ public void AreaFromSquarePetametersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquarePetameters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareExameters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e96)]
+ [InlineData(2.5, 2.5e96)]
+ public void AreaFromSquareExametersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareExameters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareZettameters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e102)]
+ [InlineData(2.5, 2.5e102)]
+ public void AreaFromSquareZettametersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareZettameters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareYottameters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e108)]
+ [InlineData(2.5, 2.5e108)]
+ public void AreaFromSquareYottametersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareYottameters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareRonnameters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e114)]
+ [InlineData(2.5, 2.5e114)]
+ public void AreaFromSquareRonnametersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareRonnameters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareQuettameters should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e120)]
+ [InlineData(2.5, 2.5e120)]
+ public void AreaFromSquareQuettametersShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareQuettameters(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareInches should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 6.4516e56)]
+ [InlineData(2.5, 1.6129e57)]
+ public void AreaFromSquareInchesShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareInches(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareFeet should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 9.290304e58)]
+ [InlineData(2.5, 2.322576e59)]
+ public void AreaFromSquareFeetShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareFeet(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareYards should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 8.3612736e59)]
+ [InlineData(2.5, 2.0903184e60)]
+ public void AreaFromSquareYardsShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareYards(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareMiles should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 2.589988110336e66)]
+ [InlineData(2.5, 6.47497027584e66)]
+ public void AreaFromSquareMilesShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareMiles(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareNauticalMiles should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 3.4299040000e66)]
+ [InlineData(2.5, 8.5747600000e66)]
+ public void AreaFromSquareNauticalMilesShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareNauticalMiles(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareFermis should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e30)]
+ [InlineData(2.5, 2.5e30)]
+ public void AreaFromSquareFermisShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareFermis(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareAngstroms should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1e40)]
+ [InlineData(2.5, 2.5e40)]
+ public void AreaFromSquareAngstromsShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareAngstroms(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareAstronomicalUnits should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 2.2379522821e82)]
+ [InlineData(2.5, 5.59488070525e82)]
+ public void AreaFromSquareAstronomicalUnitsShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareAstronomicalUnits(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareLightYears should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 8.9505421074819e91)]
+ [InlineData(2.5, 2.237635526870475e92)]
+ public void AreaFromSquareLightYearsShouldProduceExpectedSquareQuectoMeters(double value, double expectedSquareQuectoMeters)
+ {
+ // Given / When
+ Area a = Area.FromSquareLightYears(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Theory(DisplayName = "Area.FromSquareParsecs should produce the expected SquareQuectoMeters")]
+ [InlineData(0.0)]
+ [InlineData(1.0)]
+ [InlineData(2.5)]
+ public void AreaFromSquareParsecsShouldProduceExpectedSquareQuectoMeters(double value)
+ {
+ // Given
+ const double metersPerParsec = 1.495978707e11 * 648000.0 / Math.PI;
+ const double sqMetersPerSqParsec = metersPerParsec * metersPerParsec;
+ const double sqQmPerSqParsec = sqMetersPerSqParsec * 1e60;
+ double expectedSquareQuectoMeters = value * sqQmPerSqParsec;
+
+ // When
+ Area a = Area.FromSquareParsecs(value);
+
+ // Then
+ Assert.Equal(expectedSquareQuectoMeters, a.SquareQuectoMeters, Tolerance);
+ }
+
+ [Fact(DisplayName = "Area.Add should produce the expected result")]
+ public void AreaAddShouldProduceExpectedValue()
+ {
+ // Given
+ Area left = Area.FromSquareMeters(1500.0);
+ Area right = Area.FromSquareMeters(500.0);
+
+ // When
+ Area result = left.Add(right);
+
+ // Then
+ Assert.Equal(2000.0, result.SquareMeters, Tolerance);
+ }
+
+ [Fact(DisplayName = "Area.Subtract should produce the expected result")]
+ public void AreaSubtractShouldProduceExpectedValue()
+ {
+ // Given
+ Area left = Area.FromSquareMeters(1500.0);
+ Area right = Area.FromSquareMeters(400.0);
+
+ // When
+ Area result = left.Subtract(right);
+
+ // Then
+ Assert.Equal(1100.0, result.SquareMeters, Tolerance);
+ }
+
+ [Fact(DisplayName = "Area.Multiply should produce the expected result")]
+ public void AreaMultiplyShouldProduceExpectedValue()
+ {
+ // Given
+ Area left = Area.FromSquareMeters(10.0); // 1e61 sqQm
+ Area right = Area.FromSquareMeters(3.0); // 3e60 sqQm
+
+ // When
+ Area result = left.Multiply(right); // 1e61 * 3e60 = 3e121 sqQm
+
+ // Then
+ Assert.Equal(1e61, left.SquareQuectoMeters, Tolerance);
+ Assert.Equal(3e60, right.SquareQuectoMeters, Tolerance);
+ Assert.Equal(3e121, result.SquareQuectoMeters, Tolerance);
+ }
+
+ [Fact(DisplayName = "Area.Divide should produce the expected result")]
+ public void AreaDivideShouldProduceExpectedValue()
+ {
+ // Given
+ Area left = Area.FromSquareMeters(100.0); // 1e62 sqQm
+ Area right = Area.FromSquareMeters(20.0); // 2e61 sqQm
+
+ // When
+ Area result = left.Divide(right); // 1e62 / 2e61 = 5 sqQm
+
+ // Then
+ Assert.Equal(5.0, result.SquareQuectoMeters, Tolerance);
+ Assert.Equal(5e-60, result.SquareMeters, Tolerance);
+ }
+
+ [Fact(DisplayName = "Area comparison should produce the expected result (left equal to right)")]
+ public void AreaComparisonShouldProduceExpectedResultLeftEqualToRight()
+ {
+ // Given
+ Area left = Area.FromSquareMeters(1234.0);
+ Area right = Area.FromSquareMeters(1234.0);
+
+ // When / Then
+ Assert.Equal(0, Area.Compare(left, right));
+ Assert.Equal(0, left.CompareTo(right));
+ Assert.Equal(0, left.CompareTo((object)right));
+ Assert.False(left > right);
+ Assert.True(left >= right);
+ Assert.False(left < right);
+ Assert.True(left <= right);
+ }
+
+ [Fact(DisplayName = "Area comparison should produce the expected result (left greater than right)")]
+ public void AreaComparisonShouldProduceExpectedLeftGreaterThanRight()
+ {
+ // Given
+ Area left = Area.FromSquareMeters(4567.0);
+ Area right = Area.FromSquareMeters(1234.0);
+
+ // When / Then
+ Assert.Equal(1, Area.Compare(left, right));
+ Assert.Equal(1, left.CompareTo(right));
+ Assert.Equal(1, left.CompareTo((object)right));
+ Assert.True(left > right);
+ Assert.True(left >= right);
+ Assert.False(left < right);
+ Assert.False(left <= right);
+ }
+
+ [Fact(DisplayName = "Area comparison should produce the expected result (left less than right)")]
+ public void AreaComparisonShouldProduceExpectedLeftLessThanRight()
+ {
+ // Given
+ Area left = Area.FromSquareMeters(1234.0);
+ Area right = Area.FromSquareMeters(4567.0);
+
+ // When / Then
+ Assert.Equal(-1, Area.Compare(left, right));
+ Assert.Equal(-1, left.CompareTo(right));
+ Assert.Equal(-1, left.CompareTo((object)right));
+ Assert.False(left > right);
+ Assert.False(left >= right);
+ Assert.True(left < right);
+ Assert.True(left <= right);
+ }
+
+ [Fact(DisplayName = "Area equality should produce the expected result (left equal to right)")]
+ public void AreaEqualityShouldProduceExpectedResultLeftEqualToRight()
+ {
+ // Given
+ Area left = Area.FromSquareKilometers(2.0);
+ Area right = Area.FromSquareMeters(2000000.0);
+
+ // When / Then
+ Assert.True(Area.Equals(left, right));
+ Assert.True(left.Equals(right));
+ Assert.True(left.Equals((object)right));
+ Assert.True(left == right);
+ Assert.False(left != right);
+ }
+
+ [Fact(DisplayName = "Area equality should produce the expected result (left not equal to right)")]
+ public void AreaEqualityShouldProduceExpectedResultLeftNotEqualToRight()
+ {
+ // Given
+ Area left = Area.FromSquareKilometers(2.0);
+ Area right = Area.FromSquareMeters(2500000.0);
+
+ // When / Then
+ Assert.False(Area.Equals(left, right));
+ Assert.False(left.Equals(right));
+ Assert.False(left.Equals((object)right));
+ Assert.False(left == right);
+ Assert.True(left != right);
+ }
+
+ [Fact(DisplayName = "Area.ToString should produce the expected result")]
+ public void AreaToStringShouldProduceExpectedResult()
+ {
+ // Given
+ Area a = Area.FromSquareMeters(1000000.0);
+
+ // When / Then
+ Assert.Equal("1,000,000.000 m²", $"{a:sqm3}");
+ Assert.Equal("1.000 km²", $"{a:sqkm3}");
+ Assert.Equal("100.000 hm²", $"{a:sqhm3}");
+ Assert.Equal("10,000.000 dam²", $"{a:sqdam3}");
+ Assert.Equal("10,000,000,000.000 cm²", $"{a:sqcm3}");
+ Assert.Equal("1,550,003,100.006 in²", $"{a:sqin3}");
+ Assert.Equal("10,763,910.417 ft²", $"{a:sqft3}");
+ Assert.Equal("1,195,990.046 yd²", $"{a:sqyd3}");
+ }
+
+ [Fact(DisplayName = "Area.ToString should honor custom culture separators")]
+ public void AreaToStringShouldHonorCustomCulture()
+ {
+ // Given
+ CultureInfo customCulture = new("de-DE");
+ Area a = Area.FromSquareMeters(1234.56);
+
+ // When
+ string formatted = a.ToString("sqm2", customCulture);
+
+ // Then
+ Assert.Equal("1.234,56 m²", formatted);
+ }
+
+ [Fact(DisplayName = "Area property conversions should be consistent")]
+ public void AreaPropertyConversionsShouldBeConsistent()
+ {
+ // Given
+ Area a = Area.FromSquareMeters(1.0);
+
+ // Then - verify SI unit conversions are consistent
+ Assert.Equal(1.0, a.SquareMeters, Tolerance);
+ Assert.Equal(1e60, a.SquareQuectoMeters, Tolerance);
+ Assert.Equal(1e-6, a.SquareKiloMeters, Tolerance);
+ Assert.Equal(100.0, a.SquareDeciMeters, Tolerance);
+ Assert.Equal(10000.0, a.SquareCentiMeters, Tolerance);
+ Assert.Equal(1000000.0, a.SquareMilliMeters, Tolerance);
+ }
+
+ [Fact(DisplayName = "Area imperial unit conversions should be accurate")]
+ public void AreaImperialUnitConversionsShouldBeAccurate()
+ {
+ // Given - 1 square meter
+ Area a = Area.FromSquareMeters(1.0);
+
+ // Then - verify imperial conversions
+ Assert.Equal(1550.0031000062, a.SquareInches, 1e-6);
+ Assert.Equal(10.76391041671, a.SquareFeet, 1e-6);
+ Assert.Equal(1.1959900463011, a.SquareYards, 1e-6);
+ }
+
+ [Fact(DisplayName = "Area round-trip conversions should be accurate")]
+ public void AreaRoundTripConversionsShouldBeAccurate()
+ {
+ // Given
+ double originalValue = 123.456;
+
+ // When - convert from square meters and back
+ Area a = Area.FromSquareMeters(originalValue);
+
+ // Then
+ Assert.Equal(originalValue, a.SquareMeters, 1e-10);
+ }
+
+ [Fact(DisplayName = "Area from square kilometers to square meters should be accurate")]
+ public void AreaFromSquareKilometersToSquareMetersShouldBeAccurate()
+ {
+ // Given
+ Area a = Area.FromSquareKilometers(1.0);
+
+ // Then
+ Assert.Equal(1000000.0, a.SquareMeters, Tolerance);
+ }
+
+ [Fact(DisplayName = "Area from square miles to square kilometers should be accurate")]
+ public void AreaFromSquareMilesToSquareKilometersShouldBeAccurate()
+ {
+ // Given
+ Area a = Area.FromSquareMiles(1.0);
+
+ // Then - 1 square mile = 2.589988110336 square kilometers
+ Assert.Equal(2.589988110336, a.SquareKiloMeters, 1e-6);
+ }
+
+ [Fact(DisplayName = "Area GetHashCode should be consistent for equal values")]
+ public void AreaGetHashCodeShouldBeConsistentForEqualValues()
+ {
+ // Given
+ Area a1 = Area.FromSquareMeters(100.0);
+ Area a2 = Area.FromSquareMeters(100.0);
+
+ // Then
+ Assert.Equal(a1.GetHashCode(), a2.GetHashCode());
+ }
+
+ [Fact(DisplayName = "Area.Equals with null object should return false")]
+ public void AreaEqualsWithNullObjectShouldReturnFalse()
+ {
+ // Given
+ Area a = Area.FromSquareMeters(100.0);
+
+ // Then
+ Assert.False(a.Equals(null));
+ }
+
+ [Fact(DisplayName = "Area.Equals with different type should return false")]
+ public void AreaEqualsWithDifferentTypeShouldReturnFalse()
+ {
+ // Given
+ Area a = Area.FromSquareMeters(100.0);
+
+ // Then
+ Assert.False(a.Equals("not an area"));
+ }
+
+ [Fact(DisplayName = "Area default ToString should use SquareQuectoMeters")]
+ public void AreaDefaultToStringShouldUseSquareQuectoMeters()
+ {
+ // Given
+ Area a = Area.FromSquareQuectometers(123.0);
+
+ // When
+ string result = a.ToString();
+
+ // Then
+ Assert.Contains("qm²", result);
+ }
+}
diff --git a/OnixLabs.Units.UnitTests/DataSizeTests.cs b/OnixLabs.Units.UnitTests/DataSizeTests.cs
new file mode 100644
index 0000000..b13f6ce
--- /dev/null
+++ b/OnixLabs.Units.UnitTests/DataSizeTests.cs
@@ -0,0 +1,613 @@
+// Copyright 2020-2025 ONIXLabs
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using System.Globalization;
+
+namespace OnixLabs.Units.UnitTests;
+
+public sealed class DataSizeTests
+{
+ // IEEE-754 binary floating-point arithmetic causes small discrepancies in calculation, therefore we need a tolerance.
+ private const double Tolerance = 1e-12;
+
+ [Fact(DisplayName = "DataSize.Zero should produce the expected result")]
+ public void DataSizeZeroShouldProduceExpectedResult()
+ {
+ // Given / When
+ DataSize size = DataSize.Zero;
+
+ // Then
+ Assert.Equal(0.0, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(8.0, 8.0)]
+ [InlineData(1000.0, 1000.0)]
+ [InlineData(1024.0, 1024.0)]
+ [InlineData(8192.0, 8192.0)]
+ public void DataSizeFromBitsShouldProduceExpectedBits(double bits, double expectedBits)
+ {
+ // When
+ DataSize size = DataSize.FromBits(bits);
+
+ // Then
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 8.0)]
+ [InlineData(1000.0, 8000.0)]
+ [InlineData(1024.0, 8192.0)]
+ [InlineData(2048.0, 16384.0)]
+ public void DataSizeFromBytesShouldProduceExpectedBits(double bytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromBytes(bytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromKibiBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0)]
+ [InlineData(2.0, 2048.0)]
+ [InlineData(8.0, 8192.0)]
+ [InlineData(10.0, 10240.0)]
+ public void DataSizeFromKibiBitsShouldProduceExpectedBits(double kibibits, double expectedBits)
+ {
+ DataSize size = DataSize.FromKibiBits(kibibits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromKibiBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 8192.0)]
+ [InlineData(2.0, 16384.0)]
+ [InlineData(10.0, 81920.0)]
+ [InlineData(0.5, 4096.0)]
+ public void DataSizeFromKibiBytesShouldProduceExpectedBits(double kibibytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromKibiBytes(kibibytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromKiloBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0)]
+ [InlineData(8.0, 8000.0)]
+ [InlineData(10.0, 10000.0)]
+ [InlineData(0.5, 500.0)]
+ public void DataSizeFromKiloBitsShouldProduceExpectedBits(double kilobits, double expectedBits)
+ {
+ DataSize size = DataSize.FromKiloBits(kilobits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromKiloBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 8000.0)]
+ [InlineData(2.0, 16000.0)]
+ [InlineData(0.5, 4000.0)]
+ [InlineData(10.0, 80000.0)]
+ public void DataSizeFromKiloBytesShouldProduceExpectedBits(double kilobytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromKiloBytes(kilobytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromMebiBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0)]
+ public void DataSizeFromMebiBitsShouldProduceExpectedBits(double mebibits, double expectedBits)
+ {
+ DataSize size = DataSize.FromMebiBits(mebibits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromMebiBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 8.0)]
+ public void DataSizeFromMebiBytesShouldProduceExpectedBits(double mebibytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromMebiBytes(mebibytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromMegaBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0)]
+ [InlineData(10.0, 10.0 * 1000.0 * 1000.0)]
+ public void DataSizeFromMegaBitsShouldProduceExpectedBits(double megabits, double expectedBits)
+ {
+ DataSize size = DataSize.FromMegaBits(megabits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromMegaBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1000.0 * 1000.0 * 8.0)]
+ public void DataSizeFromMegaBytesShouldProduceExpectedBits(double megabytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromMegaBytes(megabytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromGibiBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 1024.0)]
+ public void DataSizeFromGibiBitsShouldProduceExpectedBits(double gibibits, double expectedBits)
+ {
+ DataSize size = DataSize.FromGibiBits(gibibits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromGibiBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ public void DataSizeFromGibiBytesShouldProduceExpectedBits(double gibibytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromGibiBytes(gibibytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromGigaBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(10.0, 10.0 * 1000.0 * 1000.0 * 1000.0)]
+ public void DataSizeFromGigaBitsShouldProduceExpectedBits(double gigabits, double expectedBits)
+ {
+ DataSize size = DataSize.FromGigaBits(gigabits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromGigaBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ public void DataSizeFromGigaBytesShouldProduceExpectedBits(double gigabytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromGigaBytes(gigabytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromTebiBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ public void DataSizeFromTebiBitsShouldProduceExpectedBits(double tebibits, double expectedBits)
+ {
+ DataSize size = DataSize.FromTebiBits(tebibits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromTebiBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ public void DataSizeFromTebiBytesShouldProduceExpectedBits(double tebibytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromTebiBytes(tebibytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromTeraBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(10.0, 10.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ public void DataSizeFromTeraBitsShouldProduceExpectedBits(double terabits, double expectedBits)
+ {
+ DataSize size = DataSize.FromTeraBits(terabits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromTeraBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ public void DataSizeFromTeraBytesShouldProduceExpectedBits(double terabytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromTeraBytes(terabytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromPebiBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ public void DataSizeFromPebiBitsShouldProduceExpectedBits(double pebibits, double expectedBits)
+ {
+ DataSize size = DataSize.FromPebiBits(pebibits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromPebiBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ public void DataSizeFromPebiBytesShouldProduceExpectedBits(double pebibytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromPebiBytes(pebibytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromPetaBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(10.0, 10.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ public void DataSizeFromPetaBitsShouldProduceExpectedBits(double petabits, double expectedBits)
+ {
+ DataSize size = DataSize.FromPetaBits(petabits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromPetaBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ public void DataSizeFromPetaBytesShouldProduceExpectedBits(double petabytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromPetaBytes(petabytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromExbiBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ public void DataSizeFromExbiBitsShouldProduceExpectedBits(double exbibits, double expectedBits)
+ {
+ DataSize size = DataSize.FromExbiBits(exbibits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromExbiBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ public void DataSizeFromExbiBytesShouldProduceExpectedBits(double exbibytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromExbiBytes(exbibytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromExaBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(10.0, 10.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ public void DataSizeFromExaBitsShouldProduceExpectedBits(double exabits, double expectedBits)
+ {
+ DataSize size = DataSize.FromExaBits(exabits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromExaBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ public void DataSizeFromExaBytesShouldProduceExpectedBits(double exabytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromExaBytes(exabytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromZebiBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ public void DataSizeFromZebiBitsShouldProduceExpectedBits(double zebibits, double expectedBits)
+ {
+ DataSize size = DataSize.FromZebiBits(zebibits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromZebiBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ public void DataSizeFromZebiBytesShouldProduceExpectedBits(double zebibytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromZebiBytes(zebibytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromZettaBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(10.0, 10.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ public void DataSizeFromZettaBitsShouldProduceExpectedBits(double zettabits, double expectedBits)
+ {
+ DataSize size = DataSize.FromZettaBits(zettabits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromZettaBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 8.0)]
+ public void DataSizeFromZettaBytesShouldProduceExpectedBits(double zettabytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromZettaBytes(zettabytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromYobiBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)]
+ public void DataSizeFromYobiBitsShouldProduceExpectedBits(double yobibits, double expectedBits)
+ {
+ DataSize size = DataSize.FromYobiBits(yobibits);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromYobiBytes should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(0.5, 0.5 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(2.0, 2.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ [InlineData(10.0, 10.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 8.0)]
+ public void DataSizeFromYobiBytesShouldProduceExpectedBits(double yobibytes, double expectedBits)
+ {
+ DataSize size = DataSize.FromYobiBytes(yobibytes);
+ Assert.Equal(expectedBits, size.Bits, Tolerance);
+ }
+
+ [Theory(DisplayName = "DataSize.FromYottaBits should produce the expected Bits")]
+ [InlineData(0.0, 0.0)]
+ [InlineData(1.0, 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(0.5, 0.5 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ [InlineData(2.0, 2.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0 * 1000.0)]
+ public void DataSizeFromYottaBitsShouldProduceExpectedBits(double yottabits, double expectedBits)
+ {
+ DataSize size = DataSize