public void BaseDimensionTest(UnitDimension unitDimension, UnitBaseQuantity unitBaseQuantity) { Assert.AreEqual(1, unitDimension.QuantityCount); foreach (var otherUnitBaseQuantity in UnitDimension.UnitBaseQuantities) { if (otherUnitBaseQuantity != unitBaseQuantity) { Assert.False(unitDimension.HasQuantity(otherUnitBaseQuantity)); } else { Assert.True(unitDimension.HasQuantity(otherUnitBaseQuantity)); } } Assert.AreEqual(1, unitDimension.GetPower(unitBaseQuantity)); }
public long GetPower(UnitBaseQuantity unitBaseQuantity) => BaseValues.TryGetValue(unitBaseQuantity, out long power) ? power : 0;
public bool HasQuantity(UnitBaseQuantity unitBaseQuantity) => BaseValues.ContainsKey(unitBaseQuantity) && BaseValues[unitBaseQuantity] != 0;
public UnitDimension(UnitBaseQuantity unitBaseQuantity) : this(q => unitBaseQuantity == q ? 1 : 0) { }