Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        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)));
        }
Ejemplo n.º 5
0
        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)));
        }