本文整理汇总了C#中EventsHelper类的典型用法代码示例。如果您正苦于以下问题:C# EventsHelper类的具体用法?C# EventsHelper怎么用?C# EventsHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventsHelper类属于命名空间,在下文中一共展示了EventsHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XDocumentAddNull
public void XDocumentAddNull()
{
XElement xElem = new XElement("root", "text");
EventsHelper elemHelper = new EventsHelper(xElem);
xElem.FirstNode.AddBeforeSelf(null);
elemHelper.Verify(0);
}
示例2: XDocumentTypeDocTypeVariation
public void XDocumentTypeDocTypeVariation()
{
XDocumentType toChange = new XDocumentType("root", "", "", "");
XDocumentType original = new XDocumentType(toChange);
using (EventsHelper eHelper = new EventsHelper(toChange))
{
toChange.Name = "newName";
Assert.True(toChange.Name.Equals("newName"), "Name did not change");
eHelper.Verify(XObjectChange.Name, toChange);
}
}
示例3: ExecuteXDocumentVariation
public void ExecuteXDocumentVariation(XNode toReplace, XNode newValue)
{
XDocument xDoc = new XDocument(toReplace);
XDocument xDocOriginal = new XDocument(xDoc);
using (UndoManager undo = new UndoManager(xDoc))
{
undo.Group();
using (EventsHelper docHelper = new EventsHelper(xDoc))
{
toReplace.ReplaceWith(newValue);
docHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Add }, new XObject[] { toReplace, newValue });
}
undo.Undo();
Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
}
}
示例4: ExecuteXDocumentVariation
public void ExecuteXDocumentVariation(XNode[] content, int index)
{
XDocument xDoc = new XDocument(content);
XDocument xDocOriginal = new XDocument(xDoc);
XNode toRemove = xDoc.Nodes().ElementAt(index);
using (UndoManager undo = new UndoManager(xDoc))
{
undo.Group();
using (EventsHelper docHelper = new EventsHelper(xDoc))
{
toRemove.Remove();
docHelper.Verify(XObjectChange.Remove, toRemove);
}
undo.Undo();
Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
}
}
示例5: ExecuteXElementVariation
public void ExecuteXElementVariation(XElement toChange, XName newName)
{
XElement original = new XElement(toChange);
using (UndoManager undo = new UndoManager(toChange))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(toChange))
{
toChange.Name = newName;
Assert.True(newName.Namespace == toChange.Name.Namespace, "Namespace did not change");
Assert.True(newName.LocalName == toChange.Name.LocalName, "LocalName did not change");
eHelper.Verify(XObjectChange.Name, toChange);
}
undo.Undo();
Assert.True(XNode.DeepEquals(toChange, original), "Undo did not work");
}
}
示例6: XProcessingInstructionPIVariation
public void XProcessingInstructionPIVariation()
{
XProcessingInstruction toChange = new XProcessingInstruction("target", "data");
XProcessingInstruction original = new XProcessingInstruction(toChange);
using (UndoManager undo = new UndoManager(toChange))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(toChange))
{
toChange.Target = "newTarget";
Assert.True(toChange.Target.Equals("newTarget"), "Name did not change");
eHelper.Verify(XObjectChange.Name, toChange);
}
undo.Undo();
Assert.True(XNode.DeepEquals(toChange, original), "Undo did not work");
}
}
示例7: ExecuteXElementVariation
public void ExecuteXElementVariation(XNode toReplace, XNode newValue)
{
XElement xElem = new XElement("root", toReplace);
XElement xElemOriginal = new XElement(xElem);
using (UndoManager undo = new UndoManager(xElem))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(xElem))
{
toReplace.ReplaceWith(newValue);
xElem.Verify();
eHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Add }, new XObject[] { toReplace, newValue });
}
undo.Undo();
Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
}
}
示例8: ExecuteXElementVariation
public void ExecuteXElementVariation(XNode[] content, int index)
{
XElement xElem = new XElement("root", content);
XNode toRemove = xElem.Nodes().ElementAt(index);
XElement xElemOriginal = new XElement(xElem);
using (UndoManager undo = new UndoManager(xElem))
{
undo.Group();
using (EventsHelper elemHelper = new EventsHelper(xElem))
{
toRemove.Remove();
xElem.Verify();
elemHelper.Verify(XObjectChange.Remove, toRemove);
}
undo.Undo();
Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
}
}
示例9: ExecuteXDocumentVariation
public void ExecuteXDocumentVariation(XNode[] toAdd, XNode contextNode)
{
IEnumerable<XNode> toAddList = toAdd.OfType<XNode>();
XDocument xDoc = new XDocument(contextNode);
XDocument xDocOriginal = new XDocument(xDoc);
using (UndoManager undo = new UndoManager(xDoc))
{
undo.Group();
using (EventsHelper docHelper = new EventsHelper(xDoc))
{
using (EventsHelper nodeHelper = new EventsHelper(contextNode))
{
contextNode.AddBeforeSelf(toAdd);
Assert.True(toAddList.SequenceEqual(contextNode.NodesBeforeSelf(), XNode.EqualityComparer), "Nodes not added correctly!");
nodeHelper.Verify(0);
}
docHelper.Verify(XObjectChange.Add, toAdd);
}
undo.Undo();
Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
}
}
示例10: ExecuteXElementVariation
public void ExecuteXElementVariation(XNode[] toAdd, XNode contextNode)
{
IEnumerable<XNode> toAddList = toAdd.OfType<XNode>();
XElement xElem = new XElement("root", contextNode);
XElement xElemOriginal = new XElement(xElem);
using (UndoManager undo = new UndoManager(xElem))
{
undo.Group();
using (EventsHelper elemHelper = new EventsHelper(xElem))
{
using (EventsHelper nodeHelper = new EventsHelper(contextNode))
{
contextNode.AddBeforeSelf(toAdd);
Assert.True(toAddList.SequenceEqual(contextNode.NodesBeforeSelf(), XNode.EqualityComparer), "Nodes not added correctly!");
nodeHelper.Verify(0);
}
elemHelper.Verify(XObjectChange.Add, toAdd);
}
undo.Undo();
Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
}
}
示例11: XCommentChangeValue
public void XCommentChangeValue()
{
XComment toChange = new XComment("Original Value");
String newValue = "New Value";
XElement xElem = new XElement("root", toChange);
XElement xElemOriginal = new XElement(xElem);
using (UndoManager undo = new UndoManager(xElem))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(xElem))
{
using (EventsHelper comHelper = new EventsHelper(toChange))
{
toChange.Value = newValue;
Assert.True(toChange.Value.Equals(newValue), "Value did not change");
xElem.Verify();
comHelper.Verify(XObjectChange.Value, toChange);
}
eHelper.Verify(XObjectChange.Value, toChange);
}
undo.Undo();
Assert.True(XNode.DeepEquals(xElem, xElemOriginal), "Undo did not work!");
}
}
示例12: ExecuteXAttributeVariation
public void ExecuteXAttributeVariation(XAttribute toChange, object newValue)
{
XElement xElem = new XElement("root", toChange);
XElement xElemOriginal = new XElement(xElem);
using (UndoManager undo = new UndoManager(xElem))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(toChange))
{
xElem.SetAttributeValue(toChange.Name, newValue);
Assert.True(newValue.Equals(toChange.Value), "Value did not change");
xElem.Verify();
eHelper.Verify(XObjectChange.Value, toChange);
}
undo.Undo();
Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
}
}
示例13: ExecuteXElementVariation
public void ExecuteXElementVariation(XElement toChange, object newValue)
{
int count = toChange.Nodes().Count();
XElement xElemOriginal = new XElement(toChange);
using (UndoManager undo = new UndoManager(toChange))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(toChange))
{
toChange.SetValue(newValue);
Assert.True(newValue.Equals(toChange.Value), "Value change was not correct");
toChange.Verify();
eHelper.Verify(count + 1);
}
undo.Undo();
Assert.True(toChange.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
Assert.True(toChange.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
}
}
示例14: XDocumentTypeChangeInternalSubset
public void XDocumentTypeChangeInternalSubset()
{
XDocumentType toChange = new XDocumentType("root", "", "", "");
XDocument xDoc = new XDocument(toChange);
XDocument xDocOriginal = new XDocument(xDoc);
using (EventsHelper docHelper = new EventsHelper(xDoc))
{
using (EventsHelper typeHelper = new EventsHelper(toChange))
{
toChange.InternalSubset = "newValue";
Assert.True(toChange.InternalSubset.Equals("newValue"), "Internal Subset did not change");
typeHelper.Verify(XObjectChange.Value, toChange);
}
docHelper.Verify(XObjectChange.Value, toChange);
}
}
示例15: XElementWorkOnTextNodes2
public void XElementWorkOnTextNodes2()
{
XElement elem = new XElement("A", "text2");
XElement xElemOriginal = new XElement(elem);
using (UndoManager undo = new UndoManager(elem))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(elem))
{
elem.Add("text0", "text1");
Assert.Equal("text2text0text1", elem.Value);
eHelper.Verify(new XObjectChange[] { XObjectChange.Value, XObjectChange.Value });
}
undo.Undo();
Assert.Equal("text2", elem.Value);
}
}