Skip to content

Commit

Permalink
* IsBaseDimension unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ygorshkov committed Oct 25, 2024
1 parent 6f9382b commit 5104c51
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions UnitsNet.Tests/BaseDimensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,49 @@ public void ConstructorImplementedCorrectly()
[InlineData(0, 0, 0, 0, 1, 0, 0)]
[InlineData(0, 0, 0, 0, 0, 1, 0)]
[InlineData(0, 0, 0, 0, 0, 0, 1)]
public void IsBaseQuantityImplementedProperly(int length, int mass, int time, int current, int temperature, int amount, int luminousIntensity)
public void IsBaseQuantity_ForBaseQuantity_ReturnsTrue(int length, int mass, int time, int current, int temperature, int amount, int luminousIntensity)
{
var baseDimensions = new BaseDimensions(length, mass, time, current, temperature, amount, luminousIntensity);
var derivedDimensions = new BaseDimensions(length * 2, mass * 2, time * 2, current * 2, temperature * 2, amount * 2, luminousIntensity * 2);

Assert.True(baseDimensions.IsBaseQuantity());
}

[Theory]
[InlineData(2, 0, 0, 0, 0, 0, 0)]
[InlineData(0, 2, 0, 0, 0, 0, 0)]
[InlineData(0, 0, 2, 0, 0, 0, 0)]
[InlineData(0, 0, 0, 2, 0, 0, 0)]
[InlineData(0, 0, 0, 0, 2, 0, 0)]
[InlineData(0, 0, 0, 0, 0, 2, 0)]
[InlineData(0, 0, 0, 0, 0, 0, 2)]
public void IsBaseQuantity_ForDerivedQuantity_ReturnsFalse(int length, int mass, int time, int current, int temperature, int amount, int luminousIntensity)
{
var derivedDimensions = new BaseDimensions(length, mass, time, current, temperature, amount, luminousIntensity);
Assert.False(derivedDimensions.IsBaseQuantity());
}

[Theory]
[InlineData(1, 1, 0, 0, 0, 0, 0)]
[InlineData(0, 2, 1, 0, 0, 0, 0)]
[InlineData(0, 2, 1, 1, 0, 0, 0)]
[InlineData(1, 2, 1, 1, 1, 1, 1)]
[InlineData(0, 0, 1, 2, -2, 0, 0)]
[InlineData(0, 0, 2,-1, 0, 0, 0)]
[InlineData(0, 0, 0,-3, 1, 0, 0)]
[InlineData(0, 0, 0, 0,-4,-4, 0)]
public void IsBaseQuantity_ForMultipleDimensions_ReturnsFalse(int length, int mass, int time, int current, int temperature, int amount, int luminousIntensity)
{
var derivedDimensions = new BaseDimensions(length, mass, time, current, temperature, amount, luminousIntensity);
Assert.False(derivedDimensions.IsBaseQuantity());
}

[Fact]
public void IsBaseQuantityImplementedReallyProperly()
public void IsBaseQuantity_ForDimensionless_ReturnsFalse()
{
Assert.False(BaseDimensions.Dimensionless.IsBaseQuantity());
}

[Fact]
public void IsBaseQuantity_ForAcceleration_ReturnsFalse()
{
Assert.False(Acceleration.BaseDimensions.IsBaseQuantity());
}
Expand Down

0 comments on commit 5104c51

Please sign in to comment.