public void GetContextValue() { var vsite = new VSite() { Url = "siteurl", RootWeb = new VWeb { Title = "webtitle", Lists = new[] { new VList { Title = "TitleText", Description = "descriptiontext" } } } }; SubstitutionContext target = new SubstitutionContext(Properties.Resources.EventDataFileAdded, vsite.Site.RootWeb.Lists[0]); Assert.AreEqual("TitleText", target.GetContextValue("SList.Title", new ModifiersCollection())); Assert.AreEqual("descriptiontext", target.GetContextValue("SList.Description", new ModifiersCollection())); Assert.AreEqual("siteurl", target.GetContextValue("SSite.Url", new ModifiersCollection())); Assert.AreEqual("webtitle", target.GetContextValue("SWeb.Title", new ModifiersCollection())); }
public void Process() { var xlst = @"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'> <xsl:template match='Data'> <HTML> <BODY> <TABLE BORDER='2'> <TR> <TD>Field</TD> <TD>Old</TD> <TD>New</TD> </TR> <xsl:apply-templates select='EventData'/> </TABLE> </BODY> </HTML> </xsl:template> <xsl:template match='EventData'> <xsl:apply-templates select='Field'/> </xsl:template> <xsl:template match='Field'> <tr><td><xsl:value-of select='@DisplayName'/>(<xsl:value-of select='@Name'/>)</td><td><xsl:value-of select='@Old'/></td><td>New:<xsl:value-of select='@New'/></td></tr> </xsl:template> </xsl:stylesheet>"; var context = new SubstitutionContext(Properties.Resources.EventDataFileAdded); var xml = context.GetXML(); var subs = new XlstSubstitution(); var res = subs.Process(xlst, context); Assert.IsNotNull(res); Assert.IsTrue(res.Contains("TABLE")); }
public void Test() { var xlst = Properties.Resources.test; var context = new SubstitutionContext(Properties.Resources.EventDataFileAdded); var xml = context.GetXML(); var subs = new XlstSubstitution(); var res = subs.Process(xlst, context); Debug.WriteLine(res); Assert.IsNotNull(res); // Assert.IsTrue(res.Contains("TABLE")); }
public void GetFieldTest() { string eventData = Properties.Resources.EventDataFileAdded; SubstitutionContext target = new SubstitutionContext(eventData); Assert.AreEqual(@"TEST\administrator", target.GetCurrentFieldValue("Document Created By", new ModifiersCollection { Modifier.New })); Assert.AreEqual(null, target.GetCurrentFieldValue("Document Created By", new ModifiersCollection { Modifier.Old })); Assert.AreEqual(null, target.GetCurrentFieldValue("Author", new ModifiersCollection { Modifier.Old })); Assert.AreEqual(@"TEST\administrator", target.GetCurrentFieldValue("Author", new ModifiersCollection { Modifier.New })); Assert.AreEqual(@"TEST\administrator", target.GetCurrentFieldValue("Editor", new ModifiersCollection { Modifier.New })); Assert.AreEqual(null, target.GetCurrentFieldValue("Editor", new ModifiersCollection { Modifier.Old })); }
internal GeneratedMessage GetMessageForItem(Guid eventID, SPList list, int ItemID, SPEventType type, string eventXML, string modifierName, string receiverEmail, int alertCreatorID) { ISearchContext search = SearchContext.Create(list, ItemID, eventXML, type, receiverEmail); var res = TemplateManager.GetTemplate(search); if (res != null) { Logger.WriteTrace("Found template:" + Environment.NewLine + res.ToString(), SeverityEnum.Trace); var substitutionContext = new SubstitutionContext(eventID, eventXML, list, ItemID, modifierName, receiverEmail, alertCreatorID, type); Logger.WriteTrace("XML data:" + Environment.NewLine + substitutionContext.GetXML(), SeverityEnum.Trace); return(new GeneratedMessage { Body = GetProcessedItem(substitutionContext, res.Body, MessageFieldType.ForBody), Subject = GetProcessedItem(substitutionContext, res.Subject, MessageFieldType.ForSubject), From = GetProcessedItem(substitutionContext, res.From, MessageFieldType.ForFrom), Replay = GetProcessedItem(substitutionContext, res.Replay, MessageFieldType.ForReplay) }); } else { Logger.WriteTrace("Found template is null", SeverityEnum.Error); } return(null); }
public void SubstitutionContextConstructorTest() { string eventData = Properties.Resources.EventDataFileAdded; SubstitutionContext target = new SubstitutionContext(eventData); }