public void FromString_ValidString_CreatesQuantity(string asString, Type expectedType) { // Act var result = QuantityFactory.FromString(asString); // Assert Assert.That(result.GetType(), Is.EqualTo(expectedType)); }
public void FromString_LengthMetricString_CreatesLengthMetric(string asString) { // Arrange var test = QuantityFactory.FromString(asString); Assert.That(test, Is.Not.Null); Assert.That(test.QuantityType, Is.EqualTo(QuantityType.Length)); }
public void SubtractDouble_DifferentUnits_ExpectedBehavior(string valueA, double valueB, string expectedOutcome) { // Arrange var quantityA = QuantityFactory.FromString(valueA); // Act var actualResult = quantityA - valueB; // Assert Assert.That(actualResult.ToString(), Is.EqualTo(expectedOutcome)); }
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 FromString_InvalidString_ThrowsException() { // Act and assert Assert.Throws <ArgumentException>(() => QuantityFactory.FromString("1 kg")); }
public void FromString_UnknownUnit_ThrowsException() { Assert.Throws <ArgumentException>(() => QuantityFactory.FromString("1 FdL")); }