Transition Microsoft.AspNet.Razor.Test from csproj to kproj.

The largest sub-segment change was removing the Microsoft.TestCommon project.  Ultimately it involved touching every test file and re-mapping them to use Xunit directly instead of a helper class which was initially ported over for legacy reasons.  Lastly how files were embedded before included the full path to the embedded file; currently there is no path associated with the embedded files so had to make modifications to account for this.  This is a temporary change and I left comments in the locations where we'll need to uncomment out old code once embeded files act the same as they used to.

#18
This commit is contained in:
N. Taylor Mullen 2014-05-30 11:00:15 -07:00
parent 9a6a3af450
commit 879a50846a
86 changed files with 531 additions and 1577 deletions

3
global.json Normal file
View File

@ -0,0 +1,3 @@
{
"sources": ["src"]
}

View File

@ -4,7 +4,7 @@
using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Generator.Compiler.CSharp;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test
{

View File

@ -10,37 +10,37 @@ using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Test.Utils;
using Microsoft.AspNet.Razor.Text;
using Microsoft.CSharp;
using Microsoft.TestCommon;
using Microsoft.AspNet.Testing;
using Moq;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Editor
{
public class RazorEditorParserTest
{
private static readonly TestFile SimpleCSHTMLDocument = TestFile.Create("DesignTime.Simple.cshtml");
private static readonly TestFile SimpleCSHTMLDocumentGenerated = TestFile.Create("DesignTime.Simple.txt");
// TODO: When paths are preserved use these.
//private static readonly TestFile SimpleCSHTMLDocument = TestFile.Create("DesignTime.Simple.cshtml");
//private static readonly TestFile SimpleCSHTMLDocumentGenerated = TestFile.Create("DesignTime.Simple.txt");
private static readonly TestFile SimpleCSHTMLDocument = TestFile.Create("Simple.cshtml");
private static readonly TestFile SimpleCSHTMLDocumentGenerated = TestFile.Create("Simple.txt");
private const string TestLinePragmaFileName = "C:\\This\\Path\\Is\\Just\\For\\Line\\Pragmas.cshtml";
[Fact]
public void ConstructorRequiresNonNullHost()
{
Assert.ThrowsArgumentNull(() => new RazorEditorParser(null, TestLinePragmaFileName),
"host");
Assert.Throws<ArgumentNullException>("host", () => new RazorEditorParser(null, TestLinePragmaFileName));
}
[Fact]
public void ConstructorRequiresNonNullPhysicalPath()
{
Assert.ThrowsArgumentNullOrEmptyString(() => new RazorEditorParser(CreateHost(), null),
"sourceFileName");
Assert.Throws<ArgumentException>("sourceFileName", () => new RazorEditorParser(CreateHost(), null));
}
[Fact]
public void ConstructorRequiresNonEmptyPhysicalPath()
{
Assert.ThrowsArgumentNullOrEmptyString(() => new RazorEditorParser(CreateHost(), String.Empty),
"sourceFileName");
Assert.Throws<ArgumentException>("sourceFileName", () => new RazorEditorParser(CreateHost(), string.Empty));
}
[Fact]
@ -100,12 +100,13 @@ namespace Microsoft.AspNet.Razor.Test.Editor
public void CheckForStructureChangesRequiresNonNullBufferInChange()
{
TextChange change = new TextChange();
Assert.ThrowsArgument(
var parameterName = "change";
var exception = Assert.Throws<ArgumentException>(
parameterName,
() => new RazorEditorParser(
CreateHost(),
"C:\\Foo.cshtml").CheckForStructureChanges(change),
"change",
RazorResources.Structure_Member_CannotBeNull("Buffer", "TextChange"));
"C:\\Foo.cshtml").CheckForStructureChanges(change));
ExceptionHelpers.ValidateArgumentException(parameterName, RazorResources.FormatStructure_Member_CannotBeNull("Buffer", "TextChange"), exception);
}
private static RazorEngineHost CreateHost()

View File

@ -12,7 +12,7 @@ using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Framework
{

View File

@ -3,12 +3,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Generator.Compiler;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Generator
{
@ -35,19 +34,19 @@ namespace Microsoft.AspNet.Razor.Test.Generator
[Fact]
public void ConstructorRequiresNonNullClassName()
{
Assert.ThrowsArgumentNullOrEmptyString(() => new CSharpRazorCodeGenerator(null, TestRootNamespaceName, TestPhysicalPath, CreateHost()), "className");
Assert.Throws<ArgumentException>("className", () => new CSharpRazorCodeGenerator(null, TestRootNamespaceName, TestPhysicalPath, CreateHost()));
}
[Fact]
public void ConstructorRequiresNonEmptyClassName()
{
Assert.ThrowsArgumentNullOrEmptyString(() => new CSharpRazorCodeGenerator(String.Empty, TestRootNamespaceName, TestPhysicalPath, CreateHost()), "className");
Assert.Throws<ArgumentException>("className", () => new CSharpRazorCodeGenerator(string.Empty, TestRootNamespaceName, TestPhysicalPath, CreateHost()));
}
[Fact]
public void ConstructorRequiresNonNullRootNamespaceName()
{
Assert.ThrowsArgumentNull(() => new CSharpRazorCodeGenerator("Foo", null, TestPhysicalPath, CreateHost()), "rootNamespaceName");
Assert.Throws<ArgumentNullException>("rootNamespaceName", () => new CSharpRazorCodeGenerator("Foo", null, TestPhysicalPath, CreateHost()));
}
[Fact]
@ -59,7 +58,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
[Fact]
public void ConstructorRequiresNonNullHost()
{
Assert.ThrowsArgumentNull(() => new CSharpRazorCodeGenerator("Foo", TestRootNamespaceName, TestPhysicalPath, null), "host");
Assert.Throws<ArgumentNullException>("host", () => new CSharpRazorCodeGenerator("Foo", TestRootNamespaceName, TestPhysicalPath, null));
}
[Theory]

View File

@ -1,12 +1,11 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Web.WebPages.TestUtils;
using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Utils;
using Microsoft.TestCommon;
using Moq;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Generator.CodeTree
{
@ -28,7 +27,9 @@ namespace Microsoft.AspNet.Razor.Test.Generator.CodeTree
BaselineWriter.WriteBaseline(@"test\Microsoft.AspNet.Razor.Test\TestFiles\CodeGenerator\CS\Output\CSharpCodeBuilder.cs", result.Code);
var expectedOutput = TestFile.Create("CodeGenerator.CS.Output.CSharpCodeBuilder.cs").ReadAllText();
// TODO: When paths are preserved use this.
//var expectedOutput = TestFile.Create("CodeGenerator.CS.Output.CSharpCodeBuilder.cs").ReadAllText();
var expectedOutput = TestFile.Create("CSharpCodeBuilder.cs").ReadAllText();
// Assert
Assert.Equal(expectedOutput, result.Code);

View File

@ -7,7 +7,7 @@ using System.Linq;
using Microsoft.AspNet.Razor.Generator.Compiler.CSharp;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Generator
{
@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
}
[Theory]
[PropertyData("SpacePropertyData")]
[MemberData("SpacePropertyData")]
public void CalculatePaddingForEmptySpanWith4Spaces(bool designTime, bool isIndentingWithTabs, int tabSize)
{
// Arrange
@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
}
[Theory]
[PropertyData("SpacePropertyData")]
[MemberData("SpacePropertyData")]
public void CalculatePaddingForIfSpanWith5Spaces(bool designTime, bool isIndentingWithTabs, int tabSize)
{
// Arrange

View File

@ -1,8 +1,8 @@
using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Generator.Compiler;
using Microsoft.TestCommon;
using Moq;
using Moq.Protected;
using Xunit;
namespace Microsoft.AspNet.Razor
{

View File

@ -2,10 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Text;
using Microsoft.CSharp;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Generator
{
@ -16,7 +13,6 @@ namespace Microsoft.AspNet.Razor.Test.Generator
{
RunTest("CodeTree", onResults: (results) =>
{
Console.WriteLine(results.GeneratedCode);
}, designTimeMode: true);
}
}

View File

@ -1,10 +1,9 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Generator.Compiler;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Generator
{

View File

@ -11,7 +11,8 @@ using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Generator.Compiler;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Utils;
using Microsoft.TestCommon;
using Microsoft.AspNet.Testing;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Generator
{
@ -43,7 +44,6 @@ namespace Microsoft.AspNet.Razor.Test.Generator
if ((tabTest & TabTest.Tabs) == TabTest.Tabs)
{
// CodeDOM will inject its strings into the generated file header, so we force English.
using (new CultureReplacer())
{
RunTestInternal(
@ -63,7 +63,6 @@ namespace Microsoft.AspNet.Razor.Test.Generator
if ((tabTest & TabTest.NoTabs) == TabTest.NoTabs)
{
// CodeDOM will inject its strings into the generated file header, so we force English.
using (new CultureReplacer())
{
RunTestInternal(
@ -100,9 +99,13 @@ namespace Microsoft.AspNet.Razor.Test.Generator
baselineName = name;
}
string sourceLocation = String.Format("/CodeGenerator/{1}/Source/{0}.{2}", name, LanguageName, FileExtension);
string source = TestFile.Create(String.Format("CodeGenerator.{1}.Source.{0}.{2}", name, LanguageName, FileExtension)).ReadAllText();
string expectedOutput = TestFile.Create(String.Format("CodeGenerator.{1}.Output.{0}.{2}", baselineName, LanguageName, BaselineExtension)).ReadAllText();
// TODO: When paths are preserved use these.
//string sourceLocation = string.Format("/CodeGenerator/{1}/Source/{0}.{2}", name, LanguageName, FileExtension);
//string source = TestFile.Create(string.Format("CodeGenerator.{1}.Source.{0}.{2}", name, LanguageName, FileExtension)).ReadAllText();
//string expectedOutput = TestFile.Create(string.Format("CodeGenerator.{1}.Output.{0}.{2}", baselineName, LanguageName, BaselineExtension)).ReadAllText();
string sourceLocation = string.Format("/CodeGenerator/{1}/Source/{0}.{2}", name, LanguageName, FileExtension);
string source = TestFile.Create(string.Format("{0}.{1}", name, FileExtension)).ReadAllText();
string expectedOutput = TestFile.Create(string.Format("{0}.{1}", baselineName, BaselineExtension)).ReadAllText();
// Set up the host and engine
RazorEngineHost host = CreateHost();

View File

@ -1,328 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{0BB62A1D-E6B5-49FA-9E3C-6AF679A66DFE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.AspNet.Razor.Test</RootNamespace>
<AssemblyName>Microsoft.AspNet.Razor.Test</AssemblyName>
<OutputPath>..\..\bin\$(Configuration)\Test\</OutputPath>
<NoWarn>0618</NoWarn>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<Prefer32Bit>false</Prefer32Bit>
<DefineConstants>
</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="xunit, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\xunit.1.9.1\lib\net20\xunit.dll</HintPath>
<Aliases>unused</Aliases>
</Reference>
<Reference Include="xunit.extensions, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\xunit.extensions.1.9.1\lib\net20\xunit.extensions.dll</HintPath>
<Aliases>unused</Aliases>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNet.Razor\Microsoft.AspNet.Razor.net45.csproj">
<Project>{8b129ff9-0b8f-4e0c-8dfc-0137d8550fb7}</Project>
<Name>Microsoft.AspNet.Razor.net45</Name>
</ProjectReference>
<ProjectReference Include="..\Microsoft.TestCommon\Microsoft.TestCommon.csproj">
<Project>{FCCC4CB7-BAF7-4A57-9F89-E5766FE536C0}</Project>
<Name>Microsoft.TestCommon</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Compile Include="CSharpRazorCodeLanguageTest.cs" />
<Compile Include="Editor\RazorEditorParserTest.cs" />
<Compile Include="Framework\BlockExtensions.cs" />
<Compile Include="Framework\BlockTypes.cs" />
<Compile Include="Framework\CodeParserTestBase.cs" />
<Compile Include="Framework\CsHtmlCodeParserTestBase.cs" />
<Compile Include="Framework\CsHtmlMarkupParserTestBase.cs" />
<Compile Include="Framework\ErrorCollector.cs" />
<Compile Include="Framework\MarkupParserTestBase.cs" />
<Compile Include="Framework\ParserTestBase.cs" />
<Compile Include="Framework\RawTextSymbol.cs" />
<Compile Include="Framework\TestSpanBuilder.cs" />
<Compile Include="Generator\CodeTree\ChunkVisitorTests.cs" />
<Compile Include="Generator\CodeTree\CodeTreeGenerationTest.cs" />
<Compile Include="Generator\CodeTree\CSharpCodeBuilderTests.cs" />
<Compile Include="Generator\CodeTree\CSharpPaddingBuilderTests.cs" />
<Compile Include="Generator\CSharpRazorCodeGeneratorTest.cs" />
<Compile Include="Generator\LineMappingTest.cs" />
<Compile Include="Generator\RazorCodeGeneratorTest.cs" />
<Compile Include="Generator\TabTest.cs" />
<Compile Include="Generator\TestSpan.cs" />
<Compile Include="Parser\BlockTest.cs" />
<Compile Include="Parser\CallbackParserListenerTest.cs" />
<Compile Include="Parser\CSharp\CSharpAutoCompleteTest.cs" />
<Compile Include="Parser\CSharp\CSharpBlockTest.cs" />
<Compile Include="Parser\CSharp\CSharpDirectivesTest.cs" />
<Compile Include="Parser\CSharp\CSharpErrorTest.cs" />
<Compile Include="Parser\CSharp\CSharpExplicitExpressionTest.cs" />
<Compile Include="Parser\CSharp\CSharpHelperTest.cs" />
<Compile Include="Parser\CSharp\CSharpImplicitExpressionTest.cs" />
<Compile Include="Parser\CSharp\CSharpLayoutDirectiveTest.cs" />
<Compile Include="Parser\CSharp\CSharpNestedStatementsTest.cs" />
<Compile Include="Parser\CSharp\CSharpRazorCommentsTest.cs" />
<Compile Include="Parser\CSharp\CSharpReservedWordsTest.cs" />
<Compile Include="Parser\CSharp\CSharpSectionTest.cs" />
<Compile Include="Parser\CSharp\CSharpSpecialBlockTest.cs" />
<Compile Include="Parser\CSharp\CSharpStatementTest.cs" />
<Compile Include="Parser\CSharp\CSharpTemplateTest.cs" />
<Compile Include="Parser\CSharp\CSharpToMarkupSwitchTest.cs" />
<Compile Include="Parser\CSharp\CSharpVerbatimBlockTest.cs" />
<Compile Include="Parser\CSharp\CSharpWhitespaceHandlingTest.cs" />
<Compile Include="Parser\Html\HtmlAttributeTest.cs" />
<Compile Include="Parser\Html\HtmlBlockTest.cs" />
<Compile Include="Parser\Html\HtmlDocumentTest.cs" />
<Compile Include="Parser\Html\HtmlErrorTest.cs" />
<Compile Include="Parser\Html\HtmlParserTestUtils.cs" />
<Compile Include="Parser\Html\HtmlTagsTest.cs" />
<Compile Include="Parser\Html\HtmlToCodeSwitchTest.cs" />
<Compile Include="Parser\Html\HtmlUrlAttributeTest.cs" />
<Compile Include="Parser\ParserContextTest.cs" />
<Compile Include="Parser\ParserVisitorExtensionsTest.cs" />
<Compile Include="Parser\PartialParsing\CSharpPartialParsingTest.cs" />
<Compile Include="Parser\PartialParsing\PartialParsingTestBase.cs" />
<Compile Include="Parser\RazorParserTest.cs" />
<Compile Include="Parser\WhitespaceRewriterTest.cs" />
<Compile Include="RazorCodeLanguageTest.cs" />
<Compile Include="RazorDirectiveAttributeTest.cs" />
<Compile Include="RazorEngineHostTest.cs" />
<Compile Include="RazorTemplateEngineTest.cs" />
<Compile Include="StringTextBuffer.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\CodeTree.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\Await.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\Await.DesignTime.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\CSharpCodeBuilder.cs" />
<Compile Include="Text\BufferingTextReaderTest.cs" />
<Compile Include="Text\LineTrackingStringBufferTest.cs" />
<Compile Include="Text\LookaheadTextReaderTestBase.cs" />
<Compile Include="Text\SourceLocationTest.cs" />
<Compile Include="Text\SourceLocationTrackerTest.cs" />
<Compile Include="Text\TextBufferReaderTest.cs" />
<Compile Include="Text\TextChangeTest.cs" />
<Compile Include="Text\TextReaderExtensionsTest.cs" />
<Compile Include="Tokenizer\CSharpTokenizerCommentTest.cs" />
<Compile Include="Tokenizer\CSharpTokenizerIdentifierTest.cs" />
<Compile Include="Tokenizer\CSharpTokenizerLiteralTest.cs" />
<Compile Include="Tokenizer\CSharpTokenizerOperatorsTest.cs" />
<Compile Include="Tokenizer\CSharpTokenizerTest.cs" />
<Compile Include="Tokenizer\CSharpTokenizerTestBase.cs" />
<Compile Include="Tokenizer\HtmlTokenizerTest.cs" />
<Compile Include="Tokenizer\HtmlTokenizerTestBase.cs" />
<Compile Include="Tokenizer\TokenizerLookaheadTest.cs" />
<Compile Include="Tokenizer\TokenizerTestBase.cs" />
<Compile Include="Utils\BaselineWriter.cs" />
<Compile Include="Utils\DisposableActionTest.cs" />
<Compile Include="Utils\MiscUtils.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\UnfinishedExpressionInCode.Tabs.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\UnfinishedExpressionInCode.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\Templates.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\SimpleUnspacedIf.DesignTime.Tabs.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\Sections.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\ResolveUrl.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\RazorComments.DesignTime.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\RazorComments.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\ParserError.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\OpenedIf.DesignTime.Tabs.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\OpenedIf.DesignTime.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\NoLinePragmas.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\NestedHelpers.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\NestedCodeBlocks.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\MarkupInCodeBlock.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\LayoutDirective.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\InlineBlocks.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\Inherits.Runtime.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\Inherits.Designtime.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\Imports.DesignTime.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\Imports.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\ImplicitExpressionAtEOF.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\ImplicitExpression.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\HtmlCommentWithQuote_Single.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\HtmlCommentWithQuote_Double.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\HiddenSpansInCode.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\HelpersMissingOpenParen.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\HelpersMissingOpenBrace.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\HelpersMissingCloseParen.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\Helpers.Instance.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\Helpers.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\FunctionsBlockMinimal.DesignTime.Tabs.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\FunctionsBlock_Tabs.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\FunctionsBlock.DesignTime.Tabs.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\FunctionsBlock.DesignTime.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\FunctionsBlock.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\ExpressionsInCode.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\ExplicitExpressionAtEOF.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\ExplicitExpression.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\EmptyImplicitExpressionInCode.Tabs.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\EmptyImplicitExpressionInCode.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\EmptyImplicitExpression.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\EmptyExplicitExpression.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\EmptyCodeBlock.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\DesignTime.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\ConditionalAttributes.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\CodeBlockAtEOF.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\CodeBlock.cs" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Output\Blocks.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\Blocks.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\CodeBlock.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\CodeBlockAtEOF.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\ConditionalAttributes.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\DesignTime.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\EmptyCodeBlock.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\EmptyExplicitExpression.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\EmptyImplicitExpression.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\EmptyImplicitExpressionInCode.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\ExplicitExpression.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\ExplicitExpressionAtEOF.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\ExpressionsInCode.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\FunctionsBlock.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\FunctionsBlock_Tabs.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\FunctionsBlockMinimal.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\Helpers.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\HelpersMissingCloseParen.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\HelpersMissingOpenBrace.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\HelpersMissingOpenParen.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\HiddenSpansInCode.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\HtmlCommentWithQuote_Double.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\HtmlCommentWithQuote_Single.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\ImplicitExpression.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\ImplicitExpressionAtEOF.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\Imports.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\Inherits.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\InlineBlocks.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\LayoutDirective.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\MarkupInCodeBlock.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\NestedCodeBlocks.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\NestedHelpers.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\NoLinePragmas.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\OpenedIf.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\ParserError.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\RazorComments.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\ResolveUrl.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\Sections.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\SimpleUnspacedIf.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\Templates.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\UnfinishedExpressionInCode.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\DesignTime\Simple.cshtml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\DesignTime\Simple.txt" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestFiles\nested-1000.html" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\CodeTree.cshtml" />
<EmbeddedResource Include="TestFiles\CodeGenerator\CS\Source\Await.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,215 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>87c7338b-0c06-4c7b-be75-a2368ae26797</ProjectGuid>
<OutputType>Library</OutputType>
<ActiveTargetFramework>net45</ActiveTargetFramework>
</PropertyGroup>
<PropertyGroup Condition="$(OutputType) == 'Console'">
<DebuggerFlavor>ConsoleDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="$(OutputType) == 'Web'">
<DebuggerFlavor>WebDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" Label="Configuration">
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="CSharpRazorCodeLanguageTest.cs" />
<Compile Include="Editor\RazorEditorParserTest.cs" />
<Compile Include="Framework\BlockExtensions.cs" />
<Compile Include="Framework\BlockTypes.cs" />
<Compile Include="Framework\CodeParserTestBase.cs" />
<Compile Include="Framework\CsHtmlCodeParserTestBase.cs" />
<Compile Include="Framework\CsHtmlMarkupParserTestBase.cs" />
<Compile Include="Framework\ErrorCollector.cs" />
<Compile Include="Framework\MarkupParserTestBase.cs" />
<Compile Include="Framework\ParserTestBase.cs" />
<Compile Include="Framework\RawTextSymbol.cs" />
<Compile Include="Framework\TestSpanBuilder.cs" />
<Compile Include="Generator\CodeTree\ChunkVisitorTests.cs" />
<Compile Include="Generator\CodeTree\CodeTreeGenerationTest.cs" />
<Compile Include="Generator\CodeTree\CSharpCodeBuilderTests.cs" />
<Compile Include="Generator\CodeTree\CSharpPaddingBuilderTests.cs" />
<Compile Include="Generator\CSharpRazorCodeGeneratorTest.cs" />
<Compile Include="Generator\LineMappingTest.cs" />
<Compile Include="Generator\RazorCodeGeneratorTest.cs" />
<Compile Include="Generator\TabTest.cs" />
<Compile Include="Generator\TestSpan.cs" />
<Compile Include="Parser\BlockTest.cs" />
<Compile Include="Parser\CallbackParserListenerTest.cs" />
<Compile Include="Parser\CSharp\CSharpAutoCompleteTest.cs" />
<Compile Include="Parser\CSharp\CSharpBlockTest.cs" />
<Compile Include="Parser\CSharp\CSharpDirectivesTest.cs" />
<Compile Include="Parser\CSharp\CSharpErrorTest.cs" />
<Compile Include="Parser\CSharp\CSharpExplicitExpressionTest.cs" />
<Compile Include="Parser\CSharp\CSharpHelperTest.cs" />
<Compile Include="Parser\CSharp\CSharpImplicitExpressionTest.cs" />
<Compile Include="Parser\CSharp\CSharpLayoutDirectiveTest.cs" />
<Compile Include="Parser\CSharp\CSharpNestedStatementsTest.cs" />
<Compile Include="Parser\CSharp\CSharpRazorCommentsTest.cs" />
<Compile Include="Parser\CSharp\CSharpReservedWordsTest.cs" />
<Compile Include="Parser\CSharp\CSharpSectionTest.cs" />
<Compile Include="Parser\CSharp\CSharpSpecialBlockTest.cs" />
<Compile Include="Parser\CSharp\CSharpStatementTest.cs" />
<Compile Include="Parser\CSharp\CSharpTemplateTest.cs" />
<Compile Include="Parser\CSharp\CSharpToMarkupSwitchTest.cs" />
<Compile Include="Parser\CSharp\CSharpVerbatimBlockTest.cs" />
<Compile Include="Parser\CSharp\CSharpWhitespaceHandlingTest.cs" />
<Compile Include="Parser\Html\HtmlAttributeTest.cs" />
<Compile Include="Parser\Html\HtmlBlockTest.cs" />
<Compile Include="Parser\Html\HtmlDocumentTest.cs" />
<Compile Include="Parser\Html\HtmlErrorTest.cs" />
<Compile Include="Parser\Html\HtmlParserTestUtils.cs" />
<Compile Include="Parser\Html\HtmlTagsTest.cs" />
<Compile Include="Parser\Html\HtmlToCodeSwitchTest.cs" />
<Compile Include="Parser\Html\HtmlUrlAttributeTest.cs" />
<Compile Include="Parser\ParserContextTest.cs" />
<Compile Include="Parser\ParserVisitorExtensionsTest.cs" />
<Compile Include="Parser\PartialParsing\CSharpPartialParsingTest.cs" />
<Compile Include="Parser\PartialParsing\PartialParsingTestBase.cs" />
<Compile Include="Parser\RazorParserTest.cs" />
<Compile Include="Parser\WhitespaceRewriterTest.cs" />
<Compile Include="RazorCodeLanguageTest.cs" />
<Compile Include="RazorDirectiveAttributeTest.cs" />
<Compile Include="RazorEngineHostTest.cs" />
<Compile Include="RazorTemplateEngineTest.cs" />
<Compile Include="StringTextBuffer.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\Await.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\Await.DesignTime.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\Blocks.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\CodeBlock.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\CodeBlockAtEOF.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\CodeTree.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\ConditionalAttributes.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\CSharpCodeBuilder.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\DesignTime.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\EmptyCodeBlock.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\EmptyExplicitExpression.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\EmptyImplicitExpression.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\EmptyImplicitExpressionInCode.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\EmptyImplicitExpressionInCode.Tabs.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\ExplicitExpression.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\ExplicitExpressionAtEOF.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\ExpressionsInCode.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\FunctionsBlock.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\FunctionsBlock.DesignTime.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\FunctionsBlock.DesignTime.Tabs.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\FunctionsBlockMinimal.DesignTime.Tabs.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\FunctionsBlock_Tabs.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\Helpers.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\Helpers.Instance.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\HelpersMissingCloseParen.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\HelpersMissingOpenBrace.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\HelpersMissingOpenParen.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\HiddenSpansInCode.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\HtmlCommentWithQuote_Double.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\HtmlCommentWithQuote_Single.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\ImplicitExpression.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\ImplicitExpressionAtEOF.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\Imports.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\Imports.DesignTime.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\Inherits.Designtime.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\Inherits.Runtime.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\InlineBlocks.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\LayoutDirective.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\MarkupInCodeBlock.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\NestedCodeBlocks.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\NestedHelpers.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\NoLinePragmas.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\OpenedIf.DesignTime.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\OpenedIf.DesignTime.Tabs.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\ParserError.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\RazorComments.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\RazorComments.DesignTime.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\ResolveUrl.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\Sections.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\SimpleUnspacedIf.DesignTime.Tabs.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\Templates.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\UnfinishedExpressionInCode.cs" />
<Compile Include="TestFiles\CodeGenerator\CS\Output\UnfinishedExpressionInCode.Tabs.cs" />
<Compile Include="Text\BufferingTextReaderTest.cs" />
<Compile Include="Text\LineTrackingStringBufferTest.cs" />
<Compile Include="Text\LookaheadTextReaderTestBase.cs" />
<Compile Include="Text\SourceLocationTest.cs" />
<Compile Include="Text\SourceLocationTrackerTest.cs" />
<Compile Include="Text\TextBufferReaderTest.cs" />
<Compile Include="Text\TextChangeTest.cs" />
<Compile Include="Text\TextReaderExtensionsTest.cs" />
<Compile Include="Tokenizer\CSharpTokenizerCommentTest.cs" />
<Compile Include="Tokenizer\CSharpTokenizerIdentifierTest.cs" />
<Compile Include="Tokenizer\CSharpTokenizerLiteralTest.cs" />
<Compile Include="Tokenizer\CSharpTokenizerOperatorsTest.cs" />
<Compile Include="Tokenizer\CSharpTokenizerTest.cs" />
<Compile Include="Tokenizer\CSharpTokenizerTestBase.cs" />
<Compile Include="Tokenizer\HtmlTokenizerTest.cs" />
<Compile Include="Tokenizer\HtmlTokenizerTestBase.cs" />
<Compile Include="Tokenizer\TokenizerLookaheadTest.cs" />
<Compile Include="Tokenizer\TokenizerTestBase.cs" />
<Compile Include="Utils\ExceptionHelpers.cs" />
<Compile Include="Utils\BaselineWriter.cs" />
<Compile Include="Utils\DisposableActionTest.cs" />
<Compile Include="Utils\MiscUtils.cs" />
<Compile Include="Utils\TestFile.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="project.json" />
<Content Include="TestFiles\CodeGenerator\CS\Source\Await.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\Blocks.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\CodeBlock.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\CodeBlockAtEOF.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\CodeTree.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\ConditionalAttributes.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\DesignTime.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\EmptyCodeBlock.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\EmptyExplicitExpression.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\EmptyImplicitExpression.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\EmptyImplicitExpressionInCode.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\ExplicitExpression.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\ExplicitExpressionAtEOF.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\ExpressionsInCode.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\FunctionsBlock.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\FunctionsBlockMinimal.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\FunctionsBlock_Tabs.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\Helpers.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\HelpersMissingCloseParen.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\HelpersMissingOpenBrace.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\HelpersMissingOpenParen.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\HiddenSpansInCode.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\HtmlCommentWithQuote_Double.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\HtmlCommentWithQuote_Single.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\ImplicitExpression.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\ImplicitExpressionAtEOF.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\Imports.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\Inherits.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\InlineBlocks.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\LayoutDirective.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\MarkupInCodeBlock.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\NestedCodeBlocks.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\NestedHelpers.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\NoLinePragmas.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\OpenedIf.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\ParserError.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\RazorComments.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\ResolveUrl.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\Sections.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\SimpleUnspacedIf.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\Templates.cshtml" />
<Content Include="TestFiles\CodeGenerator\CS\Source\UnfinishedExpressionInCode.cshtml" />
<Content Include="TestFiles\DesignTime\Simple.cshtml" />
<Content Include="TestFiles\DesignTime\Simple.txt" />
<Content Include="TestFiles\nested-1000.html" />
</ItemGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View File

@ -7,7 +7,7 @@ using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser
{

View File

@ -8,7 +8,7 @@ using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
AutoCompleteString = "}"
})),
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("functions", "}", "{"),
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", "}", "{"),
1, 0, 1));
}
@ -50,7 +50,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" })
)
),
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
1, 0, 1));
}
@ -65,7 +65,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.Accepts(AcceptedCharacters.Any),
new MarkupBlock()),
new RazorError(
RazorResources.ParseError_Expected_X("}"),
RazorResources.FormatParseError_Expected_X("}"),
17, 0, 17));
}
@ -80,7 +80,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.AsStatement()
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" })
),
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
1, 0, 1));
}
@ -100,7 +100,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
AutoCompleteString = "}"
})),
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("functions", "}", "{"),
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", "}", "{"),
1, 0, 1));
}
@ -129,7 +129,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.With(new StatementCodeGenerator())
)
),
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
1, 0, 1));
}
@ -145,7 +145,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.Accepts(AcceptedCharacters.Any),
new MarkupBlock(
Factory.Markup("\r\n<p>Foo</p>"))),
new RazorError(RazorResources.ParseError_Expected_X("}"),
new RazorError(RazorResources.FormatParseError_Expected_X("}"),
29, 1, 10));
}
@ -168,7 +168,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Span(SpanKind.Code, new CSharpSymbol(Factory.LocationTracker.CurrentLocation, String.Empty, CSharpSymbolType.Unknown))
.With(new StatementCodeGenerator())
),
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
1, 0, 1));
}
}

