Esempio n. 1
0
        public void PathToSelectedElement_SetToNotNull_SelectedElementAdjusted()
        {
            myBrowser.LoadHtml(HtmlDocument1);
            var document = new HtmlDocumentAdapter(myBrowser.Document);

            var behavior = new HtmlMarkupBehavior <HtmlElementMarker>(new HtmlElementMarker(Color.Yellow));

            behavior.AttachTo(document);

            behavior.PathToSelectedElement = document.GetElementById("x11").GetPath().ToString();

            Assert.That(behavior.SelectedElement, Is.SameAs(document.GetElementById("x11")));
        }
Esempio n. 2
0
        public void PathToSelectedElement_NoDocumentAttached_PathSet()
        {
            var behavior = new HtmlMarkupBehavior <HtmlElementMarker>(new HtmlElementMarker(Color.Yellow));

            myBrowser.LoadHtml(HtmlDocument1);
            var document = new HtmlDocumentAdapter(myBrowser.Document);
            var path     = document.GetElementById("x11").GetPath().ToString();

            behavior.PathToSelectedElement = path;

            Assert.That(behavior.PathToSelectedElement, Is.EqualTo(path));
        }
Esempio n. 3
0
        public void PathToSelectedElement_WhenSet_SelectionChangedRaised()
        {
            myBrowser.LoadHtml(HtmlDocument1);
            var document = new HtmlDocumentAdapter(myBrowser.Document);

            var behavior = new HtmlMarkupBehavior <HtmlElementMarker>(new HtmlElementMarker(Color.Yellow));

            behavior.AttachTo(document);

            bool selectionChangedRaised = false;

            behavior.SelectionChanged += (s, e) => selectionChangedRaised = true;

            behavior.PathToSelectedElement = document.GetElementById("x11").GetPath().ToString();;

            Assert.That(selectionChangedRaised, Is.True);
        }
Esempio n. 4
0
        public void Detach_WhenCalled_SelectedElementAndPathAndDocumentNulled()
        {
            myBrowser.LoadHtml(HtmlDocument1);
            var document = new HtmlDocumentAdapter(myBrowser.Document);

            var behavior = new HtmlMarkupBehavior <HtmlElementMarker>(new HtmlElementMarker(Color.Yellow));

            behavior.AttachTo(document);

            behavior.SelectedElement = ( HtmlElementAdapter )document.GetElementById("x11");

            behavior.Detach();

            Assert.That(behavior.Document, Is.Null);
            Assert.That(behavior.SelectedElement, Is.Null);
            Assert.That(behavior.PathToSelectedElement, Is.Null);
        }
Esempio n. 5
0
        public void SelectedElement_NoDocumentAttached_Throws()
        {
            var behavior = new HtmlMarkupBehavior <HtmlElementMarker>(new HtmlElementMarker(Color.Yellow));

            myBrowser.LoadHtml(HtmlDocument1);
            var document = new HtmlDocumentAdapter(myBrowser.Document);
            var ex       = Assert.Throws <InvalidOperationException>(() => behavior.SelectedElement = ( HtmlElementAdapter )document.GetElementById("x11"));

            Assert.That(ex.Message, Does.Contain("Document not attached"));
        }