void AddFoldIfEndElementOnDifferentLineToStartElement(HtmlElementFold fold)
 {
     if (htmlReader.Line > fold.Line)
     {
         folds.Add(fold);
     }
 }
		public void GetFolds_HtmlWithSingleParagraphStartAndEndTag_ReturnsTwoFolds()
		{
			CreateParser();
			
			string text =
				"<html>\r\n" +
				"<p>\r\n" +
				"</p>\r\n" +
				"</html>";
			
			GetFolds(text);
			
			var expectedFolds = new HtmlElementFold[] {
				new HtmlElementFold() {
					ElementName = "html",
					StartOffset = 0,
					EndOffset = 26
				},
				new HtmlElementFold() {
					ElementName = "p",
					StartOffset = 8,
					EndOffset = 17
				}
			};
			
			CollectionAssert.AreEqual(expectedFolds, folds);
		}
Exemple #3
0
		void SaveFoldStartOnStack()
		{
			var fold = new HtmlElementFold() {
				ElementName = htmlReader.Value,
				StartOffset = htmlReader.Offset,
				Line = htmlReader.Line
			};
			foldStack.Push(fold);
		}
        void SaveFoldStartOnStack()
        {
            var fold = new HtmlElementFold()
            {
                ElementName = htmlReader.Value,
                StartOffset = htmlReader.Offset,
                Line        = htmlReader.Line
            };

            foldStack.Push(fold);
        }
		public void GetFolds_ParagraphStartAndEndTag_ReturnsOneFoldForParagraphTag()
		{
			CreateCSharpParser();
			
			string text =
				"<p>\r\n" +
				"</p>";
			
			GetFolds(text);
			
			var expectedFolds = new HtmlElementFold[] {
				new HtmlElementFold() {
					ElementName = "p",
					StartOffset = 0,
					EndOffset = 9
				}
			};
			
			CollectionAssert.AreEqual(expectedFolds, folds);
		}
		public void GetFolds_EndAnchorTagInsideIfStatement_ReturnsOneFoldForParagraphTagAndNotAnchorTag()
		{
			CreateCSharpParser();
			
			string text =
				"@if (i<a || b>i) {\r\n" +
				"    </a>\r\n" +
				"    <p>\r\n" +
				"    </p>\r\n" +
				"}\r\n";

			GetFolds(text);
			
			var expectedFolds = new HtmlElementFold[] {
				new HtmlElementFold() {
					ElementName = "p",
					StartOffset = 34,
					EndOffset = 47
				}
			};
			
			CollectionAssert.AreEqual(expectedFolds, folds);
		}
		void CreateHtmlElementFoldsForComparison()
		{
			lhs = new HtmlElementFold();
			rhs = new HtmlElementFold();
		}
		void CreateHtmlElementFoldWithElementName(string elementName)
		{
			fold = new HtmlElementFold() { ElementName = elementName };
		}
Exemple #9
0
		void AddFoldIfEndElementOnDifferentLineToStartElement(HtmlElementFold fold)
		{
			if (htmlReader.Line > fold.Line) {
				folds.Add(fold);
			}
		}
		public void GetFolds_ScriptTagAttributeHasAspxTagsInsideWithDoubleQuotes_ReturnsOneFoldIgnoringDoubleQuotesInsideScriptTagAttribute()
		{
			CreateParser();
			
			string text =
				"<script src=\"<%: Url.Content(\"~/Scripts/jquery.js\") %>\" type=\"text/javascript\">\r\n" +
				"</script>\r\n";
			
			GetFolds(text);
			
			var expectedFolds = new HtmlElementFold[] {
				new HtmlElementFold() {
					ElementName = "script",
					StartOffset = 0,
					EndOffset = 90
				}
			};
			
			CollectionAssert.AreEqual(expectedFolds, folds);
		}
		public void GetFolds_DivTagWithClassAttribute_ReturnsOneFold()
		{
			CreateParser();
			
			string text =
				"<div class=\"foo\">\r\n" +
				"</div>\r\n";
			
			GetFolds(text);
			
			var expectedFolds = new HtmlElementFold[] {
				new HtmlElementFold() {
					ElementName = "div",
					StartOffset = 0,
					EndOffset = 25
				}
			};
			
			CollectionAssert.AreEqual(expectedFolds, folds);
		}
		public void GetFolds_ParagraphTagsWithUnclosedBoldTagInside_ReturnsOneFoldForParagraphTag()
		{
			CreateParser();
			
			string text =
				"<p>\r\n" +
				"<b>\r\n" +
				"</p>";
			
			GetFolds(text);
			
			var expectedFolds = new HtmlElementFold[] {
				new HtmlElementFold() {
					ElementName = "p",
					StartOffset = 0,
					EndOffset = 14
				}
			};
			
			CollectionAssert.AreEqual(expectedFolds, folds);
		}