View File

@ -8,7 +8,7 @@ using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
@ -21,7 +21,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
CSharpCodeParser parser = new CSharpCodeParser();
// Act and Assert
Assert.Throws<InvalidOperationException>(() => parser.ParseBlock(), RazorResources.Parser_Context_Not_Set);
var exception = Assert.Throws<InvalidOperationException>(() => parser.ParseBlock());
Assert.Equal(RazorResources.Parser_Context_Not_Set, exception.Message);
}
[Fact]
@ -45,7 +46,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
),
Factory.Code(" }").AsStatement()),
new RazorError(
RazorResources.ParseError_Unexpected_Keyword_After_At("if"),
RazorResources.FormatParseError_Unexpected_Keyword_After_At("if"),
new SourceLocation(13, 0, 13)));
}
@ -107,7 +108,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
ImplicitExpressionTest("Html.En(code()", "Html.En(code()",
AcceptedCharacters.Any,
new RazorError(
RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"),
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
new SourceLocation(8, 0, 8)));
}
@ -388,7 +389,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
{
const string document = "foreach(var f in Foo) { // foo bar baz";
SingleSpanBlockTest(document, document, BlockType.Statement, SpanKind.Code,
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), SourceLocation.Zero));
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), SourceLocation.Zero));
}
[Fact]
@ -397,7 +398,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
const string document = "foreach(var f in Foo) { /* foo bar baz";
SingleSpanBlockTest(document, document, BlockType.Statement, SpanKind.Code,
new RazorError(RazorResources.ParseError_BlockComment_Not_Terminated, 24, 0, 24),
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), SourceLocation.Zero));
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), SourceLocation.Zero));
}
[Fact]
@ -405,7 +406,7 @@ while(true);", BlockType.Statement, SpanKind.Code, acceptedCharacters: AcceptedC
{
const string document = "foreach(var f in Foo) { / foo bar baz";
SingleSpanBlockTest(document, document, BlockType.Statement, SpanKind.Code,
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), SourceLocation.Zero));
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("foreach", '}', '{'), SourceLocation.Zero));
}
[Fact]

