本文整理汇总了C#中EventsHelper.Verify方法的典型用法代码示例。如果您正苦于以下问题:C# EventsHelper.Verify方法的具体用法?C# EventsHelper.Verify怎么用?C# EventsHelper.Verify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventsHelper
的用法示例。
在下文中一共展示了EventsHelper.Verify方法的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: 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");
}
}
示例5: 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!");
}
}
示例6: 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");
}
}
示例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: AddAndRemoveEventListnersXElementAddRemoveEventListners
public void AddAndRemoveEventListnersXElementAddRemoveEventListners()
{
XDocument xDoc = new XDocument(InputSpace.GetElement(10, 10));
EventsHelper docHelper = new EventsHelper(xDoc);
EventsHelper eHelper = new EventsHelper(xDoc.Root);
xDoc.Root.Add(new XElement("Add", "Me"));
docHelper.Verify(XObjectChange.Add);
eHelper.Verify(XObjectChange.Add);
eHelper.RemoveListners();
xDoc.Root.Add(new XComment("Comment"));
eHelper.Verify(0);
docHelper.Verify(XObjectChange.Add);
}
示例13: ExecuteXAttributeVariation
public void ExecuteXAttributeVariation(XAttribute[] toAdd, XAttribute contextNode)
{
IEnumerable<XAttribute> allNodes, toAddList = toAdd.OfType<XAttribute>();
XElement xElem = contextNode == null ? new XElement("root") : new XElement("root", contextNode);
XElement xElemOriginal = new XElement(xElem);
using (UndoManager undo = new UndoManager(xElem))
{
undo.Group();
using (EventsHelper elemHelper = new EventsHelper(xElem))
{
xElem.Add(toAdd);
allNodes = contextNode == null ? xElem.Attributes() : xElem.Attributes().Skip(1);
Assert.True(toAddList.SequenceEqual(allNodes, Helpers.MyAttributeComparer), "Attributes not added correctly!");
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!");
}
}
示例14: 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!");
}
}
示例15: XElementWorkOnTextNodes1
public void XElementWorkOnTextNodes1()
{
XElement elem = new XElement("A", "text2");
XNode n = elem.FirstNode;
using (UndoManager undo = new UndoManager(elem))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(elem))
{
n.AddBeforeSelf("text0");
Assert.Equal("text0text2", elem.Value);
n.AddBeforeSelf("text1");
Assert.Equal("text0text1text2", elem.Value);
eHelper.Verify(new XObjectChange[] { XObjectChange.Add, XObjectChange.Value });
}
undo.Undo();
Assert.Equal("text2", elem.Value);
}
}