public void ConvertFrom(UnitPartsConverterSource.Data data)
        {
            var converter = new UnitPartsConverter();

            Assert.IsTrue(converter.CanConvertFrom(null, typeof(string)));
            var parts = (UnitParts)converter.ConvertFrom(null, null, data.Value);

            Assert.IsTrue(data.Units.SequenceEqual(parts, UnitAndPower.Comparer));
            var convertTo = converter.ConvertTo(null, null, parts, typeof(string));

            Assert.AreEqual(data.Formatted, convertTo);
            Assert.AreEqual(data.Formatted, parts.BaseUnitExpression);
        }
예제 #2
0
        public static void ConvertFrom(TestCase testCase)
        {
            var converter = new UnitPartsConverter();

            Assert.IsTrue(converter.CanConvertFrom(null, typeof(string)));
            var parts = (UnitParts)converter.ConvertFrom(null, null, testCase.Value);

            CollectionAssert.AreEqual(testCase.Parts, parts);
            var convertTo = converter.ConvertTo(null, null, parts, typeof(string));

            Assert.AreEqual(testCase.Formatted, convertTo);
            Assert.AreEqual(testCase.Formatted, parts?.BaseUnitSymbol);
        }
예제 #3
0
        public void ConvertFrom(UnitPartsConverterSource.Data data)
        {
            var converter = new UnitPartsConverter();

            Assert.IsTrue(converter.CanConvertFrom(null, typeof(string)));
            var parts = (UnitParts)converter.ConvertFrom(null, null, data.Value);

            CollectionAssert.AreEqual(data.Parts, parts);
            var convertTo = converter.ConvertTo(null, null, parts, typeof(string));

            Assert.AreEqual(data.Formatted, convertTo);
            Assert.AreEqual(data.Formatted, parts.BaseUnitSymbol);
        }