View File

@ -6,7 +6,7 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{

View File

@ -6,7 +6,7 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.Accepts(AcceptedCharacters.NonWhiteSpace)
),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS('"'),
RazorResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS('"'),
1, 0, 1));
}
@ -48,7 +48,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.With(new AutoCompleteEditHandler(CSharpLanguageCharacteristics.Instance.TokenizeString) { AutoCompleteString = "}" })
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
SourceLocation.Zero));
}
@ -112,7 +112,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
),
new RazorError(RazorResources.ParseError_Unexpected_EndOfFile_At_Start_Of_CodeBlock, 8, 1, 5),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
SourceLocation.Zero));
}
@ -126,7 +126,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
.Accepts(AcceptedCharacters.NonWhiteSpace)),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("!"),
RazorResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("!"),
1, 0, 1));
}
@ -140,7 +140,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("foo bar\r\nbaz").AsExpression()
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_ExplicitExpression, ')', '('),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_ExplicitExpression, ')', '('),
new SourceLocation(0, 0, 0)));
}
@ -156,7 +156,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("foo bar\r\n").AsExpression()
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_ExplicitExpression, ')', '('),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_ExplicitExpression, ')', '('),
new SourceLocation(0, 0, 0)));
}
@ -170,7 +170,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
),
new RazorError(
RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"),
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
new SourceLocation(4, 0, 4)));
}
@ -185,7 +185,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("Foo(Bar(Baz)\r\nBiz\r\nBoz")
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
),
new RazorError(RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"),
new RazorError(RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
new SourceLocation(3, 0, 3)));
}
@ -202,7 +202,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("Foo(Bar(Baz)\r\nBiz\r\n")
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
),
new RazorError(RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"),
new RazorError(RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
new SourceLocation(3, 0, 3)));
}
@ -218,7 +218,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
),
new RazorError(
RazorResources.ParseError_Expected_CloseBracket_Before_EOF("[", "]"),
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("[", "]"),
new SourceLocation(3, 0, 3)));
}
@ -236,7 +236,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
),
new RazorError(
RazorResources.ParseError_Expected_CloseBracket_Before_EOF("[", "]"),
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("[", "]"),
new SourceLocation(3, 0, 3)));
}
@ -250,7 +250,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code(" var foo = bar; if(foo != null) { bar(); } ").AsStatement()
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, '}', '{'),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, '}', '{'),
SourceLocation.Zero));
}
@ -263,7 +263,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code(" var foo = bar; if(foo != null) { bar(); } ").AsFunctionsBody()
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("functions", '}', '{'),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", '}', '{'),
SourceLocation.Zero));
}
@ -281,7 +281,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("if(foo) { baz(); } else { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("else", '}', '{'),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("else", '}', '{'),
new SourceLocation(19, 0, 19)));
}
@ -293,7 +293,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("if(foo) { baz(); } else if { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("else if", '}', '{'),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("else if", '}', '{'),
new SourceLocation(19, 0, 19)));
}
@ -305,7 +305,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("do { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("do", '}', '{'),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("do", '}', '{'),
SourceLocation.Zero));
}
@ -317,7 +317,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("try { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("try", '}', '{'),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("try", '}', '{'),
SourceLocation.Zero));
}
@ -329,7 +329,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("try { baz(); } catch(Foo) { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("catch", '}', '{'),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("catch", '}', '{'),
new SourceLocation(15, 0, 15)));
}
@ -341,7 +341,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("try { baz(); } finally { var foo = bar; if(foo != null) { bar(); } ").AsStatement()
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("finally", '}', '{'),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("finally", '}', '{'),
new SourceLocation(15, 0, 15)));
}
@ -384,7 +384,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
[Fact]
public void ParseBlockRequiresControlFlowStatementsToHaveBraces()
{
string expectedMessage = RazorResources.ParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", "<");
string expectedMessage = RazorResources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", "<");
ParseBlockTest("if(foo) <p>Bar</p> else if(bar) <p>Baz</p> else <p>Boz</p>",
new StatementBlock(
Factory.Code("if(foo) ").AsStatement(),
@ -414,7 +414,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("if(foo)) { var bar = foo; }").AsStatement()
),
new RazorError(
RazorResources.ParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", ")"),
RazorResources.FormatParseError_SingleLine_ControlFlowStatements_Not_Allowed("{", ")"),
new SourceLocation(7, 0, 7)));
}
@ -445,7 +445,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("if(foo bar\r\n").AsStatement()
),
new RazorError(
RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"),
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
new SourceLocation(2, 0, 2)));
}
@ -458,7 +458,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("foreach(foo bar\r\n").AsStatement()
),
new RazorError(
RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"),
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
new SourceLocation(7, 0, 7)));
}
@ -471,7 +471,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("do { } while(foo bar\r\n").AsStatement()
),
new RazorError(
RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"),
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
new SourceLocation(12, 0, 12)));
}
@ -484,7 +484,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("using(foo bar\r\n").AsStatement()
),
new RazorError(
RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"),
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
new SourceLocation(5, 0, 5)));
}
@ -501,7 +501,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("}").AsStatement().Accepts(AcceptedCharacters.None)
),
new RazorError(
RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"),
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
new SourceLocation(2, 0, 2)));
}
@ -521,7 +521,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
SingleSpanBlockTest("if(foo) { var foo = \"blah blah blah blah blah", BlockType.Statement, SpanKind.Code,
new RazorError(RazorResources.ParseError_Unterminated_String_Literal, 20, 0, 20),
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'), SourceLocation.Zero));
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'), SourceLocation.Zero));
}
[Fact]
@ -534,7 +534,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
+ "blah",
BlockType.Statement, SpanKind.Code,
new RazorError(RazorResources.ParseError_Unterminated_String_Literal, 20, 0, 20),
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'), SourceLocation.Zero));
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("if", '}', '{'), SourceLocation.Zero));
}
[Fact]
@ -586,7 +586,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
expectedErrors: new[] {
new RazorError(
RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"),
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
14, 0, 14)
});
@ -595,7 +595,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
private void RunUnterminatedSimpleKeywordBlock(string keyword)
{
SingleSpanBlockTest(keyword + " (foo) { var foo = bar; if(foo != null) { bar(); } ", BlockType.Statement, SpanKind.Code,
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(keyword, '}', '{'), SourceLocation.Zero));
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(keyword, '}', '{'), SourceLocation.Zero));
}
}
}

View File

@ -5,7 +5,7 @@ using System;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.EmptyCSharp().AsExpression()
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_ExplicitExpression, ")", "("),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_ExplicitExpression, ")", "("),
new SourceLocation(1, 0, 1)));
}

View File

@ -7,7 +7,7 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
@ -53,7 +53,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
Factory.EmptyHtml()),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_Newline),
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_Newline),
7, 0, 7));
}
@ -68,7 +68,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.MetaCode("helper")),
Factory.Markup("{")),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_Character("{")),
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.FormatErrorComponent_Character("{")),
7, 0, 7));
}
@ -87,10 +87,10 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.AsStatement()
.AutoCompleteWith("}")))),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_Character("(")),
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.FormatErrorComponent_Character("(")),
8, 0, 8),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
1, 0, 1));
}
@ -105,7 +105,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.EmptyCSharp().Hidden())),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_EndOfFile),
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_EndOfFile),
8, 0, 8));
}
@ -119,7 +119,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.CodeTransition(),
Factory.MetaCode("helper").Accepts(AcceptedCharacters.Any))),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_EndOfFile),
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_EndOfFile),
7, 0, 7));
}
@ -136,7 +136,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code(" \r\n").Hidden()),
Factory.Markup(@" ")),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_Newline),
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(RazorResources.ErrorComponent_Newline),
30, 0, 30));
}
@ -153,7 +153,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("Foo \r\n").Hidden()),
Factory.Markup(" ")),
new RazorError(
RazorResources.ParseError_MissingCharAfterHelperName("("),
RazorResources.FormatParseError_MissingCharAfterHelperName("("),
15, 0, 15));
}
@ -185,7 +185,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.MetaCode("helper ").Accepts(AcceptedCharacters.None),
Factory.Code("Foo(string foo) \r\n").Hidden())),
new RazorError(
RazorResources.ParseError_MissingCharAfterHelperParameters("{"),
RazorResources.FormatParseError_MissingCharAfterHelperParameters("{"),
29, 1, 0));
}
@ -208,7 +208,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Markup(" <p>Foo</p>").Accepts(AcceptedCharacters.None)),
Factory.EmptyCSharp().AsStatement()))),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
1, 0, 1));
}
@ -289,7 +289,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
expectedErrors: new[]
{
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("helper", "}", "{"),
new SourceLocation(1, 0, 1))
});
}

