public void AddDimension_AllreadyAddedDimension_ThrowsArgumentException() { // Arrange UnitSystem system = new UnitSystem(); IDimension dimension = CreateStubDimension("M"); system.AddDimension(dimension); // Act/assert Assert.Throws <ArgumentException>(() => system.AddDimension(dimension)); }
private static void AddTemperature(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.Temperature); si.AddBaseUnit(StandardUnitsCatalog.Kelvin); AddScaledUnit(si, StandardUnitsCatalog.Kelvin, StandardUnitsCatalog.Celcius, 1.0, -273.15); AddScaledUnit(si, StandardUnitsCatalog.Celcius, StandardUnitsCatalog.Fahrenheit, 9.0 / 5.0, 32.0); }
private static void AddArea(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.Area); si.AddBaseUnit(StandardUnitsCatalog.SquareMeter); AddScaledUnit(si, StandardUnitsCatalog.SquareMeter, StandardUnitsCatalog.SquareKilometer, 1.0 / (1000.0 * 1000.0)); AddScaledUnit(si, StandardUnitsCatalog.SquareMeter, StandardUnitsCatalog.SquareCentimeter, 100.0 * 100.0); }
private static void AddMass(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.Mass); si.AddBaseUnit(StandardUnitsCatalog.Kilogram); AddScaledUnit(si, StandardUnitsCatalog.Kilogram, StandardUnitsCatalog.Gram, 1000.0); AddScaledUnit(si, StandardUnitsCatalog.Kilogram, StandardUnitsCatalog.Tonne, 1.0 / 1000.0); }
private static void AddLength(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.Length); si.AddBaseUnit(StandardUnitsCatalog.Meter); AddScaledUnit(si, StandardUnitsCatalog.Meter, StandardUnitsCatalog.Centimeter, 100.0); AddScaledUnit(si, StandardUnitsCatalog.Meter, StandardUnitsCatalog.Desimeter, 10.0); AddScaledUnit(si, StandardUnitsCatalog.Meter, StandardUnitsCatalog.Kilometer, 1.0 / 1000.0); }
private static void AddTime(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.Time); si.AddBaseUnit(StandardUnitsCatalog.Second); AddScaledUnit(si, StandardUnitsCatalog.Second, StandardUnitsCatalog.Minute, 1.0 / 60.0); AddScaledUnit(si, StandardUnitsCatalog.Minute, StandardUnitsCatalog.Hour, 1.0 / 60.0); AddScaledUnit(si, StandardUnitsCatalog.Hour, StandardUnitsCatalog.Hour, 1.0 / 24.0); }
public void AddDimension_ValidDimension_DoesNotThrow() { // Arrange UnitSystem system = new UnitSystem(); IDimension dimension = CreateStubDimension("M"); // Act/assert Assert.DoesNotThrow(() => system.AddDimension(dimension)); }
public void Clone_SingleDimensionSystem_ResultHasSameDimension() { // Arrange var mockConverter = new Mock <IValueConverter>(); UnitSystem system = new UnitSystem(); IDimension dimension = CreateStubDimension("M"); IUnit baseunit = CreateStubUnit("base", dimension); IUnit scaledunit = CreateStubUnit("scaled", dimension); system.AddDimension(dimension); system.AddBaseUnit(baseunit); system.AddScaledUnit(baseunit, scaledunit, mockConverter.Object); // Act UnitSystem clone = (UnitSystem)system.Clone(); // Assert CollectionAssert.AreEquivalent(system.Dimensions, clone.Dimensions); }
public void CreateConverter_AnchestorUnits_CanCreateConverters() { // Arrange var mockConverter = new Mock <IValueConverter>(); UnitSystem system = new UnitSystem(); IDimension dimension = CreateStubDimension("M"); IUnit baseunit = CreateStubUnit("base", dimension); IUnit scaledunit = CreateStubUnit("scaled", dimension); system.AddDimension(dimension); system.AddBaseUnit(baseunit); system.AddScaledUnit(baseunit, scaledunit, mockConverter.Object); // Act IValueConverter toScaledConverter = system.CreateConverter(baseunit, scaledunit); IValueConverter fromScaledConverter = system.CreateConverter(scaledunit, baseunit); // Assert Assert.NotNull(toScaledConverter); Assert.NotNull(fromScaledConverter); }
public void CreateConverter_IndirectlyRelatedUnits_CanCreateConverters() { // Arrange UnitSystem system = new UnitSystem(); IDimension dimension = CreateStubDimension("M"); IUnit baseunit = CreateStubUnit("base", dimension); IUnit scaledunit1 = CreateStubUnit("scaled1", dimension); IUnit scaledunit2 = CreateStubUnit("scaled2", dimension); system.AddDimension(dimension); system.AddBaseUnit(baseunit); // Conversion between scaleduni1 and scaledunit2 through baseunit system.AddScaledUnit(baseunit, scaledunit1, CreateStubConverter(baseunit, scaledunit1)); system.AddScaledUnit(baseunit, scaledunit2, CreateStubConverter(baseunit, scaledunit2)); // Act IValueConverter converter = system.CreateConverter(scaledunit1, scaledunit2); // Assert Assert.NotNull(converter); }
private static void AddLuminousIntensity(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.LuminousIntensity); si.AddBaseUnit(StandardUnitsCatalog.Candela); }
private static void AddEnergy(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.Energy); si.AddBaseUnit(StandardUnitsCatalog.Joule); }
private static void AddForce(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.Force); si.AddBaseUnit(StandardUnitsCatalog.Newton); }
private static void AddSpeed(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.Speed); si.AddBaseUnit(StandardUnitsCatalog.MetersPerSecond); AddScaledUnit(si, StandardUnitsCatalog.MetersPerSecond, StandardUnitsCatalog.KilometersPerHour, 1.0 / 3.6); }
private static void AddPressure(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.Pressure); si.AddBaseUnit(StandardUnitsCatalog.Pascal); }
private static void AddVolume(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.Volume); si.AddBaseUnit(StandardUnitsCatalog.CubicMeter); AddScaledUnit(si, StandardUnitsCatalog.CubicMeter, StandardUnitsCatalog.Liter, 1000.0); }
private static void AddAmountOfSubstance(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.AmountOfSubstance); si.AddBaseUnit(StandardUnitsCatalog.Mole); }
private static void AddElectricCurrent(UnitSystem si) { si.AddDimension(StandardDimensionsCatalog.ElectricCurrent); si.AddBaseUnit(StandardUnitsCatalog.Amper); }