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
13 changes: 11 additions & 2 deletions UnitsNet.Tests/UnitSystemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,20 @@ public void ConstructorThrowsArgumentNullExceptionForNullBaseUnits()
[InlineData(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, null, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela)]
[InlineData(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, null, LuminousIntensityUnit.Candela)]
[InlineData(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, null)]
public void ConstructorThrowsArgumentExceptionWithUndefinedUnits(LengthUnit? length, MassUnit? mass, DurationUnit? time, ElectricCurrentUnit? current,
[InlineData(LengthUnit.Meter, null, null, null, null, null, null)]
public void ConstructorSupportsPartialDimensions(LengthUnit? length, MassUnit? mass, DurationUnit? time, ElectricCurrentUnit? current,
TemperatureUnit? temperature, AmountOfSubstanceUnit? amount, LuminousIntensityUnit? luminousIntensity)
{
var baseUnits = new BaseUnits(length, mass, time, current, temperature, amount, luminousIntensity);
Assert.Throws<ArgumentException>(() => new UnitSystem(baseUnits));
var unitSystem = new UnitSystem(baseUnits);

Assert.Equal(baseUnits, unitSystem.BaseUnits);
}

[Fact]
public void ConstructorThrowsArgumentExceptionWithUndefinedUnits()
{
Assert.Throws<ArgumentException>(() => new UnitSystem(BaseUnits.Undefined));
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions UnitsNet/UnitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public sealed class UnitSystem : IEquatable<UnitSystem>
/// <summary>
/// Creates an instance of a unit system with the specified base units.
/// </summary>
/// <param name="baseUnits">The base units for the unit system.</param>
/// <param name="baseUnits">One or more base units that define the unit system.</param>
public UnitSystem(BaseUnits baseUnits)
{
if (baseUnits is null) throw new ArgumentNullException(nameof(baseUnits));
if (!baseUnits.IsFullyDefined) throw new ArgumentException("A unit system must have all base units defined.", nameof(baseUnits));
if (baseUnits == BaseUnits.Undefined) throw new ArgumentException("A unit system must define at least one base unit.", nameof(baseUnits));

BaseUnits = baseUnits;
}
Expand Down
Loading