View File

@ -1,12 +1,11 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
@ -49,7 +48,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.AsImplicitExpression(KeywordSet)
.Accepts(AcceptedCharacters.NonWhiteSpace)),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"),
RazorResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"),
new SourceLocation(1, 0, 1)));
}
@ -163,7 +162,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
ImplicitExpressionTest("foo(()", "foo(()",
acceptedCharacters: AcceptedCharacters.Any,
errors: new RazorError(RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"), new SourceLocation(4, 0, 4)));
errors: new RazorError(RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), new SourceLocation(4, 0, 4)));
}
[Fact]

View File

@ -7,7 +7,7 @@ using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{

View File

@ -5,7 +5,7 @@ using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{

View File

@ -6,7 +6,7 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
@ -82,7 +82,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code("\r\n")
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords))),
new RazorError(
RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"),
RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"),
4, 0, 4));
}
@ -107,7 +107,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
CSharpSymbolType.Unknown))
.Accepts(AcceptedCharacters.Any)))),
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 5, 0, 5),
new RazorError(RazorResources.ParseError_Expected_CloseBracket_Before_EOF("(", ")"), 4, 0, 4));
new RazorError(RazorResources.FormatParseError_Expected_CloseBracket_Before_EOF("(", ")"), 4, 0, 4));
}
[Fact]
@ -143,8 +143,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.Accepts(AcceptedCharacters.None)),
Factory.Markup("\r\n}")))),
new RazorError(RazorResources.ParseError_TextTagCannotContainAttributes, 8, 1, 4),
new RazorError(RazorResources.ParseError_MissingEndTag("text"), 8, 1, 4),
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"), 1, 0, 1));
new RazorError(RazorResources.FormatParseError_MissingEndTag("text"), 8, 1, 4),
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"), 1, 0, 1));
}
[Fact]
@ -168,7 +168,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
CSharpSymbolType.Unknown))
.Accepts(AcceptedCharacters.Any)))),
new RazorError(RazorResources.ParseError_RazorComment_Not_Terminated, 2, 0, 2),
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"), 1, 0, 1));
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"), 1, 0, 1));
}
}
}

View File

@ -1,12 +1,11 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
@ -21,7 +20,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
new DirectiveBlock(
Factory.MetaCode(word).Accepts(AcceptedCharacters.None)
),
new RazorError(RazorResources.ParseError_ReservedWord(word), SourceLocation.Zero));
new RazorError(RazorResources.FormatParseError_ReservedWord(word), SourceLocation.Zero));
}
[Theory]

View File

@ -6,7 +6,7 @@ using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.CodeTransition(),
Factory.MetaCode("section\r\n"))),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start(RazorResources.ErrorComponent_EndOfFile),
RazorResources.FormatParseError_Unexpected_Character_At_Section_Name_Start(RazorResources.ErrorComponent_EndOfFile),
10, 1, 0));
}
@ -52,7 +52,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.MetaCode("section \r\n")),
Factory.Markup(" ")),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start(RazorResources.ErrorComponent_EndOfFile),
RazorResources.FormatParseError_Unexpected_Character_At_Section_Name_Start(RazorResources.ErrorComponent_EndOfFile),
23, 1, 4));
}
@ -76,12 +76,12 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
ParseDocumentTest("@section 9 { <p>Foo</p> }",
new MarkupBlock(
Factory.EmptyHtml(),
new SectionBlock(new SectionCodeGenerator(String.Empty),
new SectionBlock(new SectionCodeGenerator(string.Empty),
Factory.CodeTransition(),
Factory.MetaCode("section ")),
Factory.Markup("9 { <p>Foo</p> }")),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Section_Name_Start(RazorResources.ErrorComponent_Character("9")),
RazorResources.FormatParseError_Unexpected_Character_At_Section_Name_Start(RazorResources.FormatErrorComponent_Character("9")),
9, 0, 9));
}
@ -121,7 +121,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.MetaCode("}").Accepts(AcceptedCharacters.None)),
Factory.EmptyHtml()),
new RazorError(
RazorResources.ParseError_Sections_Cannot_Be_Nested(RazorResources.SectionExample_CS),
RazorResources.FormatParseError_Sections_Cannot_Be_Nested(RazorResources.SectionExample_CS),
23, 0, 23));
}
@ -137,7 +137,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.AutoCompleteWith("}", atEndOfSpan: true),
new MarkupBlock())),
new RazorError(
RazorResources.ParseError_Expected_X("}"),
RazorResources.FormatParseError_Expected_X("}"),
14, 0, 14));
}
@ -152,10 +152,10 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.MetaCode("section foo {")
.AutoCompleteWith("}", atEndOfSpan: true),
new MarkupBlock(
// Need to provide the markup span as fragments, since the parser will split the {} into separate symbols.
// Need to provide the markup span as fragments, since the parser will split the {} into separate symbols.
Factory.Markup(" <p>Foo", "{", "}", "</p>")))),
new RazorError(
RazorResources.ParseError_Expected_X("}"),
RazorResources.FormatParseError_Expected_X("}"),
27, 0, 27));
}

View File

@ -6,7 +6,7 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
@ -151,7 +151,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
Factory.Code(" { { { { } zoop").AsFunctionsBody()
),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("functions", "}", "{"),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("functions", "}", "{"),
SourceLocation.Zero));
}
@ -175,7 +175,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
.AsImplicitExpression(CSharpCodeParser.DefaultKeywords)
.Accepts(AcceptedCharacters.NonWhiteSpace)),
new RazorError(
RazorResources.ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"),
RazorResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("/"),
1, 0, 1));
}

View File

@ -5,7 +5,7 @@ using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{

View File

@ -8,7 +8,7 @@ using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{

View File

@ -7,7 +7,7 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{

View File

@ -5,7 +5,7 @@ using System;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{
@ -44,7 +44,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
designTimeParser: true,
expectedErrors: new[]
{
new RazorError(RazorResources.ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("}"), new SourceLocation(2, 0, 2))
new RazorError(RazorResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("}"), new SourceLocation(2, 0, 2))
});
}
@ -64,7 +64,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
designTimeParser: true,
expectedErrors: new[]
{
new RazorError(RazorResources.ParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("."), new SourceLocation(2, 0, 2))
new RazorError(RazorResources.FormatParseError_Unexpected_Character_At_Start_Of_CodeBlock_CS("."), new SourceLocation(2, 0, 2))
});
}

View File

@ -5,7 +5,7 @@ using System;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.CSharp
{

View File

@ -7,8 +7,8 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Moq;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser
{

View File

@ -8,7 +8,7 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.Html
{
@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
Factory.Markup("<a"),
new MarkupBlock(new AttributeBlockCodeGenerator(name: "href", prefix: new LocationTagged<string>(" href='", 2, 0, 2), suffix: new LocationTagged<string>("'", 12, 0, 12)),
Factory.Markup(" href='").With(SpanCodeGenerator.Null),
Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged<string>(String.Empty, 9, 0, 9), value: new LocationTagged<string>("Foo", 9, 0, 9))),
Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged<string>(string.Empty, 9, 0, 9), value: new LocationTagged<string>("Foo", 9, 0, 9))),
Factory.Markup("'").With(SpanCodeGenerator.Null)),
Factory.Markup(" />").Accepts(AcceptedCharacters.None)));
}
@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
Factory.Markup("<a"),
new MarkupBlock(new AttributeBlockCodeGenerator(name: "href", prefix: new LocationTagged<string>(" href='", 2, 0, 2), suffix: new LocationTagged<string>("'", 20, 0, 20)),
Factory.Markup(" href='").With(SpanCodeGenerator.Null),
Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged<string>(String.Empty, 9, 0, 9), value: new LocationTagged<string>("Foo", 9, 0, 9))),
Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged<string>(string.Empty, 9, 0, 9), value: new LocationTagged<string>("Foo", 9, 0, 9))),
Factory.Markup(" Bar").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged<string>(" ", 12, 0, 12), value: new LocationTagged<string>("Bar", 13, 0, 13))),
Factory.Markup(" Baz").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged<string>(" ", 16, 0, 16), value: new LocationTagged<string>("Baz", 17, 0, 17))),
Factory.Markup("'").With(SpanCodeGenerator.Null)),
@ -50,7 +50,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
Factory.Markup("<a"),
new MarkupBlock(new AttributeBlockCodeGenerator(name: "href", prefix: new LocationTagged<string>(" href=\"", 2, 0, 2), suffix: new LocationTagged<string>("\"", 20, 0, 20)),
Factory.Markup(" href=\"").With(SpanCodeGenerator.Null),
Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged<string>(String.Empty, 9, 0, 9), value: new LocationTagged<string>("Foo", 9, 0, 9))),
Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged<string>(string.Empty, 9, 0, 9), value: new LocationTagged<string>("Foo", 9, 0, 9))),
Factory.Markup(" Bar").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged<string>(" ", 12, 0, 12), value: new LocationTagged<string>("Bar", 13, 0, 13))),
Factory.Markup(" Baz").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged<string>(" ", 16, 0, 16), value: new LocationTagged<string>("Baz", 17, 0, 17))),
Factory.Markup("\"").With(SpanCodeGenerator.Null)),
@ -63,9 +63,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
ParseBlockTest("<a href=Foo Bar Baz />",
new MarkupBlock(
Factory.Markup("<a"),
new MarkupBlock(new AttributeBlockCodeGenerator(name: "href", prefix: new LocationTagged<string>(" href=", 2, 0, 2), suffix: new LocationTagged<string>(String.Empty, 11, 0, 11)),
new MarkupBlock(new AttributeBlockCodeGenerator(name: "href", prefix: new LocationTagged<string>(" href=", 2, 0, 2), suffix: new LocationTagged<string>(string.Empty, 11, 0, 11)),
Factory.Markup(" href=").With(SpanCodeGenerator.Null),
Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged<string>(String.Empty, 8, 0, 8), value: new LocationTagged<string>("Foo", 8, 0, 8)))),
Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged<string>(string.Empty, 8, 0, 8), value: new LocationTagged<string>("Foo", 8, 0, 8)))),
Factory.Markup(" Bar Baz />").Accepts(AcceptedCharacters.None)));
}
@ -77,7 +77,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
Factory.Markup("<a"),
new MarkupBlock(new AttributeBlockCodeGenerator(name: "href", prefix: new LocationTagged<string>(" href='", 2, 0, 2), suffix: new LocationTagged<string>("'", 13, 0, 13)),
Factory.Markup(" href='").With(SpanCodeGenerator.Null),
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(String.Empty, 9, 0, 9), 9, 0, 9),
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 9, 0, 9), 9, 0, 9),
new ExpressionBlock(
Factory.CodeTransition(),
Factory.Code("foo")
@ -95,7 +95,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
Factory.Markup("<a"),
new MarkupBlock(new AttributeBlockCodeGenerator(name: "href", prefix: new LocationTagged<string>(" href='", 2, 0, 2), suffix: new LocationTagged<string>("'", 22, 0, 22)),
Factory.Markup(" href='").With(SpanCodeGenerator.Null),
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(String.Empty, 9, 0, 9), 9, 0, 9),
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 9, 0, 9), 9, 0, 9),
new ExpressionBlock(
Factory.CodeTransition(),
Factory.Code("foo")
@ -121,7 +121,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
Factory.Markup("<a"),
new MarkupBlock(new AttributeBlockCodeGenerator(name: "href", prefix: new LocationTagged<string>(" href='", 2, 0, 2), suffix: new LocationTagged<string>("'", 23, 0, 23)),
Factory.Markup(" href='").With(SpanCodeGenerator.Null),
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(String.Empty, 9, 0, 9), 9, 0, 9),
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 9, 0, 9), 9, 0, 9),
new ExpressionBlock(
Factory.CodeTransition(),
Factory.Code("foo")
@ -142,9 +142,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
ParseBlockTest("<input value=@foo />",
new MarkupBlock(
Factory.Markup("<input"),
new MarkupBlock(new AttributeBlockCodeGenerator(name: "value", prefix: new LocationTagged<string>(" value=", 6, 0, 6), suffix: new LocationTagged<string>(String.Empty, 17, 0, 17)),
new MarkupBlock(new AttributeBlockCodeGenerator(name: "value", prefix: new LocationTagged<string>(" value=", 6, 0, 6), suffix: new LocationTagged<string>(string.Empty, 17, 0, 17)),
Factory.Markup(" value=").With(SpanCodeGenerator.Null),
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(String.Empty, 13, 0, 13), 13, 0, 13),
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 13, 0, 13), 13, 0, 13),
new ExpressionBlock(
Factory.CodeTransition(),
Factory.Code("foo")
@ -159,9 +159,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
ParseDocumentTest("<input value=@foo />",
new MarkupBlock(
Factory.Markup("<input"),
new MarkupBlock(new AttributeBlockCodeGenerator(name: "value", prefix: new LocationTagged<string>(" value=", 6, 0, 6), suffix: new LocationTagged<string>(String.Empty, 17, 0, 17)),
new MarkupBlock(new AttributeBlockCodeGenerator(name: "value", prefix: new LocationTagged<string>(" value=", 6, 0, 6), suffix: new LocationTagged<string>(string.Empty, 17, 0, 17)),
Factory.Markup(" value=").With(SpanCodeGenerator.Null),
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(String.Empty, 13, 0, 13), 13, 0, 13),
new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged<string>(string.Empty, 13, 0, 13), 13, 0, 13),
new ExpressionBlock(
Factory.CodeTransition(),
Factory.Code("foo")
@ -188,7 +188,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
Factory.Markup("~/Foo/Bar")
.WithEditorHints(EditorHints.VirtualPath)
.With(new LiteralAttributeCodeGenerator(
new LocationTagged<string>(String.Empty, 9, 0, 9),
new LocationTagged<string>(string.Empty, 9, 0, 9),
new LocationTagged<SpanCodeGenerator>(new ResolveUrlCodeGenerator(), 9, 0, 9))),
Factory.Markup("'").With(SpanCodeGenerator.Null)),
Factory.Markup(" />")));

View File

@ -9,7 +9,7 @@ using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.Html
{
@ -22,7 +22,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
HtmlMarkupParser parser = new HtmlMarkupParser();
// Act and Assert
Assert.Throws<InvalidOperationException>(() => parser.ParseBlock(), RazorResources.Parser_Context_Not_Set);
var exception = Assert.Throws<InvalidOperationException>(() => parser.ParseBlock());
Assert.Equal(RazorResources.Parser_Context_Not_Set, exception.Message);
}
[Fact]
@ -39,7 +40,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
new MarkupBlock(
Factory.Markup("<")))),
new RazorError(
RazorResources.ParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF(RazorResources.BlockName_Code, "}", "{"),
1, 0, 1));
}
@ -67,8 +68,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
designTimeParser: true,
expectedErrors: new[]
{
new RazorError(RazorResources.ParseError_UnexpectedEndTag("html"), 7, 2, 0),
new RazorError(RazorResources.ParseError_Expected_EndOfBlock_Before_EOF("code", "}", "{"), 1, 0, 1)
new RazorError(RazorResources.FormatParseError_UnexpectedEndTag("html"), 7, 2, 0),
new RazorError(RazorResources.FormatParseError_Expected_EndOfBlock_Before_EOF("code", "}", "{"), 1, 0, 1)
});
}
@ -80,7 +81,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
new MarkupBlock(
Factory.Markup("< \r\n ")),
designTimeParser: true,
expectedErrors: new RazorError(RazorResources.ParseError_UnfinishedTag(String.Empty), 0, 0, 0));
expectedErrors: new RazorError(RazorResources.FormatParseError_UnfinishedTag(string.Empty), 0, 0, 0));
}
[Fact]
@ -217,7 +218,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
public void ParseBlockTerminatesAtEOF()
{
SingleSpanBlockTest("<foo>", "<foo>", BlockType.Markup, SpanKind.Markup,
new RazorError(RazorResources.ParseError_MissingEndTag("foo"), new SourceLocation(0, 0, 0)));
new RazorError(RazorResources.FormatParseError_MissingEndTag("foo"), new SourceLocation(0, 0, 0)));
}
[Fact]
@ -265,7 +266,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
BlockType.Markup,
SpanKind.Markup,
AcceptedCharacters.None,
new RazorError(RazorResources.ParseError_MissingEndTag("foo"), 0, 0, 0));
new RazorError(RazorResources.FormatParseError_MissingEndTag("foo"), 0, 0, 0));
}
@ -360,7 +361,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
new MarkupBlock(
Factory.Markup("<br/")
),
new RazorError(RazorResources.ParseError_UnfinishedTag("br"), SourceLocation.Zero));
new RazorError(RazorResources.FormatParseError_UnfinishedTag("br"), SourceLocation.Zero));
}
[Fact]

