예제 #1
0
        public void FromString_ValidString_CorrectUnitSubType(string asString, QuantityMetric.MetricPrefix expectedMetricPrefix)
        {
            // Act
            var unitUnderTest = new VolumeMetric().FromString(asString);

            // Assert
            Assert.That(unitUnderTest.UnitSubType, Is.EqualTo((ushort)expectedMetricPrefix));
        }
예제 #2
0
        public void FromString_ValidString_CorrectUnitType(string asString)
        {
            // Act
            var unitUnderTest = new VolumeMetric().FromString(asString);

            // Assert
            Assert.That(unitUnderTest.UnitType, Is.EqualTo((ushort)Volume.VolumeUnit.Metric));
        }
예제 #3
0
        public void FromString_ValidString_CorrectQuantityType(string baseString)
        {
            // Act
            var unitUnderTest = new VolumeMetric().FromString(baseString);

            // Assert
            Assert.That(unitUnderTest.QuantityType, Is.EqualTo(QuantityType.Volume));
        }
예제 #4
0
        public void Constructor_InvalidDna_ThrowsException()
        {
            // Arrange
            var invalidDna = new QuantityDna
            {
                QuantityType = QuantityType.Length,
                UnitType     = (ushort)Volume.VolumeUnit.Liter,
                UnitSubType  = (ushort)QuantityMetric.MetricPrefix.Base,
                Precision    = 2
            };

            // Act and Assert
            Assert.Throws <ArgumentException>(() =>
            {
                var unused = new VolumeMetric(invalidDna, 21.09);
            });
        }
예제 #5
0
        public void Constructor_WithValidDna_CreatesVolumeMetric()
        {
            // Arrange
            var validDna = new QuantityDna
            {
                QuantityType = QuantityType.Volume,
                UnitType     = (ushort)Volume.VolumeUnit.Metric,
                UnitSubType  = (ushort)QuantityMetric.MetricPrefix.Base,
                Precision    = 2
            };

            // Act
            var unitUnderTest = new VolumeMetric(validDna, 21.09);

            // Assert
            Assert.That(unitUnderTest.ToString(), Is.EqualTo("21,09m³"));
        }