// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; using System.Windows; using ICSharpCode.AvalonEdit.Document; using NUnit.Framework; namespace ICSharpCode.AvalonEdit.Highlighting { [TestFixture] public class HtmlClipboardTests { TextDocument document; DocumentHighlighter highlighter; public HtmlClipboardTests() { document = new TextDocument("using System.Text;\n\tstring text = SomeMethod();"); highlighter = new DocumentHighlighter(document, HighlightingManager.Instance.GetDefinition("C#").MainRuleSet); } [Test] public void FullDocumentTest() { var segment = new TextSegment { StartOffset = 0, Length = document.TextLength }; string html = HtmlClipboard.CreateHtmlFragment(document, highlighter, segment, new HtmlOptions()); Assert.AreEqual("using " + "System.Text;
" + Environment.NewLine + "    string " + "text = SomeMethod();", html); } [Test] public void PartOfHighlightedWordTest() { var segment = new TextSegment { StartOffset = 1, Length = 3 }; string html = HtmlClipboard.CreateHtmlFragment(document, highlighter, segment, new HtmlOptions()); Assert.AreEqual("sin", html); } } }