Example #1
0
 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));
 }
Example #2
0
 public long GetPower(UnitBaseQuantity unitBaseQuantity) => BaseValues.TryGetValue(unitBaseQuantity, out long power) ? power : 0;
Example #3
0
 public bool HasQuantity(UnitBaseQuantity unitBaseQuantity) => BaseValues.ContainsKey(unitBaseQuantity) && BaseValues[unitBaseQuantity] != 0;
Example #4
0
 public UnitDimension(UnitBaseQuantity unitBaseQuantity) : this(q => unitBaseQuantity == q ? 1 : 0)
 {
 }