コード例 #1
0
        public void FromString_ValidString_CorrectUnitType(string asString)
        {
            // Act
            var unitUnderTest = new LengthUsCustomary().FromString(asString);

            // Assert
            Assert.That(unitUnderTest.UnitType, Is.EqualTo((ushort)Length.LengthUnit.UsCustomary));
        }
コード例 #2
0
        public void FromString_ValidString_CorrectQuantityType()
        {
            // Act
            var unitUnderTest = new LengthUsCustomary().FromString("1 yard");

            // Assert
            Assert.That(unitUnderTest.QuantityType, Is.EqualTo(QuantityType.Length));
        }
コード例 #3
0
        public void FromString_ValidStringWithSpaces_CorrectUnitSubType(string asString,
                                                                        LengthUsCustomary.UsCustomaryLengthUnit expectedMetricPrefix)
        {
            // Act
            var unitUnderTest = new LengthUsCustomary().FromString(asString);

            // Assert
            Assert.That(unitUnderTest.UnitSubType, Is.EqualTo((ushort)expectedMetricPrefix));
        }
コード例 #4
0
        public void ConvertValue_FromMileToBase_CorrectValue()
        {
            // Arrange
            var       unitUnderTest = new LengthUsCustomary().FromString("12 mile");
            const int expectedValue = 63360;

            // Act
            var actualValue = unitUnderTest.ValueInBaseUnitSubType;

            // Assert
            Assert.That(actualValue, Is.EqualTo(expectedValue));
        }
コード例 #5
0
        public void Constructor_InvalidDna_ThrowsException()
        {
            // Arrange
            var invalidDna = new QuantityDna
            {
                QuantityType = QuantityType.Length,
                UnitType     = (ushort)Length.LengthUnit.Metric,
                UnitSubType  = (ushort)LengthUsCustomary.UsCustomaryLengthUnit.Inch,
                Precision    = 2
            };

            // Act and Assert
            Assert.Throws <ArgumentException>(() =>
            {
                var unused = new LengthUsCustomary(invalidDna, 21.09);
            });
        }
コード例 #6
0
        public void Constructor_WithValidDna_CreatesLengthUsCustomary()
        {
            // Arrange
            var validDna = new QuantityDna
            {
                QuantityType = QuantityType.Length,
                UnitType     = (ushort)Length.LengthUnit.UsCustomary,
                UnitSubType  = (ushort)LengthUsCustomary.UsCustomaryLengthUnit.Inch,
                Precision    = 2
            };

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

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