public void FromString_ValidString_CorrectDecimals(string asString, int expectedDecimals) { // Arrange and act var unitUnderTest = new LengthMetric().FromString(asString); // Assert Assert.That(unitUnderTest.Precision, Is.EqualTo(expectedDecimals)); }
public void FromString_ValidStringWithSpaces_CorrectUnitSubType(string asString, QuantityMetric.MetricPrefix expectedMetricPrefix) { // Act var unitUnderTest = new LengthMetric().FromString(asString); // Assert Assert.That(unitUnderTest.UnitSubType, Is.EqualTo((ushort)expectedMetricPrefix)); }
public void FromString_validString_ValueConverted(string asString, double expectedValue) { // Arrange and act var unitUnderTest = new LengthMetric().FromString(asString + "m"); // Assert Assert.That(unitUnderTest.Value, Is.EqualTo(expectedValue)); }
public void FromString_ValidString_CorrectUnitType(string asString) { // Act var unitUnderTest = new LengthMetric().FromString(asString); // Assert Assert.That(unitUnderTest.UnitType, Is.EqualTo((ushort)Length.LengthUnit.Metric)); }
public void FromString_ValidString_CorrectQuantityType() { // Act var unitUnderTest = new LengthMetric().FromString("1 m"); // Assert Assert.That(unitUnderTest.QuantityType, Is.EqualTo(QuantityType.Length)); }
public void SubtractQuantity_SameUnits_ExpectedResult(string valueA, string valueB, string expectedOutcome) { var test = new LengthMetric(); // Arrange var quantityA = QuantityFactory.FromString(valueA); var quantityB = QuantityFactory.FromString(valueB); // Act var actualResult = (quantityA - quantityB).ToString(); // Assert Assert.That(actualResult, Is.EqualTo(expectedOutcome)); }
public void Constructor_InvalidDna_ThrowsException() { // Arrange var invalidDna = new QuantityDna { QuantityType = QuantityType.Length, UnitType = (ushort)Length.LengthUnit.Imperial, UnitSubType = (ushort)QuantityMetric.MetricPrefix.Base, Precision = 2 }; // Act and Assert Assert.Throws <ArgumentException>(() => { var unused = new LengthMetric(invalidDna, 21.09); }); }
public void Constructor_WithValidDna_CreatesLengthMetric() { // Arrange var validDna = new QuantityDna { QuantityType = QuantityType.Length, UnitType = (ushort)Length.LengthUnit.Metric, UnitSubType = (ushort)QuantityMetric.MetricPrefix.Base, Precision = 2 }; // Act var unitUnderTest = new LengthMetric(validDna, 21.09); // Assert Assert.That(unitUnderTest.ToString(), Is.EqualTo("21,09m")); }