/// <summary> /// Gets a macro by alias. /// </summary> /// <param name="alias">The alias.</param> /// <returns></returns> private MacroEditorModel GetMacroByAlias(string alias) { using (var uow = BackOfficeRequestContext .Application .Hive.OpenReader <IFileStore>(new Uri("storage://macros"))) { var filename = alias + ".macro"; var macroFile = uow.Repositories.Get <File>(new HiveId(filename)); if (macroFile == null) { throw new ApplicationException("Could not find a macro with the specified alias: " + alias); } return(MacroSerializer.FromXml(Encoding.UTF8.GetString(macroFile.ContentBytes))); } }
public void MacroSerializer_FromXml() { var xml = @"<macro id=""my-macro.macro"" alias=""test"" name=""Test"" cacheByPage=""true"" cachePeriodSeconds=""1234"" cachePersonalized=""false"" macroType=""ChildAction"" renderContentInEditor=""true"" selectedItem=""RenderTwitterFeed"" useInEditor=""false"" />"; var macro = MacroSerializer.FromXml(xml); Assert.AreEqual("test", macro.Alias); Assert.AreEqual("Test", macro.Name); Assert.AreEqual(true, macro.CacheByPage); Assert.AreEqual(1234, macro.CachePeriodSeconds); Assert.AreEqual(false, macro.CachePersonalized); Assert.AreEqual("ChildAction", macro.MacroType); Assert.AreEqual(true, macro.RenderContentInEditor); Assert.AreEqual("RenderTwitterFeed", macro.SelectedItem); Assert.AreEqual(false, macro.UseInEditor); //TODO: Test parameters }