Example #1
0
 public void XDocumentAddNull()
 {
     XElement xElem = new XElement("root", "text");
     EventsHelper elemHelper = new EventsHelper(xElem);
     xElem.FirstNode.AddBeforeSelf(null);
     elemHelper.Verify(0);
 }
Example #2
0
 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);
     }
 }
Example #3
0
 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!");
     }
 }
Example #4
0
 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");
     }
 }
Example #5
0
 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!");
     }
 }
Example #6
0
 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");
     }
 }
Example #7
0
 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!");
     }
 }
Example #8
0
 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!");
     }
 }
Example #9
0
 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!");
     }
 }
Example #10
0
 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!");
     }
 }
Example #11
0
        public void XElementXElementAddAtDeepLevel()
        {
            XDocument xDoc         = new XDocument(InputSpace.GetElement(100, 10));
            XDocument xDocOriginal = new XDocument(xDoc);

            using (UndoManager undo = new UndoManager(xDoc))
            {
                undo.Group();
                using (EventsHelper docHelper = new EventsHelper(xDoc))
                {
                    using (EventsHelper eHelper = new EventsHelper(xDoc.Root))
                    {
                        foreach (XElement x in xDoc.Root.Descendants())
                        {
                            x.Add(new XText("Add Me"));
                            eHelper.Verify(XObjectChange.Add);
                        }
                        docHelper.Verify(XObjectChange.Add, xDoc.Root.Descendants().Count());
                    }
                }
                undo.Undo();
                Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
            }
        }
Example #12
0
        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!");
            }
        }
Example #13
0
 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!");
     }
 }
Example #14
0
 public void ExecuteXDocumentVariation(XNode toReplace)
 {
     XNode newValue = new XText(" ");
     XDocument xDoc = new XDocument(toReplace);
     XDocument xDocOriginal = new XDocument(xDoc);
     using (UndoManager undo = new UndoManager(xDoc))
     {
         undo.Group();
         using (EventsHelper docHelper = new EventsHelper(xDoc))
         {
             xDoc.ReplaceNodes(newValue);
             Assert.True(xDoc.Nodes().Count() == 1, "Not all content were removed");
             Assert.True(Object.ReferenceEquals(xDoc.FirstNode, newValue), "Did not replace correctly");
             docHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Add }, new XObject[] { toReplace, newValue });
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
     }
 }
Example #15
0
 public void XElementXElementAddAtDeepLevel()
 {
     XDocument xDoc = new XDocument(InputSpace.GetElement(100, 10));
     XDocument xDocOriginal = new XDocument(xDoc);
     using (UndoManager undo = new UndoManager(xDoc))
     {
         undo.Group();
         using (EventsHelper docHelper = new EventsHelper(xDoc))
         {
             using (EventsHelper eHelper = new EventsHelper(xDoc.Root))
             {
                 foreach (XElement x in xDoc.Root.Descendants())
                 {
                     x.Add(new XText("Add Me"));
                     eHelper.Verify(XObjectChange.Add);
                 }
                 docHelper.Verify(XObjectChange.Add, xDoc.Root.Descendants().Count());
             }
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
     }
 }
Example #16
0
 public void XElementWorkTextNodes()
 {
     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))
         {
             XNode x = elem.LastNode;
             eHelper.Verify(0);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(elem, xElemOriginal), "Undo did not work!");
     }
 }
Example #17
0
 public void ExecuteXElementVariation(XObject[] toReplace)
 {
     XNode newValue = new XText("text");
     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))
         {
             xElem.ReplaceAll(newValue);
             Assert.True(xElem.Nodes().Count() == 1, "Did not replace correctly");
             Assert.True(Object.ReferenceEquals(xElem.FirstNode, newValue), "Did not replace correctly");
             Assert.True(!xElem.HasAttributes, "ReplaceAll did not remove attributes");
             xElem.Verify();
             eHelper.Verify(toReplace.Length + 1);
         }
         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!");
     }
 }
Example #18
0
 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);
     }
 }
Example #19
0
 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!");
     }
 }
Example #20
0
 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);
     }
 }
        //[Variation(Priority = 0, Desc = "All elements from mixed content")]

        //[Variation(Priority = 0, Desc = "All content from the XDocument (doc level)")]

        public void AllFromDocument()
        {
            int count = 0;

            _runWithEvents = (bool)Params[0];
            XDocument           doc      = XDocument.Parse("\t<?PI?><A xmlns='a'/>\r\n <!--comment-->", LoadOptions.PreserveWhitespace);
            IEnumerable <XNode> toRemove = doc.Nodes();

            if (_runWithEvents)
            {
                _eHelper = new EventsHelper(doc);
                count    = toRemove.IsEmpty() ? 0 : toRemove.Count();
            }
            VerifyDeleteNodes(toRemove);
            if (_runWithEvents)
            {
                _eHelper.Verify(XObjectChange.Remove, count);
            }
        }
