public void ToString_GyUnit_ReturnsString(string doseStr, DoseUnit displayUnit, int displayDecimals, string expectedDoseStr) { Dose.DisplayUnit = displayUnit; Dose.DisplayDecimals = displayDecimals; var dose = Dose.Parse(doseStr); var result = dose.ToString(); Assert.That(result, Is.EqualTo(expectedDoseStr)); }
/// <summary> /// Creates an instance of Dose. /// </summary> /// <param name="dose">The dose value.</param> /// <param name="unit">The dose unit.</param> public Dose(double dose, DoseUnit unit) { switch (unit) { case DoseUnit.Gy: Gy = dose; break; case DoseUnit.CGy: Gy = CGyToGy(dose); break; default: throw new ArgumentOutOfRangeException(nameof(unit), unit, null); } }
public void ConvertUnits(DoseUnit desiredUnits) { if (!PrescriptionDoseGy.HasValue) { return; } if (desiredUnits == D.DoseUnit.ABSOLUTE && DoseUnit == D.DoseUnit.RELATIVE) { _mat = PrescriptionDoseGy.Value * _mat; MaxDose *= (float)PrescriptionDoseGy.Value; DoseUnit = D.DoseUnit.ABSOLUTE; } else if (desiredUnits == D.DoseUnit.RELATIVE && DoseUnit == D.DoseUnit.ABSOLUTE) { _mat = 1 / PrescriptionDoseGy.Value * _mat; MaxDose /= (float)PrescriptionDoseGy.Value; DoseUnit = D.DoseUnit.RELATIVE; } }
public void TryParse_Validdose_ReturnsTrueAndParsedDose(string doseStr, double expectedDoseValue, DoseUnit expectedDoseUnit) { var parsed = Dose.TryParse(doseStr, out var dose); Assert.That(parsed, Is.True); Assert.That(dose, Is.EqualTo(new Dose(expectedDoseValue, expectedDoseUnit))); }
public void Parse_ValidDose_ReturnsParsedDose(string doseStr, double expectedDoseValue, DoseUnit expectedDoseUnit) { var dose = Dose.Parse(doseStr); Assert.That(dose, Is.EqualTo(new Dose(expectedDoseValue, expectedDoseUnit))); }