コード例 #1
0
        public void ObserveChildNodes_callback_should_be_noop(MutationData data)
        {
            var doc = new DomDocument().LoadXml(@"
                <root><a/><b/><c/></root>
            ");

            var element = doc.DocumentElement;
            var evts    = new TestActionDispatcher <DomMutationEvent>(_ => {});

            doc.ObserveChildNodes(element, evts.Invoke);
            data.Action(element);

            Assert.Equal(0, evts.CallCount);
        }
コード例 #2
0
        public void ObserveChildNodes_callback_should_be_invoked_on_mutation_nodes(MutationData data)
        {
            var doc = new DomDocument().LoadXml(@"
                <root><a/><b/><c/></root>
            ");

            var element  = doc.DocumentElement;
            var evts     = new TestActionDispatcher <DomMutationEvent>(_ => {});
            var expected = data.Event(element);

            doc.ObserveChildNodes(element, evts.Invoke);

            data.Action(element);
            var actuallyAddedNodes = data.Event(element).AddedNodes;

            Assert.Equal(1, evts.CallCount);
            Assert.Equal(actuallyAddedNodes.NodeNames(), evts.ArgsForCall(0).AddedNodes.NodeNames());
            Assert.Equal(expected.RemovedNodes.NodeNames(), evts.ArgsForCall(0).RemovedNodes.NodeNames());
            Assert.Same(expected.NextSiblingNode, evts.ArgsForCall(0).NextSiblingNode);
            Assert.Same(expected.PreviousSiblingNode, evts.ArgsForCall(0).PreviousSiblingNode);
        }