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)); }
public void FromString_ValidString_CorrectQuantityType() { // Act var unitUnderTest = new LengthUsCustomary().FromString("1 yard"); // Assert Assert.That(unitUnderTest.QuantityType, Is.EqualTo(QuantityType.Length)); }
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)); }
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)); }
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); }); }
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")); }