View File

@ -2,13 +2,12 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Web.WebPages.TestUtils;
using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.Html
{
@ -23,7 +22,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
HtmlMarkupParser parser = new HtmlMarkupParser();
// Act and Assert
Assert.Throws<InvalidOperationException>(() => parser.ParseDocument(), RazorResources.Parser_Context_Not_Set);
var exception = Assert.Throws<InvalidOperationException>(() => parser.ParseDocument());
Assert.Equal(RazorResources.Parser_Context_Not_Set, exception.Message);
}
[Fact]
@ -33,7 +33,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
HtmlMarkupParser parser = new HtmlMarkupParser();
// Act and Assert
Assert.Throws<InvalidOperationException>(() => parser.ParseSection(null, true), RazorResources.Parser_Context_Not_Set);
var exception = Assert.Throws<InvalidOperationException>(() => parser.ParseSection(null, true));
Assert.Equal(RazorResources.Parser_Context_Not_Set, exception.Message);
}
[Fact]

View File

@ -6,7 +6,7 @@ using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.Html
{
@ -54,7 +54,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
ParseBlockTest("</foo> bar baz",
new MarkupBlock(
Factory.Markup("</foo> ").Accepts(AcceptedCharacters.None)),
new RazorError(RazorResources.ParseError_UnexpectedEndTag("foo"), SourceLocation.Zero));
new RazorError(RazorResources.FormatParseError_UnexpectedEndTag("foo"), SourceLocation.Zero));
}
[Fact]
@ -63,7 +63,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
ParseBlockTest("<p><foo></bar>",
new MarkupBlock(
Factory.Markup("<p><foo></bar>").Accepts(AcceptedCharacters.None)),
new RazorError(RazorResources.ParseError_MissingEndTag("p"), new SourceLocation(0, 0, 0)));
new RazorError(RazorResources.FormatParseError_MissingEndTag("p"), new SourceLocation(0, 0, 0)));
}
[Fact]
@ -72,7 +72,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
ParseBlockTest("<foo>blah blah blah blah blah",
new MarkupBlock(
Factory.Markup("<foo>blah blah blah blah blah")),
new RazorError(RazorResources.ParseError_MissingEndTag("foo"), new SourceLocation(0, 0, 0)));
new RazorError(RazorResources.FormatParseError_MissingEndTag("foo"), new SourceLocation(0, 0, 0)));
}
[Fact]
@ -83,8 +83,8 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
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(RazorResources.ParseError_UnfinishedTag("foo"), new SourceLocation(0, 0, 0)));
Factory.Markup("baz").With(new LiteralAttributeCodeGenerator(new LocationTagged<string>(string.Empty, 9, 0, 9), new LocationTagged<string>("baz", 9, 0, 9))))),
new RazorError(RazorResources.FormatParseError_UnfinishedTag("foo"), new SourceLocation(0, 0, 0)));
}
}
}

View File