Example #22
0
 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);
 }
Example #23
0
 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!");
     }
 }
Example #24
0
 public void ExecuteRemoveVariation(XElement content)
 {
     XElement xElem = new XElement("root", content);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             xElem.SetElementValue(content.Name, null);
             xElem.Verify();
             eHelper.Verify(XObjectChange.Remove, content);
         }
         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!");
     }
 }
Example #25
0
 public void ExecuteXDocumentVariation(XNode[] toAdd, XNode contextNode)
 {
     IEnumerable<XNode> allNodes, toAddList = toAdd.OfType<XNode>();
     XDocument xDoc = contextNode == null ? new XDocument() : new XDocument(contextNode);
     XDocument xDocOriginal = new XDocument(xDoc);
     using (UndoManager undo = new UndoManager(xDoc))
     {
         undo.Group();
         using (EventsHelper docHelper = new EventsHelper(xDoc))
         {
             xDoc.Add(toAdd);
             allNodes = contextNode == null ? xDoc.Nodes() : contextNode.NodesAfterSelf();
             Assert.True(toAddList.SequenceEqual(allNodes, XNode.EqualityComparer), "Nodes not added correctly!");
             docHelper.Verify(XObjectChange.Add, toAdd);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
     }
 }
Example #26
0
 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);
     }
 }
Example #27
0
 public void ExecuteXElementVariation(XNode toReplace)
 {
     XNode newValue = new XText("text");
     XElement xElem = new XElement("root", InputSpace.GetAttributeElement(10, 1000).Elements().Attributes(), toReplace);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             xElem.ReplaceNodes(newValue);
             Assert.True(xElem.Nodes().Count() == 1, "Did not replace correctly");
             Assert.True(Object.ReferenceEquals(xElem.FirstNode, newValue), "Did not replace correctly");
             Assert.True(xElem.HasAttributes, "ReplaceNodes removed attributes");
             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!");
     }
 }
Example #28
0
 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!");
     }
 }
Example #29
0
 public void XElementReplaceNodes()
 {
     XElement xElem = new XElement(InputSpace.GetElement(1000, 2));
     int count = xElem.Nodes().Count();
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             foreach (XElement x in xElem.Nodes())
             {
                 using (EventsHelper xHelper = new EventsHelper(x))
                 {
                     x.ReplaceNodes("text");
                     xHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Remove, XObjectChange.Remove, XObjectChange.Add });
                 }
                 eHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Remove, XObjectChange.Remove, XObjectChange.Add });
             }
             undo.Undo();
             Assert.True(XNode.DeepEquals(xElem, xElemOriginal), "Undo did not work!");
         }
     }
 }
Example #30
0
 public void ExecuteValueVariation(XElement content, object newValue)
 {
     int count = content.Nodes().Count();
     XElement xElem = new XElement("root", content);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             xElem.SetElementValue(content.Name, newValue);
             // First all contents are removed and then new element with the value is added.
             xElem.Verify();
             eHelper.Verify(count + 1);
         }
         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!");
     }
 }
Example #31
0
 public void XElementReplaceWithIEnumerable()
 {
     XElement xElem = new XElement("root");
     IEnumerable<XNode> newValue = InputSpace.GetElement(1000, 2).DescendantNodes();
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             xElem.ReplaceNodes(newValue);
             eHelper.Verify(XObjectChange.Add, newValue.ToArray());
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xElem, xElemOriginal), "Undo did not work!");
     }
 }
Example #32
0
 public void XProcessingInstructionChangeValue()
 {
     XProcessingInstruction toChange = new XProcessingInstruction("target", "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 piHelper = new EventsHelper(toChange))
             {
                 toChange.Data = newValue;
                 Assert.True(toChange.Data.Equals(newValue), "Value did not change");
                 xElem.Verify();
                 piHelper.Verify(XObjectChange.Value, toChange);
             }
             eHelper.Verify(XObjectChange.Value, toChange);
         }
         undo.Undo();
         Assert.True(XNode.DeepEquals(xElem, xElemOriginal), "Undo did not work!");
     }
 }
Example #33
0
 public void ExecuteXAttributeVariation(XAttribute[] content)
 {
     XElement xElem = new XElement("root", content);
     XElement xElemOriginal = new XElement(xElem);
     using (UndoManager undo = new UndoManager(xElem))
     {
         undo.Group();
         using (EventsHelper eHelper = new EventsHelper(xElem))
         {
             xElem.ReplaceAttributes(new XAttribute("a", "aa"));
             Assert.True(XObject.ReferenceEquals(xElem.FirstAttribute, xElem.LastAttribute), "Did not replace attributes correctly");
             xElem.Verify();
             eHelper.Verify(content.Length + 1);
         }
         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!");
     }
 }