You've already forked linux-packaging-mono
acceptance-tests
data
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
packages
src
test
Microsoft.TestCommon
Microsoft.Web.Helpers.Test
Microsoft.Web.Http.Data.Test
Microsoft.Web.Mvc.Test
Microsoft.Web.WebPages.OAuth.Test
SPA.Test
System.Json.Test.Integration
System.Json.Test.Unit
System.Net.Http.Formatting.Test.Integration
System.Net.Http.Formatting.Test.Unit
System.Web.Helpers.Test
System.Web.Http.Integration.Test
System.Web.Http.SelfHost.Test
System.Web.Http.Test
System.Web.Http.WebHost.Test
System.Web.Mvc.Test
System.Web.Razor.Test
Editor
Framework
Generator
Parser
CSharp
Html
HtmlAttributeTest.cs
HtmlBlockTest.cs
HtmlDocumentTest.cs
HtmlErrorTest.cs
HtmlParserTestUtils.cs
HtmlTagsTest.cs
HtmlToCodeSwitchTest.cs
HtmlUrlAttributeTest.cs
Old
PartialParsing
VB
BlockTest.cs
CallbackParserListenerTest.cs
ParserContextTest.cs
ParserVisitorExtensionsTest.cs
RazorParserTest.cs
WhitespaceRewriterTest.cs
Properties
TestFiles
Text
Tokenizer
Utils
CSharpRazorCodeLanguageTest.cs
CodeCompileUnitExtensions.cs
RazorCodeLanguageTest.cs
RazorDirectiveAttributeTest.cs
RazorEngineHostTest.cs
RazorTemplateEngineTest.cs
StringTextBuffer.cs
System.Web.Razor.Test.csproj
VBRazorCodeLanguageTest.cs
packages.config
System.Web.WebPages.Administration.Test
System.Web.WebPages.Deployment.Test
System.Web.WebPages.Razor.Test
System.Web.WebPages.Test
WebMatrix.Data.Test
WebMatrix.WebData.Test
Settings.StyleCop
tools
.gitattributes
.gitignore
License.txt
README.md
Runtime.msbuild
Runtime.sln
Runtime.xunit
Settings.StyleCop
build.cmd
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
ikvm-native
libgc
llvm
m4
man
mcs
mk
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
90 lines
4.0 KiB
C#
90 lines
4.0 KiB
C#
![]() |
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
|||
|
|
|||
|
using System.Web.Razor.Generator;
|
|||
|
using System.Web.Razor.Parser.SyntaxTree;
|
|||
|
using System.Web.Razor.Resources;
|
|||
|
using System.Web.Razor.Test.Framework;
|
|||
|
using System.Web.Razor.Text;
|
|||
|
using Xunit;
|
|||
|
|
|||
|
namespace System.Web.Razor.Test.Parser.Html
|
|||
|
{
|
|||
|
public class HtmlErrorTest : CsHtmlMarkupParserTestBase
|
|||
|
{
|
|||
|
[Fact]
|
|||
|
public void ParseBlockAllowsInvalidTagNamesAsLongAsParserCanIdentifyEndTag()
|
|||
|
{
|
|||
|
SingleSpanBlockTest("<1-foo+bar>foo</1-foo+bar>", BlockType.Markup, SpanKind.Markup, acceptedCharacters: AcceptedCharacters.None);
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public void ParseBlockThrowsErrorIfStartTextTagContainsTextAfterName()
|
|||
|
{
|
|||
|
ParseBlockTest("<text foo bar></text>",
|
|||
|
new MarkupBlock(
|
|||
|
Factory.MarkupTransition("<text").Accepts(AcceptedCharacters.Any),
|
|||
|
Factory.Markup(" foo bar>"),
|
|||
|
Factory.MarkupTransition("</text>")),
|
|||
|
new RazorError(RazorResources.ParseError_TextTagCannotContainAttributes, SourceLocation.Zero));
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public void ParseBlockThrowsErrorIfEndTextTagContainsTextAfterName()
|
|||
|
{
|
|||
|
ParseBlockTest("<text></text foo bar>",
|
|||
|
new MarkupBlock(
|
|||
|
Factory.MarkupTransition("<text>"),
|
|||
|
Factory.MarkupTransition("</text").Accepts(AcceptedCharacters.Any),
|
|||
|
Factory.Markup(" ")),
|
|||
|
new RazorError(RazorResources.ParseError_TextTagCannotContainAttributes, 6, 0, 6));
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public void ParseBlockThrowsExceptionIfBlockDoesNotStartWithTag()
|
|||
|
{
|
|||
|
ParseBlockTest("foo bar <baz>",
|
|||
|
new MarkupBlock(),
|
|||
|
new RazorError(RazorResources.ParseError_MarkupBlock_Must_Start_With_Tag, SourceLocation.Zero));
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public void ParseBlockStartingWithEndTagProducesRazorErrorThenOutputsMarkupSegmentAndEndsBlock()
|
|||
|
{
|
|||
|
ParseBlockTest("</foo> bar baz",
|
|||
|
new MarkupBlock(
|
|||
|
Factory.Markup("</foo> ").Accepts(AcceptedCharacters.None)),
|
|||
|
new RazorError(String.Format(RazorResources.ParseError_UnexpectedEndTag, "foo"), SourceLocation.Zero));
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public void ParseBlockWithUnclosedTopLevelTagThrowsMissingEndTagParserExceptionOnOutermostUnclosedTag()
|
|||
|
{
|
|||
|
ParseBlockTest("<p><foo></bar>",
|
|||
|
new MarkupBlock(
|
|||
|
Factory.Markup("<p><foo></bar>").Accepts(AcceptedCharacters.None)),
|
|||
|
new RazorError(String.Format(RazorResources.ParseError_MissingEndTag, "p"), new SourceLocation(0, 0, 0)));
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public void ParseBlockWithUnclosedTagAtEOFThrowsMissingEndTagException()
|
|||
|
{
|
|||
|
ParseBlockTest("<foo>blah blah blah blah blah",
|
|||
|
new MarkupBlock(
|
|||
|
Factory.Markup("<foo>blah blah blah blah blah")),
|
|||
|
new RazorError(String.Format(RazorResources.ParseError_MissingEndTag, "foo"), new SourceLocation(0, 0, 0)));
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public void ParseBlockWithUnfinishedTagAtEOFThrowsIncompleteTagException()
|
|||
|
{
|
|||
|
ParseBlockTest("<foo bar=baz",
|
|||
|
new MarkupBlock(
|
|||
|
Factory.Markup("<foo"),
|
|||
|
new MarkupBlock(new AttributeBlockCodeGenerator("bar", new LocationTagged<string>(" bar=", 4, 0, 4), new LocationTagged<string>(String.Empty, 12, 0, 12)),
|
|||
|
Factory.Markup(" bar=").With(SpanCodeGenerator.Null),
|
|||
|
Factory.Markup("baz").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(String.Empty, 9, 0, 9), new LocationTagged<string>("baz", 9, 0, 9))))),
|
|||
|
new RazorError(String.Format(RazorResources.ParseError_UnfinishedTag, "foo"), new SourceLocation(0, 0, 0)));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|