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); }
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); }
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); }