示例#1
0
        public void FromString_ValidString_CreatesQuantity(string asString, Type expectedType)
        {
            // Act
            var result = QuantityFactory.FromString(asString);

            // Assert
            Assert.That(result.GetType(), Is.EqualTo(expectedType));
        }
示例#2
0
        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));
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }
示例#5
0
 public void FromString_InvalidString_ThrowsException()
 {
     // Act and assert
     Assert.Throws <ArgumentException>(() => QuantityFactory.FromString("1 kg"));
 }
示例#6
0
 public void FromString_UnknownUnit_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() => QuantityFactory.FromString("1 FdL"));
 }