public void RoundTripKnownUnits(DimensionAbbreviationUnitKeyScheme subject) { var units = new[] { Meters, Centimeters, Feet, Inches, Seconds, Minutes, Hours, Grams, PoundsMass, PoundsForce, Newtons, SquareMeters, SquareInches, CubicMeters, Pascals, PoundsPerSquareInch }; foreach (var unit in units) { var key = subject.GetKey(unit); subject.GetUnit(key).Should().Be(unit); } }
public void Exceptions(DimensionAbbreviationUnitKeyScheme subject) { // Mismatched dimension: ShouldThrow <KeyNotFoundException>(() => subject.GetUnit("DA1:Mass:m")); // Not a predefined unit: var derivedKey = subject.GetKey(Meters * Seconds); ShouldThrow <KeyNotFoundException>(() => subject.GetUnit(derivedKey)); // Wrong format: ShouldThrow <FormatException>(() => subject.GetUnit("")); ShouldThrow <FormatException>(() => subject.GetUnit("DA2:Length:m")); ShouldThrow <FormatException>(() => subject.GetUnit("DA1:Mass")); ShouldThrow <FormatException>(() => subject.GetUnit("DA1:Mass:kg:")); }