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