コード例 #1
0
ファイル: TestMacros.cs プロジェクト: seniorOtaka/ndoctor
        public void CreateMacro_UsingUnknownMarkups_ExceptionIsThrown()
        {
            var macro = "Hello $unknown$ $LASTNAME$";
            var patient = new Patient() { FirstName = "ROBERT", LastName = "DUPONT" };

            var builder = new MacroBuilder(patient);
            Assert.Throws<InvalidMacroException>(() => builder.Resolve(macro));
        }
コード例 #2
0
ファイル: TestMacros.cs プロジェクト: seniorOtaka/ndoctor
        public void CreateMacro_UsingUpperCaseMarkups_MarkupsReplacesWithValues()
        {
            var robert = "Robert";
            var dupont = "Dupont";

            var macro = "Hello $FIRSTNAME$ $LASTNAME$";
            var expected = "Hello " + robert + " " + dupont;

            var patient = new Patient() { FirstName = robert, LastName = dupont };

            var builder = new MacroBuilder(patient);
            var result = builder.Resolve(macro);

            Assert.AreEqual(expected, result);
        }
コード例 #3
0
ファイル: TestMacros.cs プロジェクト: seniorOtaka/ndoctor
        public void CreateMacro_ReplaceFullName_MarkupsReplacedWithValue()
        {
            var robert = "Robert";
            var dupont = "Dupont";

            var macro = "Hello $firstname$ $lastname$";
            var expected = "Hello " + robert + " " + dupont;

            var patient = new Patient() { FirstName = robert, LastName = dupont };

            var builder = new MacroBuilder(patient);
            var result = builder.Resolve(macro);

            Assert.AreEqual(expected, result);
        }
コード例 #4
0
        /// <summary>
        /// Resolves the specified macro with the data of the specified patient.
        /// </summary>
        /// <param name="macro">The macro.</param>
        /// <param name="patient">The patient.</param>
        /// <returns></returns>
        public string Resolve(MacroDto macro, LightPatientDto patient)
        {
            if (macro == null || patient == null) return string.Empty;

            var p = this.Session.Get<Patient>(patient.Id);
            if (p == null) throw new EntityNotFoundException(typeof(Patient));

            var builder = new MacroBuilder(p);
            return builder.Resolve(macro.Expression);
        }