@ -1,11 +1,10 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.Html
{
@ -40,7 +39,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
ParseBlockTest("<p></> Bar",
new MarkupBlock(
Factory.Markup("<p></> ").Accepts(AcceptedCharacters.None)),
new RazorError(RazorResources.ParseError_MissingEndTag("p"), 0, 0, 0));
new RazorError(RazorResources.FormatParseError_MissingEndTag("p"), 0, 0, 0));
}
[Fact]
@ -110,7 +109,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
}
[Theory]
[PropertyData("VoidElementNames")]
[MemberData("VoidElementNames")]
public void VoidElementFollowedByContent(string tagName)
{
ParseBlockTest("<" + tagName + ">foo",
@ -120,7 +119,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
}
[Theory]
[PropertyData("VoidElementNames")]
[MemberData("VoidElementNames")]
public void VoidElementFollowedByOtherTag(string tagName)
{
ParseBlockTest("<" + tagName + "><other>foo",
@ -130,7 +129,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
}
[Theory]
[PropertyData("VoidElementNames")]
[MemberData("VoidElementNames")]
public void VoidElementFollowedByCloseTag(string tagName)
{
ParseBlockTest("<" + tagName + "> </" + tagName + ">foo",
@ -140,7 +139,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html
}
[Theory]
[PropertyData("VoidElementNames")]
[MemberData("VoidElementNames")]
public void IncompleteVoidElementEndTag(string tagName)
{
ParseBlockTest("<" + tagName + "></" + tagName,

View File

@ -9,7 +9,7 @@ using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.Html
{

View File

@ -8,7 +8,7 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.Html
{

View File

@ -8,8 +8,8 @@ using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Moq;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser
{
@ -19,35 +19,35 @@ namespace Microsoft.AspNet.Razor.Test.Parser
public void ConstructorRequiresNonNullSource()
{
var codeParser = new CSharpCodeParser();
Assert.ThrowsArgumentNull(() => new ParserContext(null, codeParser, new HtmlMarkupParser(), codeParser), "source");
Assert.Throws<ArgumentNullException>("source", () => new ParserContext(null, codeParser, new HtmlMarkupParser(), codeParser));
}
[Fact]
public void ConstructorRequiresNonNullCodeParser()
{
var codeParser = new CSharpCodeParser();
Assert.ThrowsArgumentNull(() => new ParserContext(new SeekableTextReader(TextReader.Null), null, new HtmlMarkupParser(), codeParser), "codeParser");
Assert.Throws<ArgumentNullException>("codeParser", () => new ParserContext(new SeekableTextReader(TextReader.Null), null, new HtmlMarkupParser(), codeParser));
}
[Fact]
public void ConstructorRequiresNonNullMarkupParser()
{
var codeParser = new CSharpCodeParser();
Assert.ThrowsArgumentNull(() => new ParserContext(new SeekableTextReader(TextReader.Null), codeParser, null, codeParser), "markupParser");
Assert.Throws<ArgumentNullException>("markupParser", () => new ParserContext(new SeekableTextReader(TextReader.Null), codeParser, null, codeParser));
}
[Fact]
public void ConstructorRequiresNonNullActiveParser()
{
Assert.ThrowsArgumentNull(() => new ParserContext(new SeekableTextReader(TextReader.Null), new CSharpCodeParser(), new HtmlMarkupParser(), null), "activeParser");
Assert.Throws<ArgumentNullException>("activeParser", () => new ParserContext(new SeekableTextReader(TextReader.Null), new CSharpCodeParser(), new HtmlMarkupParser(), null));
}
[Fact]
public void ConstructorThrowsIfActiveParserIsNotCodeOrMarkupParser()
{
Assert.ThrowsArgument(() => new ParserContext(new SeekableTextReader(TextReader.Null), new CSharpCodeParser(), new HtmlMarkupParser(), new CSharpCodeParser()),
"activeParser",
RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser);
var parameterName = "activeParser";
var exception = Assert.Throws<ArgumentException>(parameterName, () => new ParserContext(new SeekableTextReader(TextReader.Null), new CSharpCodeParser(), new HtmlMarkupParser(), new CSharpCodeParser()));
ExceptionHelpers.ValidateArgumentException(parameterName, RazorResources.ActiveParser_Must_Be_Code_Or_Markup_Parser, exception);
}
[Fact]

View File

@ -1,11 +1,12 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.TestCommon;
using Moq;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser
{
@ -17,14 +18,14 @@ namespace Microsoft.AspNet.Razor.Test.Parser
ParserVisitor target = null;
ParserResults results = new ParserResults(new BlockBuilder() { Type = BlockType.Comment }.Build(), new List<RazorError>());
Assert.ThrowsArgumentNull(() => target.Visit(results), "self");
Assert.Throws<ArgumentNullException>("self", () => target.Visit(results));
}
[Fact]
public void VisitThrowsOnNullResults()
{
ParserVisitor target = new Mock<ParserVisitor>().Object;
Assert.ThrowsArgumentNull(() => target.Visit(null), "result");
Assert.Throws<ArgumentNullException>("result", () => target.Visit(null));
}
[Fact]

View File

@ -7,7 +7,7 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
{

View File

@ -9,7 +9,7 @@ using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Test.Utils;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser.PartialParsing
{

View File

@ -6,7 +6,7 @@ using System.IO;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser
{
@ -15,13 +15,13 @@ namespace Microsoft.AspNet.Razor.Test.Parser
[Fact]
public void ConstructorRequiresNonNullCodeParser()
{
Assert.ThrowsArgumentNull(() => new RazorParser(null, new HtmlMarkupParser()), "codeParser");
Assert.Throws<ArgumentNullException>("codeParser", () => new RazorParser(null, new HtmlMarkupParser()));
}
[Fact]
public void ConstructorRequiresNonNullMarkupParser()
{
Assert.ThrowsArgumentNull(() => new RazorParser(new CSharpCodeParser(), null), "markupParser");
Assert.Throws<ArgumentNullException>("markupParser", () => new RazorParser(new CSharpCodeParser(), null));
}
[Fact]

View File

@ -1,10 +1,11 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser
{
@ -13,7 +14,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser
[Fact]
public void Constructor_Requires_NonNull_SymbolConverter()
{
Assert.ThrowsArgumentNull(() => new WhiteSpaceRewriter(null), "markupSpanFactory");
Assert.Throws<ArgumentNullException>("markupSpanFactory", () => new WhiteSpaceRewriter(null));
}
[Fact]

View File

@ -0,0 +1,20 @@
{
"version": "0.1-alpha-*",
"resources": "TestFiles/**/*",
"dependencies": {
"Moq": "4.2.1312.1622",
"Microsoft.AspNet.Razor": "",
"Microsoft.AspNet.Testing": "0.1-alpha-*",
"xunit.abstractions": "2.0.0-aspnet-*",
"xunit.assert": "2.0.0-aspnet-*",
"xunit.core": "2.0.0-aspnet-*",
"xunit.execution": "2.0.0-aspnet-*",
"Xunit.KRunner": "0.1-alpha-*"
},
"commands": {
"test": "Xunit.KRunner"
},
"configurations": {
"net45": { }
}
}

View File

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test
{

View File

@ -3,7 +3,7 @@
using System;
using System.Linq;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test
{
@ -13,8 +13,8 @@ namespace Microsoft.AspNet.Razor.Test
public void ConstructorThrowsIfNameIsNullOrEmpty()
{
// Act and Assert
Assert.ThrowsArgumentNullOrEmptyString(() => new RazorDirectiveAttribute(name: null, value: "blah"), "name");
Assert.ThrowsArgumentNullOrEmptyString(() => new RazorDirectiveAttribute(name: "", value: "blah"), "name");
Assert.Throws<ArgumentException>("name", () => new RazorDirectiveAttribute(name: null, value: "blah"));
Assert.Throws<ArgumentException>("name", () => new RazorDirectiveAttribute(name: "", value: "blah"));
}
[Fact]

View File

@ -1,9 +1,10 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test
{
@ -12,14 +13,14 @@ namespace Microsoft.AspNet.Razor.Test
[Fact]
public void ConstructorRequiresNonNullCodeLanguage()
{
Assert.ThrowsArgumentNull(() => new RazorEngineHost(null), "codeLanguage");
Assert.ThrowsArgumentNull(() => new RazorEngineHost(null, () => new HtmlMarkupParser()), "codeLanguage");
Assert.Throws<ArgumentNullException>("codeLanguage", () => new RazorEngineHost(null));
Assert.Throws<ArgumentNullException>("codeLanguage", () => new RazorEngineHost(null, () => new HtmlMarkupParser()));
}
[Fact]
public void ConstructorRequiresNonNullMarkupParser()
{
Assert.ThrowsArgumentNull(() => new RazorEngineHost(new CSharpRazorCodeLanguage(), null), "markupParserFactory");
Assert.Throws<ArgumentNullException>("markupParserFactory", () => new RazorEngineHost(new CSharpRazorCodeLanguage(), null));
}
[Fact]
@ -56,19 +57,19 @@ namespace Microsoft.AspNet.Razor.Test
[Fact]
public void DecorateCodeParserRequiresNonNullCodeParser()
{
Assert.ThrowsArgumentNull(() => CreateHost().DecorateCodeParser(null), "incomingCodeParser");
Assert.Throws<ArgumentNullException>("incomingCodeParser", () => CreateHost().DecorateCodeParser(null));
}
[Fact]
public void DecorateMarkupParserRequiresNonNullMarkupParser()
{
Assert.ThrowsArgumentNull(() => CreateHost().DecorateMarkupParser(null), "incomingMarkupParser");
Assert.Throws<ArgumentNullException>("incomingMarkupParser", () => CreateHost().DecorateMarkupParser(null));
}
[Fact]
public void DecorateCodeGeneratorRequiresNonNullCodeGenerator()
{
Assert.ThrowsArgumentNull(() => CreateHost().DecorateCodeGenerator(null), "incomingCodeGenerator");
Assert.Throws<ArgumentNullException>("incomingCodeGenerator", () => CreateHost().DecorateCodeGenerator(null));
}
[Fact]

View File

@ -1,6 +1,7 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Threading;
using System.Web.WebPages.TestUtils;
@ -8,8 +9,8 @@ using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Generator.Compiler.CSharp;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Moq;
using Xunit;
namespace Microsoft.AspNet.Razor.Test
{
@ -18,7 +19,7 @@ namespace Microsoft.AspNet.Razor.Test
[Fact]
public void ConstructorRequiresNonNullHost()
{
Assert.ThrowsArgumentNull(() => new RazorTemplateEngine(null), "host");
Assert.Throws<ArgumentNullException>("host", () => new RazorTemplateEngine(null));
}
[Fact]

View File

@ -4,7 +4,7 @@
using System;
using System.IO;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Text
{
@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Razor.Test.Text
[Fact]
public void ConstructorRequiresNonNullSourceReader()
{
Assert.ThrowsArgumentNull(() => new BufferingTextReader(null), "source");
Assert.Throws<ArgumentNullException>("source", () => new BufferingTextReader(null));
}
[Fact]

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Text
{

View File

@ -4,7 +4,7 @@
using System;
using System.Text;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Text
{
@ -74,7 +74,8 @@ namespace Microsoft.AspNet.Razor.Test.Text
LookaheadTextReader reader = CreateReader("abcdefg");
// Act and Assert
Assert.Throws<InvalidOperationException>(() => reader.CancelBacktrack(), RazorResources.CancelBacktrack_Must_Be_Called_Within_Lookahead);
var exception = Assert.Throws<InvalidOperationException>(() => reader.CancelBacktrack());
Assert.Equal(RazorResources.CancelBacktrack_Must_Be_Called_Within_Lookahead, exception.Message);
}
protected Action<StringBuilder, LookaheadTextReader> CaptureSourceLocation(Action<SourceLocation> capture)

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Text
{

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Text
{

View File

@ -4,7 +4,7 @@
using System;
using System.Web.WebPages.TestUtils;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Text
{
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Razor.Test.Text
[Fact]
public void ConstructorRequiresNonNullTextBuffer()
{
Assert.ThrowsArgumentNull(() => new TextBufferReader(null), "buffer");
Assert.Throws<ArgumentNullException>("buffer", () => new TextBufferReader(null));
}
[Fact]

View File

@ -4,8 +4,8 @@
using System;
using System.Web.WebPages.TestUtils;
using Microsoft.AspNet.Razor.Text;
using Microsoft.TestCommon;
using Moq;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Text
{
@ -14,37 +14,45 @@ namespace Microsoft.AspNet.Razor.Test.Text
[Fact]
public void ConstructorRequiresNonNegativeOldPosition()
{
Assert.ThrowsArgumentOutOfRange(() => new TextChange(-1, 0, new Mock<ITextBuffer>().Object, 0, 0, new Mock<ITextBuffer>().Object), "oldPosition", "Value must be greater than or equal to 0.");
var parameterName = "oldPosition";
var exception = Assert.Throws<ArgumentOutOfRangeException>(parameterName, () => new TextChange(-1, 0, new Mock<ITextBuffer>().Object, 0, 0, new Mock<ITextBuffer>().Object));
ExceptionHelpers.ValidateArgumentException(parameterName, "Value must be greater than or equal to 0.", exception);
}
[Fact]
public void ConstructorRequiresNonNegativeNewPosition()
{
Assert.ThrowsArgumentOutOfRange(() => new TextChange(0, 0, new Mock<ITextBuffer>().Object, -1, 0, new Mock<ITextBuffer>().Object), "newPosition", "Value must be greater than or equal to 0.");
var parameterName = "newPosition";
var exception = Assert.Throws<ArgumentOutOfRangeException>(parameterName, () => new TextChange(0, 0, new Mock<ITextBuffer>().Object, -1, 0, new Mock<ITextBuffer>().Object));
ExceptionHelpers.ValidateArgumentException(parameterName, "Value must be greater than or equal to 0.", exception);
}
[Fact]
public void ConstructorRequiresNonNegativeOldLength()
{
Assert.ThrowsArgumentOutOfRange(() => new TextChange(0, -1, new Mock<ITextBuffer>().Object, 0, 0, new Mock<ITextBuffer>().Object), "oldLength", "Value must be greater than or equal to 0.");
var parameterName = "oldLength";
var exception = Assert.Throws<ArgumentOutOfRangeException>(parameterName, () => new TextChange(0, -1, new Mock<ITextBuffer>().Object, 0, 0, new Mock<ITextBuffer>().Object));
ExceptionHelpers.ValidateArgumentException(parameterName, "Value must be greater than or equal to 0.", exception);
}
[Fact]
public void ConstructorRequiresNonNegativeNewLength()
{
Assert.ThrowsArgumentOutOfRange(() => new TextChange(0, 0, new Mock<ITextBuffer>().Object, 0, -1, new Mock<ITextBuffer>().Object), "newLength", "Value must be greater than or equal to 0.");
var parameterName = "newLength";
var exception = Assert.Throws<ArgumentOutOfRangeException>(parameterName, () => new TextChange(0, 0, new Mock<ITextBuffer>().Object, 0, -1, new Mock<ITextBuffer>().Object));
ExceptionHelpers.ValidateArgumentException(parameterName, "Value must be greater than or equal to 0.", exception);
}
[Fact]
public void ConstructorRequiresNonNullOldBuffer()
{
Assert.ThrowsArgumentNull(() => new TextChange(0, 0, null, 0, 0, new Mock<ITextBuffer>().Object), "oldBuffer");
Assert.Throws<ArgumentNullException>("oldBuffer", () => new TextChange(0, 0, null, 0, 0, new Mock<ITextBuffer>().Object));
}
[Fact]
public void ConstructorRequiresNonNullNewBuffer()
{
Assert.ThrowsArgumentNull(() => new TextChange(0, 0, new Mock<ITextBuffer>().Object, 0, 0, null), "newBuffer");
Assert.Throws<ArgumentNullException>("newBuffer", () => new TextChange(0, 0, new Mock<ITextBuffer>().Object, 0, 0, null));
}
[Fact]

View File

@ -4,7 +4,7 @@
using System;
using System.IO;
using Microsoft.AspNet.Razor.Parser;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Text
{
@ -13,74 +13,74 @@ namespace Microsoft.AspNet.Razor.Test.Text
[Fact]
public void ReadUntilWithCharThrowsArgNullIfReaderNull()
{
Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(null, '@'), "reader");
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadUntil(null, '@'));
}
[Fact]
public void ReadUntilInclusiveWithCharThrowsArgNullIfReaderNull()
{
Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(null, '@', inclusive: true), "reader");
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadUntil(null, '@', inclusive: true));
}
[Fact]
public void ReadUntilWithMultipleTerminatorsThrowsArgNullIfReaderNull()
{
Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(null, '/', '>'), "reader");
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadUntil(null, '/', '>'));
}
[Fact]
public void ReadUntilInclusiveWithMultipleTerminatorsThrowsArgNullIfReaderNull()
{
// NOTE: Using named parameters would be difficult here, hence the inline comment
Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(null, /* inclusive */ true, '/', '>'), "reader");
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadUntil(null, /* inclusive */ true, '/', '>'));
}
[Fact]
public void ReadUntilWithPredicateThrowsArgNullIfReaderNull()
{
Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(null, c => true), "reader");
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadUntil(null, c => true));
}
[Fact]
public void ReadUntilInclusiveWithPredicateThrowsArgNullIfReaderNull()
{
Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(null, c => true, inclusive: true), "reader");
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadUntil(null, c => true, inclusive: true));
}
[Fact]
public void ReadUntilWithPredicateThrowsArgExceptionIfPredicateNull()
{
Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(new StringReader("Foo"), (Predicate<char>)null), "condition");
Assert.Throws<ArgumentNullException>("condition", () => TextReaderExtensions.ReadUntil(new StringReader("Foo"), (Predicate<char>)null));
}
[Fact]
public void ReadUntilInclusiveWithPredicateThrowsArgExceptionIfPredicateNull()
{
Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(new StringReader("Foo"), (Predicate<char>)null, inclusive: true), "condition");
Assert.Throws<ArgumentNullException>("condition", () => TextReaderExtensions.ReadUntil(new StringReader("Foo"), (Predicate<char>)null, inclusive: true));
}
[Fact]
public void ReadWhileWithPredicateThrowsArgNullIfReaderNull()
{
Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadWhile(null, c => true), "reader");
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadWhile(null, c => true));
}
[Fact]
public void ReadWhileInclusiveWithPredicateThrowsArgNullIfReaderNull()
{
Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadWhile(null, c => true, inclusive: true), "reader");
Assert.Throws<ArgumentNullException>("reader", () => TextReaderExtensions.ReadWhile(null, c => true, inclusive: true));
}
[Fact]
public void ReadWhileWithPredicateThrowsArgNullIfPredicateNull()
{
Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadWhile(new StringReader("Foo"), (Predicate<char>)null), "condition");
Assert.Throws<ArgumentNullException>("condition", () => TextReaderExtensions.ReadWhile(new StringReader("Foo"), (Predicate<char>)null));
}
[Fact]
public void ReadWhileInclusiveWithPredicateThrowsArgNullIfPredicateNull()
{
Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadWhile(new StringReader("Foo"), (Predicate<char>)null, inclusive: true), "condition");
Assert.Throws<ArgumentNullException>("condition", () => TextReaderExtensions.ReadWhile(new StringReader("Foo"), (Predicate<char>)null, inclusive: true));
}
[Fact]

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Tokenizer
{

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Tokenizer
{

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Tokenizer
{

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Tokenizer
{

View File

@ -1,9 +1,10 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Razor.Tokenizer;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Tokenizer
{
@ -12,7 +13,7 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
[Fact]
public void Constructor_Throws_ArgNull_If_Null_Source_Provided()
{
Assert.ThrowsArgumentNull(() => new CSharpTokenizer(null), "source");
Assert.Throws<ArgumentNullException>("source", () => new CSharpTokenizer(null));
}
[Fact]

View File

@ -1,9 +1,10 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Razor.Tokenizer;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Tokenizer
{
@ -12,7 +13,7 @@ namespace Microsoft.AspNet.Razor.Test.Tokenizer
[Fact]
public void Constructor_Throws_ArgNull_If_Null_Source_Provided()
{
Assert.ThrowsArgumentNull(() => new HtmlTokenizer(null), "source");
Assert.Throws<ArgumentNullException>("source", () => new HtmlTokenizer(null));
}
[Fact]

View File

@ -5,7 +5,7 @@ using System.IO;
using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Tokenizer
{

View File

@ -8,7 +8,7 @@ using System.Text;
using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer;
using Microsoft.AspNet.Razor.Tokenizer.Symbols;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Tokenizer
{

View File

@ -1,8 +1,10 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Razor.Utils;
using Microsoft.TestCommon;
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Utils
{
@ -11,7 +13,7 @@ namespace Microsoft.AspNet.Razor.Test.Utils
[Fact]
public void ConstructorRequiresNonNullAction()
{
Assert.ThrowsArgumentNull(() => new DisposableAction(null), "action");
Assert.Throws<ArgumentNullException>("action", () => new DisposableAction(null));
}
[Fact]

View File

@ -0,0 +1,13 @@
using System;
using Xunit;
namespace Microsoft.AspNet.Razor.Test
{
public static class ExceptionHelpers
{
public static void ValidateArgumentException(string parameterName, string expectedMessage, ArgumentException exception)
{
Assert.Equal(string.Format("{0}{1}Parameter name: {2}", expectedMessage, Environment.NewLine, parameterName), exception.Message);
}
}
}

View File

@ -2,8 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Text.RegularExpressions;
using Microsoft.TestCommon;
#if DEBUG
using System.Diagnostics;
#endif
using Xunit;
namespace Microsoft.AspNet.Razor.Test.Utils
{

View File

@ -3,9 +3,9 @@
using System.IO;
using System.Reflection;
using Microsoft.TestCommon;
using Xunit;
namespace System.Web.WebPages.TestUtils
namespace Microsoft.AspNet.Razor.Test
{
public class TestFile
{
@ -22,7 +22,9 @@ namespace System.Web.WebPages.TestUtils
public static TestFile Create(string localResourceName)
{
return new TestFile(String.Format(ResourceNameFormat, Assembly.GetCallingAssembly().GetName().Name, localResourceName), Assembly.GetCallingAssembly());
// TODO: When paths are preserved use this.
//return new TestFile(string.Format(ResourceNameFormat, Assembly.GetCallingAssembly().GetName().Name, localResourceName), Assembly.GetCallingAssembly());
return new TestFile(localResourceName, Assembly.GetCallingAssembly());
}
public Stream OpenRead()
@ -30,7 +32,7 @@ namespace System.Web.WebPages.TestUtils
Stream strm = Assembly.GetManifestResourceStream(ResourceName);
if (strm == null)
{
Assert.True(false, String.Format("Manifest resource: {0} not found", ResourceName));
Assert.True(false, string.Format("Manifest resource: {0} not found", ResourceName));
}
return strm;
}

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.0.10827" targetFramework="net45" />
<package id="xunit" version="1.9.1" targetFramework="net45" />
<package id="xunit.extensions" version="1.9.1" targetFramework="net45" />
</packages>

View File

@ -1,14 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.TestCommon
{
// This extends xUnit.net's Assert class, and makes it partial so that we can
// organize the extension points by logical functionality (rather than dumping them
// all into this single file).
//
// See files named XxxAssertions for root extensions to Assert.
public partial class Assert : Xunit.Assert
{
}
}

View File

@ -1,73 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Globalization;
using System.Threading;
namespace Microsoft.TestCommon
{
public class CultureReplacer : IDisposable
{
private const string _defaultCultureName = "en-GB";
private const string _defaultUICultureName = "en-US";
private static readonly CultureInfo _defaultCulture = CultureInfo.GetCultureInfo(_defaultCultureName);
private readonly CultureInfo _originalCulture;
private readonly CultureInfo _originalUICulture;
private readonly long _threadId;
// Culture => Formatting of dates/times/money/etc, defaults to en-GB because en-US is the same as InvariantCulture
// We want to be able to find issues where the InvariantCulture is used, but a specific culture should be.
//
// UICulture => Language
public CultureReplacer(string culture = _defaultCultureName, string uiCulture = _defaultUICultureName)
{
_originalCulture = Thread.CurrentThread.CurrentCulture;
_originalUICulture = Thread.CurrentThread.CurrentUICulture;
_threadId = Thread.CurrentThread.ManagedThreadId;
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(culture);
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(uiCulture);
}
/// <summary>
/// The name of the culture that is used as the default value for Thread.CurrentCulture when CultureReplacer is used.
/// </summary>
public static string DefaultCultureName
{
get { return _defaultCultureName; }
}
/// <summary>
/// The name of the culture that is used as the default value for Thread.UICurrentCulture when CultureReplacer is used.
/// </summary>
public static string DefaultUICultureName
{
get { return _defaultUICultureName; }
}
/// <summary>
/// The culture that is used as the default value for Thread.CurrentCulture when CultureReplacer is used.
/// </summary>
public static CultureInfo DefaultCulture
{
get { return _defaultCulture; }
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (disposing)
{
Assert.True(Thread.CurrentThread.ManagedThreadId == _threadId, "The current thread is not the same as the thread invoking the constructor. This should never happen.");
Thread.CurrentThread.CurrentCulture = _originalCulture;
Thread.CurrentThread.CurrentUICulture = _originalUICulture;
}
}
}
}

View File

@ -1,12 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.TestCommon
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public abstract class DataAttribute : Xunit.Extensions.DataAttribute
{
}
}

View File

@ -1,522 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.ComponentModel;
using System.Reflection;
using System.Threading.Tasks;
using System.Web;
namespace Microsoft.TestCommon
{
public partial class Assert
{
/// <summary>
/// Verifies that the exact exception is thrown (and not a derived exception type).
/// </summary>
/// <typeparam name="T">The type of the exception expected to be thrown</typeparam>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static T Throws<T>(Action testCode)
where T : Exception
{
return (T)Throws(typeof(T), testCode);
}
/// <summary>
/// Verifies that the exact exception is thrown (and not a derived exception type).
/// Generally used to test property accessors.
/// </summary>
/// <typeparam name="T">The type of the exception expected to be thrown</typeparam>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static T Throws<T>(Func<object> testCode)
where T : Exception
{
return (T)Throws(typeof(T), testCode);
}
/// <summary>
/// Verifies that the exact exception is thrown (and not a derived exception type).
/// </summary>
/// <param name="exceptionType">The type of the exception expected to be thrown</param>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static Exception Throws(Type exceptionType, Action testCode)
{
Exception exception = RecordException(testCode);
return VerifyException(exceptionType, exception);
}
/// <summary>
/// Verifies that the exact exception is thrown (and not a derived exception type).
/// Generally used to test property accessors.
/// </summary>
/// <param name="exceptionType">The type of the exception expected to be thrown</param>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static Exception Throws(Type exceptionType, Func<object> testCode)
{
return Throws(exceptionType, () => { testCode(); });
}
/// <summary>
/// Verifies that an exception of the given type (or optionally a derived type) is thrown.
/// </summary>
/// <typeparam name="TException">The type of the exception expected to be thrown</typeparam>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="allowDerivedExceptions">Pass true to allow exceptions which derive from TException; pass false, otherwise</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static TException Throws<TException>(Action testCode, bool allowDerivedExceptions)
where TException : Exception
{
Type exceptionType = typeof(TException);
Exception exception = RecordException(testCode);
TargetInvocationException tie = exception as TargetInvocationException;
if (tie != null)
{
exception = tie.InnerException;
}
if (exception == null)
{
throw new ThrowsException(exceptionType);
}
var typedException = exception as TException;
if (typedException == null || (!allowDerivedExceptions && typedException.GetType() != typeof(TException)))
{
throw new ThrowsException(exceptionType, exception);
}
return typedException;
}
/// <summary>
/// Verifies that an exception of the given type (or optionally a derived type) is thrown.
/// Generally used to test property accessors.
/// </summary>
/// <typeparam name="TException">The type of the exception expected to be thrown</typeparam>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="allowDerivedExceptions">Pass true to allow exceptions which derive from TException; pass false, otherwise</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static TException Throws<TException>(Func<object> testCode, bool allowDerivedExceptions)
where TException : Exception
{
return Throws<TException>(() => { testCode(); }, allowDerivedExceptions);
}
/// <summary>
/// Verifies that an exception of the given type (or optionally a derived type) is thrown.
/// Also verifies that the exception message matches.
/// </summary>
/// <typeparam name="TException">The type of the exception expected to be thrown</typeparam>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="exceptionMessage">The exception message to verify</param>
/// <param name="allowDerivedExceptions">Pass true to allow exceptions which derive from TException; pass false, otherwise</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static TException Throws<TException>(Action testCode, string exceptionMessage, bool allowDerivedExceptions = false)
where TException : Exception
{
var ex = Throws<TException>(testCode, allowDerivedExceptions);
VerifyExceptionMessage(ex, exceptionMessage);
return ex;
}
/// <summary>
/// Verifies that an exception of the given type (or optionally a derived type) is thrown.
/// Also verified that the exception message matches.
/// </summary>
/// <typeparam name="TException">The type of the exception expected to be thrown</typeparam>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="exceptionMessage">The exception message to verify</param>
/// <param name="allowDerivedExceptions">Pass true to allow exceptions which derive from TException; pass false, otherwise</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static TException Throws<TException>(Func<object> testCode, string exceptionMessage, bool allowDerivedExceptions = false)
where TException : Exception
{
return Throws<TException>(() => { testCode(); }, exceptionMessage, allowDerivedExceptions);
}
/// <summary>
/// Verifies that the code throws an <see cref="ArgumentException"/> (or optionally any exception which derives from it).
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="paramName">The name of the parameter that should throw the exception</param>
/// <param name="allowDerivedExceptions">Pass true to allow exceptions which derive from TException; pass false, otherwise</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static ArgumentException ThrowsArgument(Action testCode, string paramName, bool allowDerivedExceptions = false)
{
var ex = Throws<ArgumentException>(testCode, allowDerivedExceptions);
if (paramName != null)
{
Equal(paramName, ex.ParamName);
}
return ex;
}
/// <summary>
/// Verifies that the code throws an <see cref="ArgumentException"/> (or optionally any exception which derives from it).
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="paramName">The name of the parameter that should throw the exception</param>
/// <param name="exceptionMessage">The exception message to verify</param>
/// <param name="allowDerivedExceptions">Pass true to allow exceptions which derive from TException; pass false, otherwise</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static ArgumentException ThrowsArgument(Action testCode, string paramName, string exceptionMessage, bool allowDerivedExceptions = false)
{
var ex = Throws<ArgumentException>(testCode, allowDerivedExceptions);
if (paramName != null)
{
Equal(paramName, ex.ParamName);
}
VerifyExceptionMessage(ex, exceptionMessage, partialMatch: true);
return ex;
}
/// <summary>
/// Verifies that the code throws an ArgumentException (or optionally any exception which derives from it).
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="paramName">The name of the parameter that should throw the exception</param>
/// <param name="allowDerivedExceptions">Pass true to allow exceptions which derive from TException; pass false, otherwise</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static ArgumentException ThrowsArgument(Func<object> testCode, string paramName, bool allowDerivedExceptions = false)
{
var ex = Throws<ArgumentException>(testCode, allowDerivedExceptions);
if (paramName != null)
{
Equal(paramName, ex.ParamName);
}
return ex;
}
/// <summary>
/// Verifies that the code throws an ArgumentNullException (or optionally any exception which derives from it).
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="paramName">The name of the parameter that should throw the exception</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static ArgumentNullException ThrowsArgumentNull(Action testCode, string paramName)
{
var ex = Throws<ArgumentNullException>(testCode, allowDerivedExceptions: false);
if (paramName != null)
{
Equal(paramName, ex.ParamName);
}
return ex;
}
/// <summary>
/// Verifies that the code throws an ArgumentNullException with the expected message that indicates that the value cannot
/// be null or empty.
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="paramName">The name of the parameter that should throw the exception</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static ArgumentException ThrowsArgumentNullOrEmpty(Action testCode, string paramName)
{
return Throws<ArgumentException>(testCode, "Value cannot be null or empty.\r\nParameter name: " + paramName, allowDerivedExceptions: false);
}
/// <summary>
/// Verifies that the code throws an ArgumentNullException with the expected message that indicates that the value cannot
/// be null or empty string.
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="paramName">The name of the parameter that should throw the exception</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static ArgumentException ThrowsArgumentNullOrEmptyString(Action testCode, string paramName)
{
return ThrowsArgument(testCode, paramName, "Value cannot be null or an empty string.", allowDerivedExceptions: true);
}
/// <summary>
/// Verifies that the code throws an ArgumentOutOfRangeException (or optionally any exception which derives from it).
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="paramName">The name of the parameter that should throw the exception</param>
/// <param name="exceptionMessage">The exception message to verify</param>
/// <param name="allowDerivedExceptions">Pass true to allow exceptions which derive from TException; pass false, otherwise</param>
/// <param name="actualValue">The actual value provided</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static ArgumentOutOfRangeException ThrowsArgumentOutOfRange(Action testCode, string paramName, string exceptionMessage, bool allowDerivedExceptions = false, object actualValue = null)
{
if (exceptionMessage != null)
{
exceptionMessage = exceptionMessage + "\r\nParameter name: " + paramName;
if (actualValue != null)
{
exceptionMessage += String.Format(CultureReplacer.DefaultCulture, "\r\nActual value was {0}.", actualValue);
}
}
var ex = Throws<ArgumentOutOfRangeException>(testCode, exceptionMessage, allowDerivedExceptions);
if (paramName != null)
{
Equal(paramName, ex.ParamName);
}
return ex;
}
/// <summary>
/// Verifies that the code throws an <see cref="ArgumentOutOfRangeException"/> with the expected message that indicates that
/// the value must be greater than the given <paramref name="value"/>.
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="paramName">The name of the parameter that should throw the exception</param>
/// <param name="actualValue">The actual value provided.</param>
/// <param name="value">The expected limit value.</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static ArgumentOutOfRangeException ThrowsArgumentGreaterThan(Action testCode, string paramName, string value, object actualValue = null)
{
return ThrowsArgumentOutOfRange(
testCode,
paramName,
String.Format(CultureReplacer.DefaultCulture, "Value must be greater than {0}.", value), false, actualValue);
}
/// <summary>
/// Verifies that the code throws an <see cref="ArgumentOutOfRangeException"/> with the expected message that indicates that
/// the value must be greater than or equal to the given value.
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="paramName">The name of the parameter that should throw the exception</param>
/// <param name="value">The expected limit value.</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static ArgumentOutOfRangeException ThrowsArgumentGreaterThanOrEqualTo(Action testCode, string paramName, string value, object actualValue = null)
{
return ThrowsArgumentOutOfRange(
testCode,
paramName,
String.Format(CultureReplacer.DefaultCulture, "Value must be greater than or equal to {0}.", value), false, actualValue);
}
/// <summary>
/// Verifies that the code throws an <see cref="ArgumentOutOfRangeException"/> with the expected message that indicates that
/// the value must be less than the given <paramref name="maxValue"/>.
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="paramName">The name of the parameter that should throw the exception</param>
/// <param name="actualValue">The actual value provided.</param>
/// <param name="maxValue">The expected limit value.</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static ArgumentOutOfRangeException ThrowsArgumentLessThan(Action testCode, string paramName, string maxValue, object actualValue = null)
{
return ThrowsArgumentOutOfRange(
testCode,
paramName,
String.Format(CultureReplacer.DefaultCulture, "Value must be less than {0}.", maxValue), false, actualValue);
}
/// <summary>
/// Verifies that the code throws an <see cref="ArgumentOutOfRangeException"/> with the expected message that indicates that
/// the value must be less than or equal to the given <paramref name="maxValue"/>.
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="paramName">The name of the parameter that should throw the exception</param>
/// <param name="actualValue">The actual value provided.</param>
/// <param name="maxValue">The expected limit value.</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static ArgumentOutOfRangeException ThrowsArgumentLessThanOrEqualTo(Action testCode, string paramName, string maxValue, object actualValue = null)
{
return ThrowsArgumentOutOfRange(
testCode,
paramName,
String.Format(CultureReplacer.DefaultCulture, "Value must be less than or equal to {0}.", maxValue), false, actualValue);
}
/// <summary>
/// Verifies that the code throws an HttpException (or optionally any exception which derives from it).
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="exceptionMessage">The exception message to verify</param>
/// <param name="httpCode">The expected HTTP status code of the exception</param>
/// <param name="allowDerivedExceptions">Pass true to allow exceptions which derive from TException; pass false, otherwise</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static HttpException ThrowsHttpException(Action testCode, string exceptionMessage, int httpCode, bool allowDerivedExceptions = false)
{
var ex = Throws<HttpException>(testCode, exceptionMessage, allowDerivedExceptions);
Equal(httpCode, ex.GetHttpCode());
return ex;
}
/// <summary>
/// Verifies that the code throws an InvalidEnumArgumentException (or optionally any exception which derives from it).
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="paramName">The name of the parameter that should throw the exception</param>
/// <param name="invalidValue">The expected invalid value that should appear in the message</param>
/// <param name="enumType">The type of the enumeration</param>
/// <param name="allowDerivedExceptions">Pass true to allow exceptions which derive from TException; pass false, otherwise</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static InvalidEnumArgumentException ThrowsInvalidEnumArgument(Action testCode, string paramName, int invalidValue, Type enumType, bool allowDerivedExceptions = false)
{
string message = String.Format(CultureReplacer.DefaultCulture,
"The value of argument '{0}' ({1}) is invalid for Enum type '{2}'.{3}Parameter name: {0}",
paramName, invalidValue, enumType.Name, Environment.NewLine);
return Throws<InvalidEnumArgumentException>(testCode, message, allowDerivedExceptions);
}
/// <summary>
/// Verifies that the code throws an HttpException (or optionally any exception which derives from it).
/// </summary>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <param name="objectName">The name of the object that was dispose</param>
/// <param name="allowDerivedExceptions">Pass true to allow exceptions which derive from TException; pass false, otherwise</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
public static ObjectDisposedException ThrowsObjectDisposed(Action testCode, string objectName, bool allowDerivedExceptions = false)
{
var ex = Throws<ObjectDisposedException>(testCode, allowDerivedExceptions);
if (objectName != null)
{
Equal(objectName, ex.ObjectName);
}
return ex;
}
/// <summary>
/// Verifies that an exception of the given type is thrown.
/// </summary>
/// <typeparam name="TException">The type of the exception expected to be thrown</typeparam>
/// <param name="testCode">A delegate to the code to be tested</param>
/// <returns>The exception that was thrown, when successful</returns>
/// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
/// <remarks>
/// Unlike other Throws* methods, this method does not enforce running the exception delegate with a known Thread Culture.
/// </remarks>
public static async Task<TException> ThrowsAsync<TException>(Func<Task> testCode)
where TException : Exception
{
Exception exception = null;
try
{
// The 'testCode' Task might execute asynchronously in a different thread making it hard to enforce the thread culture.
// The correct way to verify exception messages in such a scenario would be to run the task synchronously inside of a
// culture enforced block.
await testCode();
}
catch (Exception ex)
{
exception = ex;
}
VerifyException(typeof(TException), exception);
return (TException)exception;
}
// We've re-implemented all the xUnit.net Throws code so that we can get this
// updated implementation of RecordException which silently unwraps any instances
// of AggregateException. In addition to unwrapping exceptions, this method ensures
// that tests are executed in with a known set of Culture and UICulture. This prevents
// tests from failing when executed on a non-English machine.
private static Exception RecordException(Action testCode)
{
try
{
using (new CultureReplacer())
{
testCode();
}
return null;
}
catch (Exception exception)
{
return UnwrapException(exception);
}
}
private static Exception UnwrapException(Exception exception)
{
AggregateException aggEx = exception as AggregateException;
if (aggEx != null)
{
return aggEx.GetBaseException();
}
return exception;
}
private static Exception VerifyException(Type exceptionType, Exception exception)
{
if (exception == null)
{
throw new ThrowsException(exceptionType);
}
else if (exceptionType != exception.GetType())
{
throw new ThrowsException(exceptionType, exception);
}
return exception;
}
private static void VerifyExceptionMessage(Exception exception, string expectedMessage, bool partialMatch = false)
{
if (expectedMessage != null)
{
if (!partialMatch)
{
Equal(expectedMessage, exception.Message);
}
else
{
Contains(expectedMessage, exception.Message);
}
}
}
// Custom ThrowsException so we can filter the stack trace.
[Serializable]
private class ThrowsException : Xunit.Sdk.ThrowsException
{
public ThrowsException(Type type) : base(type) { }
public ThrowsException(Type type, Exception ex) : base(type, ex) { }
protected override bool ExcludeStackFrame(string stackFrame)
{
if (stackFrame.StartsWith("at Microsoft.TestCommon.Assert.", StringComparison.OrdinalIgnoreCase))
{
return true;
}
return base.ExcludeStackFrame(stackFrame);
}
}
}
}

View File

@ -1,61 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Xunit.Sdk;
namespace Microsoft.TestCommon
{
/// <summary>
/// An override of <see cref="FactAttribute"/> that provides extended capabilities.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class FactAttribute : Xunit.FactAttribute
{
public FactAttribute()
{
Timeout = Debugger.IsAttached ? Int32.MaxValue : TimeoutConstant.DefaultTimeout;
Platforms = Platform.All;
PlatformJustification = "Unsupported platform (test runs on {0}, current platform is {1})";
}
/// <summary>
/// Gets the platform that the unit test is currently running on.
/// </summary>
protected Platform Platform
{
get { return PlatformInfo.Platform; }
}
/// <summary>
/// Gets or set the platforms that the unit test is compatible with. Defaults to
/// <see cref="Platform.All"/>.
/// </summary>
public Platform Platforms { get; set; }
/// <summary>
/// Gets or sets the platform skipping justification. This message can receive
/// the supported platforms as {0}, and the current platform as {1}.
/// </summary>
public string PlatformJustification { get; set; }
/// <inheritdoc/>
protected override IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo method)
{
if ((Platforms & Platform) == 0)
{
return new[] {
new SkipCommand(
method,
DisplayName,
String.Format(PlatformJustification, Platforms.ToString().Replace(", ", " | "), Platform)
)
};
}
return base.EnumerateTestCommands(method);
}
}
}

View File

@ -1,16 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.TestCommon
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class InlineDataAttribute : Xunit.Extensions.InlineDataAttribute
{
public InlineDataAttribute(params object[] dataValues)
: base(dataValues)
{
}
}
}

View File

@ -1,56 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{FCCC4CB7-BAF7-4A57-9F89-E5766FE536C0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.TestCommon</RootNamespace>
<AssemblyName>Microsoft.TestCommon</AssemblyName>
<OutputPath>..\..\bin\$(Configuration)\Test\</OutputPath>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="xunit, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\xunit.1.9.1\lib\net20\xunit.dll</HintPath>
</Reference>
<Reference Include="xunit.extensions, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\xunit.extensions.1.9.1\lib\net20\xunit.extensions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DataAttribute.cs" />
<Compile Include="ExceptionAssertions.cs" />
<Compile Include="FactAttribute.cs" />
<Compile Include="InlineDataAttribute.cs" />
<Compile Include="Microsoft\TestCommon\TimeoutConstant.cs" />
<Compile Include="Platform.cs" />
<Compile Include="PlatformInfo.cs" />
<Compile Include="PropertyDataAttribute.cs" />
<Compile Include="ReplaceCultureAttribute.cs" />
<Compile Include="Assert.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="CultureReplacer.cs" />
<Compile Include="TestFile.cs" />
<Compile Include="TheoryAttribute.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,23 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.TestCommon
{
/// <summary>
/// MSTest timeout constants for use with the <see cref="Microsoft.VisualStudio.TestTools.UnitTesting.TimeoutAttribute"/>.
/// </summary>
public class TimeoutConstant
{
private const int seconds = 1000;
/// <summary>
/// The default timeout for test methods.
/// </summary>
public const int DefaultTimeout = 30 * seconds;
/// <summary>
/// An extended timeout for longer running test methods.
/// </summary>
public const int ExtendedTimeout = 240 * seconds;
}
}

View File

@ -1,37 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.TestCommon
{
/// <summary>
/// An enumeration of known platforms that the unit test might be running under.
/// </summary>
[Flags]
public enum Platform
{
/// <summary>
/// A special value used to indicate that the test is valid on all known platforms.
/// </summary>
All = 0xFFFFFF,
/// <summary>
/// Indicates that the test wants to run on .NET 4 (when used with
/// <see cref="FactAttribute.Platforms"/> and/or <see cref="TheoryAttribute.Platforms"/>),
/// or that the current platform that the test is running on is .NET 4 (when used with the
/// <see cref="PlatformInfo.Platform"/>, <see cref="FactAttribute.Platform"/>, and/or
/// <see cref="TheoryAttribute.Platform"/>).
/// </summary>
Net40 = 0x01,
/// <summary>
/// Indicates that the test wants to run on .NET 4.5 (when used with
/// <see cref="FactAttribute.Platforms"/> and/or <see cref="TheoryAttribute.Platforms"/>),
/// or that the current platform that the test is running on is .NET 4.5 (when used with the
/// <see cref="PlatformInfo.Platform"/>, <see cref="FactAttribute.Platform"/>, and/or
/// <see cref="TheoryAttribute.Platform"/>).
/// </summary>
Net45 = 0x02,
}
}

View File

@ -1,34 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.TestCommon
{
/// <summary>
/// Used to retrieve the currently running platform.
/// </summary>
public static class PlatformInfo
{
private const string _net45TypeName = "System.IWellKnownStringEqualityComparer, mscorlib, Version=4.0.0.0, PublicKeyToken=b77a5c561934e089";
private static Lazy<Platform> _platform = new Lazy<Platform>(GetPlatform, isThreadSafe: true);
/// <summary>
/// Gets the platform that the unit test is currently running on.
/// </summary>
public static Platform Platform
{
get { return _platform.Value; }
}
private static Platform GetPlatform()
{
if (Type.GetType(_net45TypeName, throwOnError: false) != null)
{
return Platform.Net45;
}
return Platform.Net40;
}
}
}

View File

@ -1,16 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.TestCommon
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class PropertyDataAttribute : Xunit.Extensions.PropertyDataAttribute
{
public PropertyDataAttribute(string propertyName)
: base(propertyName)
{
}
}
}

View File

@ -1,56 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Globalization;
using System.Reflection;
using System.Threading;
namespace Microsoft.TestCommon
{
/// <summary>
/// Replaces the current culture and UI culture for the test.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class ReplaceCultureAttribute : Xunit.BeforeAfterTestAttribute
{
private CultureInfo _originalCulture;
private CultureInfo _originalUICulture;
public ReplaceCultureAttribute()
{
Culture = CultureReplacer.DefaultCultureName;
UICulture = CultureReplacer.DefaultUICultureName;
}
/// <summary>
/// Sets <see cref="Thread.CurrentCulture"/> for the test. Defaults to en-GB.
/// </summary>
/// <remarks>
/// en-GB is used here as the default because en-US is equivalent to the InvariantCulture. We
/// want to be able to find bugs where we're accidentally relying on the Invariant instead of the
/// user's culture.
/// </remarks>
public string Culture { get; set; }
/// <summary>
/// Sets <see cref="Thread.CurrentUICulture"/> for the test. Defaults to en-US.
/// </summary>
public string UICulture { get; set; }
public override void Before(MethodInfo methodUnderTest)
{
_originalCulture = Thread.CurrentThread.CurrentCulture;
_originalUICulture = Thread.CurrentThread.CurrentUICulture;
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(Culture);
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(UICulture);
}
public override void After(MethodInfo methodUnderTest)
{
Thread.CurrentThread.CurrentCulture = _originalCulture;
Thread.CurrentThread.CurrentUICulture = _originalUICulture;
}
}
}

View File

@ -1,58 +0,0 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Xunit.Sdk;
namespace Microsoft.TestCommon
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class TheoryAttribute : Xunit.Extensions.TheoryAttribute
{
public TheoryAttribute()
{
Timeout = Debugger.IsAttached ? Int32.MaxValue : TimeoutConstant.DefaultTimeout;
Platforms = Platform.All;
PlatformJustification = "Unsupported platform (test runs on {0}, current platform is {1})";
}
/// <summary>
/// Gets the platform that the unit test is currently running on.
/// </summary>
protected Platform Platform
{
get { return PlatformInfo.Platform; }
}
/// <summary>
/// Gets or set the platforms that the unit test is compatible with. Defaults to
/// <see cref="Platform.All"/>.
/// </summary>
public Platform Platforms { get; set; }
/// <summary>
/// Gets or sets the platform skipping justification. This message can receive
/// the supported platforms as {0}, and the current platform as {1}.
/// </summary>
public string PlatformJustification { get; set; }
/// <inheritdoc/>
protected override IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo method)
{
if ((Platforms & Platform) == 0)
{
return new[] {
new SkipCommand(
method,
DisplayName,
String.Format(PlatformJustification, Platforms.ToString().Replace(", ", " | "), Platform)
)
};
}
return base.EnumerateTestCommands(method);
}
}
}

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="1.9.1" targetFramework="net45" />
<package id="xunit.extensions" version="1.9.1" targetFramework="net45" />
</packages>