diff --git a/global.json b/global.json new file mode 100644 index 0000000000..840c36f6ad --- /dev/null +++ b/global.json @@ -0,0 +1,3 @@ +{ + "sources": ["src"] +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/CSharpRazorCodeLanguageTest.cs b/test/Microsoft.AspNet.Razor.Test/CSharpRazorCodeLanguageTest.cs index 4dd8f72859..b3d5d0732d 100644 --- a/test/Microsoft.AspNet.Razor.Test/CSharpRazorCodeLanguageTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/CSharpRazorCodeLanguageTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Editor/RazorEditorParserTest.cs b/test/Microsoft.AspNet.Razor.Test/Editor/RazorEditorParserTest.cs index 89539e487a..ec7d669e00 100644 --- a/test/Microsoft.AspNet.Razor.Test/Editor/RazorEditorParserTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Editor/RazorEditorParserTest.cs @@ -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("host", () => new RazorEditorParser(null, TestLinePragmaFileName)); } [Fact] public void ConstructorRequiresNonNullPhysicalPath() { - Assert.ThrowsArgumentNullOrEmptyString(() => new RazorEditorParser(CreateHost(), null), - "sourceFileName"); + Assert.Throws("sourceFileName", () => new RazorEditorParser(CreateHost(), null)); } [Fact] public void ConstructorRequiresNonEmptyPhysicalPath() { - Assert.ThrowsArgumentNullOrEmptyString(() => new RazorEditorParser(CreateHost(), String.Empty), - "sourceFileName"); + Assert.Throws("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( + 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() diff --git a/test/Microsoft.AspNet.Razor.Test/Framework/ParserTestBase.cs b/test/Microsoft.AspNet.Razor.Test/Framework/ParserTestBase.cs index f3fb71b22f..1e667c08fc 100644 --- a/test/Microsoft.AspNet.Razor.Test/Framework/ParserTestBase.cs +++ b/test/Microsoft.AspNet.Razor.Test/Framework/ParserTestBase.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs index 286c00fb68..c8f09d38bc 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CSharpRazorCodeGeneratorTest.cs @@ -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("className", () => new CSharpRazorCodeGenerator(null, TestRootNamespaceName, TestPhysicalPath, CreateHost())); } [Fact] public void ConstructorRequiresNonEmptyClassName() { - Assert.ThrowsArgumentNullOrEmptyString(() => new CSharpRazorCodeGenerator(String.Empty, TestRootNamespaceName, TestPhysicalPath, CreateHost()), "className"); + Assert.Throws("className", () => new CSharpRazorCodeGenerator(string.Empty, TestRootNamespaceName, TestPhysicalPath, CreateHost())); } [Fact] public void ConstructorRequiresNonNullRootNamespaceName() { - Assert.ThrowsArgumentNull(() => new CSharpRazorCodeGenerator("Foo", null, TestPhysicalPath, CreateHost()), "rootNamespaceName"); + Assert.Throws("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("host", () => new CSharpRazorCodeGenerator("Foo", TestRootNamespaceName, TestPhysicalPath, null)); } [Theory] diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpCodeBuilderTests.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpCodeBuilderTests.cs index f35df6e18b..0ae5657f3d 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpCodeBuilderTests.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpCodeBuilderTests.cs @@ -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); diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpPaddingBuilderTests.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpPaddingBuilderTests.cs index 9b4932c238..80a4080a41 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpPaddingBuilderTests.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CSharpPaddingBuilderTests.cs @@ -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 diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/ChunkVisitorTests.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/ChunkVisitorTests.cs index 7977cc0ed1..b387b4e443 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/ChunkVisitorTests.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/ChunkVisitorTests.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CodeTreeGenerationTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CodeTreeGenerationTest.cs index 64ff53d140..b59f836ecc 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CodeTreeGenerationTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/CodeTree/CodeTreeGenerationTest.cs @@ -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); } } diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/LineMappingTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/LineMappingTest.cs index 6fd1f0cc8e..a2f86c5a86 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/LineMappingTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/LineMappingTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Generator/RazorCodeGeneratorTest.cs b/test/Microsoft.AspNet.Razor.Test/Generator/RazorCodeGeneratorTest.cs index 592f847fc2..95e62108a2 100644 --- a/test/Microsoft.AspNet.Razor.Test/Generator/RazorCodeGeneratorTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Generator/RazorCodeGeneratorTest.cs @@ -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(); diff --git a/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.csproj b/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.csproj deleted file mode 100644 index aae5f95a05..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.csproj +++ /dev/null @@ -1,328 +0,0 @@ - - - - {0BB62A1D-E6B5-49FA-9E3C-6AF679A66DFE} - Library - Properties - Microsoft.AspNet.Razor.Test - Microsoft.AspNet.Razor.Test - ..\..\bin\$(Configuration)\Test\ - 0618 - v4.5.1 - - - - false - - - - - - - False - ..\..\packages\Moq.4.0.10827\lib\NET40\Moq.dll - - - - 3.5 - - - False - ..\..\packages\xunit.1.9.1\lib\net20\xunit.dll - unused - - - False - ..\..\packages\xunit.extensions.1.9.1\lib\net20\xunit.extensions.dll - unused - - - - - {8b129ff9-0b8f-4e0c-8dfc-0137d8550fb7} - Microsoft.AspNet.Razor.net45 - - - {FCCC4CB7-BAF7-4A57-9F89-E5766FE536C0} - Microsoft.TestCommon - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.kproj b/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.kproj new file mode 100644 index 0000000000..ac910cbb96 --- /dev/null +++ b/test/Microsoft.AspNet.Razor.Test/Microsoft.AspNet.Razor.Test.kproj @@ -0,0 +1,215 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + Debug + AnyCPU + + + + 87c7338b-0c06-4c7b-be75-a2368ae26797 + Library + net45 + + + ConsoleDebugger + + + WebDebugger + + + + + 2.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/BlockTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/BlockTest.cs index fdd0a8c98d..f203a33b43 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/BlockTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/BlockTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpAutoCompleteTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpAutoCompleteTest.cs index 11fc9795d8..78bb1a7c18 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpAutoCompleteTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpAutoCompleteTest.cs @@ -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

Foo

"))), - 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)); } } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpBlockTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpBlockTest.cs index edafb9c545..5b6a758520 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpBlockTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpBlockTest.cs @@ -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(() => parser.ParseBlock(), RazorResources.Parser_Context_Not_Set); + var exception = Assert.Throws(() => 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] diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpDirectivesTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpDirectivesTest.cs index 5066387d7a..1105b95117 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpDirectivesTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpDirectivesTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpErrorTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpErrorTest.cs index 89bb0df2eb..e6ed563061 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpErrorTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpErrorTest.cs @@ -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)

Bar

else if(bar)

Baz

else

Boz

", 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)); } } } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpExplicitExpressionTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpExplicitExpressionTest.cs index c60aa93fcb..e4510ad36b 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpExplicitExpressionTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpExplicitExpressionTest.cs @@ -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))); } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpHelperTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpHelperTest.cs index 23ba6ce2ad..c7d28e9b20 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpHelperTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpHelperTest.cs @@ -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("

Foo

").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)) }); } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpImplicitExpressionTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpImplicitExpressionTest.cs index 5ca937ecc6..326d0a458d 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpImplicitExpressionTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpImplicitExpressionTest.cs @@ -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] diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpLayoutDirectiveTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpLayoutDirectiveTest.cs index adfd1da329..77c718d4c8 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpLayoutDirectiveTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpLayoutDirectiveTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpNestedStatementsTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpNestedStatementsTest.cs index d04cee4e2d..fe8bcd3bca 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpNestedStatementsTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpNestedStatementsTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpRazorCommentsTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpRazorCommentsTest.cs index ceba536e8c..20e4568a68 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpRazorCommentsTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpRazorCommentsTest.cs @@ -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)); } } } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpReservedWordsTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpReservedWordsTest.cs index e0c6794e41..301837b2a1 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpReservedWordsTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpReservedWordsTest.cs @@ -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] diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpSectionTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpSectionTest.cs index fd713a5fb0..524041cee3 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpSectionTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpSectionTest.cs @@ -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 {

Foo

}", new MarkupBlock( Factory.EmptyHtml(), - new SectionBlock(new SectionCodeGenerator(String.Empty), + new SectionBlock(new SectionCodeGenerator(string.Empty), Factory.CodeTransition(), Factory.MetaCode("section ")), Factory.Markup("9 {

Foo

}")), 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("

Foo", "{", "}", "

")))), new RazorError( - RazorResources.ParseError_Expected_X("}"), + RazorResources.FormatParseError_Expected_X("}"), 27, 0, 27)); } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpSpecialBlockTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpSpecialBlockTest.cs index 23e173e306..b9a387a9e1 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpSpecialBlockTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpSpecialBlockTest.cs @@ -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)); } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpStatementTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpStatementTest.cs index cf0fd70e0b..09fc5b020f 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpStatementTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpStatementTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpTemplateTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpTemplateTest.cs index 7b79044b1a..fa44cfb6e3 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpTemplateTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpTemplateTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpToMarkupSwitchTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpToMarkupSwitchTest.cs index b5d5328646..512742b585 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpToMarkupSwitchTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpToMarkupSwitchTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpVerbatimBlockTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpVerbatimBlockTest.cs index 73aed5f96d..dd5fdded25 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpVerbatimBlockTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpVerbatimBlockTest.cs @@ -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)) }); } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpWhitespaceHandlingTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpWhitespaceHandlingTest.cs index 77eccf49b7..813ea0f799 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpWhitespaceHandlingTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CSharp/CSharpWhitespaceHandlingTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/CallbackParserListenerTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/CallbackParserListenerTest.cs index 86bc3302a0..9d3d1a8fe7 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/CallbackParserListenerTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/CallbackParserListenerTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlAttributeTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlAttributeTest.cs index 0a1ec5317a..fcc0dfe0a4 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlAttributeTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlAttributeTest.cs @@ -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("(" href='", 2, 0, 2), suffix: new LocationTagged("'", 12, 0, 12)), Factory.Markup(" href='").With(SpanCodeGenerator.Null), - Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged(String.Empty, 9, 0, 9), value: new LocationTagged("Foo", 9, 0, 9))), + Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged(string.Empty, 9, 0, 9), value: new LocationTagged("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("(" href='", 2, 0, 2), suffix: new LocationTagged("'", 20, 0, 20)), Factory.Markup(" href='").With(SpanCodeGenerator.Null), - Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged(String.Empty, 9, 0, 9), value: new LocationTagged("Foo", 9, 0, 9))), + Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged(string.Empty, 9, 0, 9), value: new LocationTagged("Foo", 9, 0, 9))), Factory.Markup(" Bar").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged(" ", 12, 0, 12), value: new LocationTagged("Bar", 13, 0, 13))), Factory.Markup(" Baz").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged(" ", 16, 0, 16), value: new LocationTagged("Baz", 17, 0, 17))), Factory.Markup("'").With(SpanCodeGenerator.Null)), @@ -50,7 +50,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html Factory.Markup("(" href=\"", 2, 0, 2), suffix: new LocationTagged("\"", 20, 0, 20)), Factory.Markup(" href=\"").With(SpanCodeGenerator.Null), - Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged(String.Empty, 9, 0, 9), value: new LocationTagged("Foo", 9, 0, 9))), + Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged(string.Empty, 9, 0, 9), value: new LocationTagged("Foo", 9, 0, 9))), Factory.Markup(" Bar").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged(" ", 12, 0, 12), value: new LocationTagged("Bar", 13, 0, 13))), Factory.Markup(" Baz").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged(" ", 16, 0, 16), value: new LocationTagged("Baz", 17, 0, 17))), Factory.Markup("\"").With(SpanCodeGenerator.Null)), @@ -63,9 +63,9 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html ParseBlockTest("", new MarkupBlock( Factory.Markup("(" href=", 2, 0, 2), suffix: new LocationTagged(String.Empty, 11, 0, 11)), + new MarkupBlock(new AttributeBlockCodeGenerator(name: "href", prefix: new LocationTagged(" href=", 2, 0, 2), suffix: new LocationTagged(string.Empty, 11, 0, 11)), Factory.Markup(" href=").With(SpanCodeGenerator.Null), - Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged(String.Empty, 8, 0, 8), value: new LocationTagged("Foo", 8, 0, 8)))), + Factory.Markup("Foo").With(new LiteralAttributeCodeGenerator(prefix: new LocationTagged(string.Empty, 8, 0, 8), value: new LocationTagged("Foo", 8, 0, 8)))), Factory.Markup(" Bar Baz />").Accepts(AcceptedCharacters.None))); } @@ -77,7 +77,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html Factory.Markup("(" href='", 2, 0, 2), suffix: new LocationTagged("'", 13, 0, 13)), Factory.Markup(" href='").With(SpanCodeGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged(String.Empty, 9, 0, 9), 9, 0, 9), + new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged(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("(" href='", 2, 0, 2), suffix: new LocationTagged("'", 22, 0, 22)), Factory.Markup(" href='").With(SpanCodeGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged(String.Empty, 9, 0, 9), 9, 0, 9), + new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged(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("(" href='", 2, 0, 2), suffix: new LocationTagged("'", 23, 0, 23)), Factory.Markup(" href='").With(SpanCodeGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged(String.Empty, 9, 0, 9), 9, 0, 9), + new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged(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("", new MarkupBlock( Factory.Markup("(" value=", 6, 0, 6), suffix: new LocationTagged(String.Empty, 17, 0, 17)), + new MarkupBlock(new AttributeBlockCodeGenerator(name: "value", prefix: new LocationTagged(" value=", 6, 0, 6), suffix: new LocationTagged(string.Empty, 17, 0, 17)), Factory.Markup(" value=").With(SpanCodeGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged(String.Empty, 13, 0, 13), 13, 0, 13), + new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged(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("", new MarkupBlock( Factory.Markup("(" value=", 6, 0, 6), suffix: new LocationTagged(String.Empty, 17, 0, 17)), + new MarkupBlock(new AttributeBlockCodeGenerator(name: "value", prefix: new LocationTagged(" value=", 6, 0, 6), suffix: new LocationTagged(string.Empty, 17, 0, 17)), Factory.Markup(" value=").With(SpanCodeGenerator.Null), - new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged(String.Empty, 13, 0, 13), 13, 0, 13), + new MarkupBlock(new DynamicAttributeBlockCodeGenerator(new LocationTagged(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.Empty, 9, 0, 9), + new LocationTagged(string.Empty, 9, 0, 9), new LocationTagged(new ResolveUrlCodeGenerator(), 9, 0, 9))), Factory.Markup("'").With(SpanCodeGenerator.Null)), Factory.Markup(" />"))); diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlBlockTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlBlockTest.cs index 9e599eebb6..f8987b1198 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlBlockTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlBlockTest.cs @@ -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(() => parser.ParseBlock(), RazorResources.Parser_Context_Not_Set); + var exception = Assert.Throws(() => 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("", "", 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("
(() => parser.ParseDocument(), RazorResources.Parser_Context_Not_Set); + var exception = Assert.Throws(() => 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(() => parser.ParseSection(null, true), RazorResources.Parser_Context_Not_Set); + var exception = Assert.Throws(() => parser.ParseSection(null, true)); + Assert.Equal(RazorResources.Parser_Context_Not_Set, exception.Message); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlErrorTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlErrorTest.cs index 82f4e1f680..710fc953d8 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlErrorTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlErrorTest.cs @@ -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("
bar baz", new MarkupBlock( Factory.Markup("
").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("

", new MarkupBlock( Factory.Markup("

").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("blah blah blah blah blah", new MarkupBlock( Factory.Markup("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("(" bar=", 4, 0, 4), new LocationTagged(String.Empty, 12, 0, 12)), Factory.Markup(" bar=").With(SpanCodeGenerator.Null), - Factory.Markup("baz").With(new LiteralAttributeCodeGenerator(new LocationTagged(String.Empty, 9, 0, 9), new LocationTagged("baz", 9, 0, 9))))), - new RazorError(RazorResources.ParseError_UnfinishedTag("foo"), new SourceLocation(0, 0, 0))); + Factory.Markup("baz").With(new LiteralAttributeCodeGenerator(new LocationTagged(string.Empty, 9, 0, 9), new LocationTagged("baz", 9, 0, 9))))), + new RazorError(RazorResources.FormatParseError_UnfinishedTag("foo"), new SourceLocation(0, 0, 0))); } } } diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlTagsTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlTagsTest.cs index 52be0a68ff..ef028c3982 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlTagsTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/Html/HtmlTagsTest.cs @@ -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("

Bar", new MarkupBlock( Factory.Markup("

").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 + ">foo", @@ -130,7 +129,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser.Html } [Theory] - [PropertyData("VoidElementNames")] + [MemberData("VoidElementNames")] public void VoidElementFollowedByCloseTag(string tagName) { ParseBlockTest("<" + 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 + "> new ParserContext(null, codeParser, new HtmlMarkupParser(), codeParser), "source"); + Assert.Throws("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("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("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("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(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] diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/ParserVisitorExtensionsTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/ParserVisitorExtensionsTest.cs index 0760e6a88e..bbeef3d556 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/ParserVisitorExtensionsTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/ParserVisitorExtensionsTest.cs @@ -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()); - Assert.ThrowsArgumentNull(() => target.Visit(results), "self"); + Assert.Throws("self", () => target.Visit(results)); } [Fact] public void VisitThrowsOnNullResults() { ParserVisitor target = new Mock().Object; - Assert.ThrowsArgumentNull(() => target.Visit(null), "result"); + Assert.Throws("result", () => target.Visit(null)); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/PartialParsing/CSharpPartialParsingTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/PartialParsing/CSharpPartialParsingTest.cs index 22c300eb5a..64d8696254 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/PartialParsing/CSharpPartialParsingTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/PartialParsing/CSharpPartialParsingTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/PartialParsing/PartialParsingTestBase.cs b/test/Microsoft.AspNet.Razor.Test/Parser/PartialParsing/PartialParsingTestBase.cs index c83a1aab3d..e584e4d94d 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/PartialParsing/PartialParsingTestBase.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/PartialParsing/PartialParsingTestBase.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/RazorParserTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/RazorParserTest.cs index 75744842a1..61c027c41b 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/RazorParserTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/RazorParserTest.cs @@ -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("codeParser", () => new RazorParser(null, new HtmlMarkupParser())); } [Fact] public void ConstructorRequiresNonNullMarkupParser() { - Assert.ThrowsArgumentNull(() => new RazorParser(new CSharpCodeParser(), null), "markupParser"); + Assert.Throws("markupParser", () => new RazorParser(new CSharpCodeParser(), null)); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/Parser/WhitespaceRewriterTest.cs b/test/Microsoft.AspNet.Razor.Test/Parser/WhitespaceRewriterTest.cs index 71871d6cac..b068775a0c 100644 --- a/test/Microsoft.AspNet.Razor.Test/Parser/WhitespaceRewriterTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Parser/WhitespaceRewriterTest.cs @@ -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("markupSpanFactory", () => new WhiteSpaceRewriter(null)); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/Project.json b/test/Microsoft.AspNet.Razor.Test/Project.json new file mode 100644 index 0000000000..2074a38218 --- /dev/null +++ b/test/Microsoft.AspNet.Razor.Test/Project.json @@ -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": { } + } +} diff --git a/test/Microsoft.AspNet.Razor.Test/RazorCodeLanguageTest.cs b/test/Microsoft.AspNet.Razor.Test/RazorCodeLanguageTest.cs index 7976f9311e..23b80a5312 100644 --- a/test/Microsoft.AspNet.Razor.Test/RazorCodeLanguageTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/RazorCodeLanguageTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/RazorDirectiveAttributeTest.cs b/test/Microsoft.AspNet.Razor.Test/RazorDirectiveAttributeTest.cs index 54462778df..fbec15ccb4 100644 --- a/test/Microsoft.AspNet.Razor.Test/RazorDirectiveAttributeTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/RazorDirectiveAttributeTest.cs @@ -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("name", () => new RazorDirectiveAttribute(name: null, value: "blah")); + Assert.Throws("name", () => new RazorDirectiveAttribute(name: "", value: "blah")); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/RazorEngineHostTest.cs b/test/Microsoft.AspNet.Razor.Test/RazorEngineHostTest.cs index 4316733d47..6706004471 100644 --- a/test/Microsoft.AspNet.Razor.Test/RazorEngineHostTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/RazorEngineHostTest.cs @@ -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("codeLanguage", () => new RazorEngineHost(null)); + Assert.Throws("codeLanguage", () => new RazorEngineHost(null, () => new HtmlMarkupParser())); } [Fact] public void ConstructorRequiresNonNullMarkupParser() { - Assert.ThrowsArgumentNull(() => new RazorEngineHost(new CSharpRazorCodeLanguage(), null), "markupParserFactory"); + Assert.Throws("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("incomingCodeParser", () => CreateHost().DecorateCodeParser(null)); } [Fact] public void DecorateMarkupParserRequiresNonNullMarkupParser() { - Assert.ThrowsArgumentNull(() => CreateHost().DecorateMarkupParser(null), "incomingMarkupParser"); + Assert.Throws("incomingMarkupParser", () => CreateHost().DecorateMarkupParser(null)); } [Fact] public void DecorateCodeGeneratorRequiresNonNullCodeGenerator() { - Assert.ThrowsArgumentNull(() => CreateHost().DecorateCodeGenerator(null), "incomingCodeGenerator"); + Assert.Throws("incomingCodeGenerator", () => CreateHost().DecorateCodeGenerator(null)); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/RazorTemplateEngineTest.cs b/test/Microsoft.AspNet.Razor.Test/RazorTemplateEngineTest.cs index f74f7fe6cc..b739d171d5 100644 --- a/test/Microsoft.AspNet.Razor.Test/RazorTemplateEngineTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/RazorTemplateEngineTest.cs @@ -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("host", () => new RazorTemplateEngine(null)); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/Text/BufferingTextReaderTest.cs b/test/Microsoft.AspNet.Razor.Test/Text/BufferingTextReaderTest.cs index e9526126ba..50c84175f3 100644 --- a/test/Microsoft.AspNet.Razor.Test/Text/BufferingTextReaderTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Text/BufferingTextReaderTest.cs @@ -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("source", () => new BufferingTextReader(null)); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/Text/LineTrackingStringBufferTest.cs b/test/Microsoft.AspNet.Razor.Test/Text/LineTrackingStringBufferTest.cs index f54441899d..b1b263c037 100644 --- a/test/Microsoft.AspNet.Razor.Test/Text/LineTrackingStringBufferTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Text/LineTrackingStringBufferTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Text/LookaheadTextReaderTestBase.cs b/test/Microsoft.AspNet.Razor.Test/Text/LookaheadTextReaderTestBase.cs index 9ff85535e0..0d31e0589a 100644 --- a/test/Microsoft.AspNet.Razor.Test/Text/LookaheadTextReaderTestBase.cs +++ b/test/Microsoft.AspNet.Razor.Test/Text/LookaheadTextReaderTestBase.cs @@ -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(() => reader.CancelBacktrack(), RazorResources.CancelBacktrack_Must_Be_Called_Within_Lookahead); + var exception = Assert.Throws(() => reader.CancelBacktrack()); + Assert.Equal(RazorResources.CancelBacktrack_Must_Be_Called_Within_Lookahead, exception.Message); } protected Action CaptureSourceLocation(Action capture) diff --git a/test/Microsoft.AspNet.Razor.Test/Text/SourceLocationTest.cs b/test/Microsoft.AspNet.Razor.Test/Text/SourceLocationTest.cs index 968b807281..b7b6455b26 100644 --- a/test/Microsoft.AspNet.Razor.Test/Text/SourceLocationTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Text/SourceLocationTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Text/SourceLocationTrackerTest.cs b/test/Microsoft.AspNet.Razor.Test/Text/SourceLocationTrackerTest.cs index 20d25f91ef..5a797f1867 100644 --- a/test/Microsoft.AspNet.Razor.Test/Text/SourceLocationTrackerTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Text/SourceLocationTrackerTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Text/TextBufferReaderTest.cs b/test/Microsoft.AspNet.Razor.Test/Text/TextBufferReaderTest.cs index 73a679b7ef..fa7b18ab0a 100644 --- a/test/Microsoft.AspNet.Razor.Test/Text/TextBufferReaderTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Text/TextBufferReaderTest.cs @@ -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("buffer", () => new TextBufferReader(null)); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/Text/TextChangeTest.cs b/test/Microsoft.AspNet.Razor.Test/Text/TextChangeTest.cs index 82e49ad89f..a364037dae 100644 --- a/test/Microsoft.AspNet.Razor.Test/Text/TextChangeTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Text/TextChangeTest.cs @@ -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().Object, 0, 0, new Mock().Object), "oldPosition", "Value must be greater than or equal to 0."); + var parameterName = "oldPosition"; + var exception = Assert.Throws(parameterName, () => new TextChange(-1, 0, new Mock().Object, 0, 0, new Mock().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().Object, -1, 0, new Mock().Object), "newPosition", "Value must be greater than or equal to 0."); + var parameterName = "newPosition"; + var exception = Assert.Throws(parameterName, () => new TextChange(0, 0, new Mock().Object, -1, 0, new Mock().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().Object, 0, 0, new Mock().Object), "oldLength", "Value must be greater than or equal to 0."); + var parameterName = "oldLength"; + var exception = Assert.Throws(parameterName, () => new TextChange(0, -1, new Mock().Object, 0, 0, new Mock().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().Object, 0, -1, new Mock().Object), "newLength", "Value must be greater than or equal to 0."); + var parameterName = "newLength"; + var exception = Assert.Throws(parameterName, () => new TextChange(0, 0, new Mock().Object, 0, -1, new Mock().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().Object), "oldBuffer"); + Assert.Throws("oldBuffer", () => new TextChange(0, 0, null, 0, 0, new Mock().Object)); } [Fact] public void ConstructorRequiresNonNullNewBuffer() { - Assert.ThrowsArgumentNull(() => new TextChange(0, 0, new Mock().Object, 0, 0, null), "newBuffer"); + Assert.Throws("newBuffer", () => new TextChange(0, 0, new Mock().Object, 0, 0, null)); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/Text/TextReaderExtensionsTest.cs b/test/Microsoft.AspNet.Razor.Test/Text/TextReaderExtensionsTest.cs index b99212ed12..9f52f51d0d 100644 --- a/test/Microsoft.AspNet.Razor.Test/Text/TextReaderExtensionsTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Text/TextReaderExtensionsTest.cs @@ -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("reader", () => TextReaderExtensions.ReadUntil(null, '@')); } [Fact] public void ReadUntilInclusiveWithCharThrowsArgNullIfReaderNull() { - Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(null, '@', inclusive: true), "reader"); + Assert.Throws("reader", () => TextReaderExtensions.ReadUntil(null, '@', inclusive: true)); } [Fact] public void ReadUntilWithMultipleTerminatorsThrowsArgNullIfReaderNull() { - Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(null, '/', '>'), "reader"); + Assert.Throws("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("reader", () => TextReaderExtensions.ReadUntil(null, /* inclusive */ true, '/', '>')); } [Fact] public void ReadUntilWithPredicateThrowsArgNullIfReaderNull() { - Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(null, c => true), "reader"); + Assert.Throws("reader", () => TextReaderExtensions.ReadUntil(null, c => true)); } [Fact] public void ReadUntilInclusiveWithPredicateThrowsArgNullIfReaderNull() { - Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(null, c => true, inclusive: true), "reader"); + Assert.Throws("reader", () => TextReaderExtensions.ReadUntil(null, c => true, inclusive: true)); } [Fact] public void ReadUntilWithPredicateThrowsArgExceptionIfPredicateNull() { - Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(new StringReader("Foo"), (Predicate)null), "condition"); + Assert.Throws("condition", () => TextReaderExtensions.ReadUntil(new StringReader("Foo"), (Predicate)null)); } [Fact] public void ReadUntilInclusiveWithPredicateThrowsArgExceptionIfPredicateNull() { - Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadUntil(new StringReader("Foo"), (Predicate)null, inclusive: true), "condition"); + Assert.Throws("condition", () => TextReaderExtensions.ReadUntil(new StringReader("Foo"), (Predicate)null, inclusive: true)); } [Fact] public void ReadWhileWithPredicateThrowsArgNullIfReaderNull() { - Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadWhile(null, c => true), "reader"); + Assert.Throws("reader", () => TextReaderExtensions.ReadWhile(null, c => true)); } [Fact] public void ReadWhileInclusiveWithPredicateThrowsArgNullIfReaderNull() { - Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadWhile(null, c => true, inclusive: true), "reader"); + Assert.Throws("reader", () => TextReaderExtensions.ReadWhile(null, c => true, inclusive: true)); } [Fact] public void ReadWhileWithPredicateThrowsArgNullIfPredicateNull() { - Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadWhile(new StringReader("Foo"), (Predicate)null), "condition"); + Assert.Throws("condition", () => TextReaderExtensions.ReadWhile(new StringReader("Foo"), (Predicate)null)); } [Fact] public void ReadWhileInclusiveWithPredicateThrowsArgNullIfPredicateNull() { - Assert.ThrowsArgumentNull(() => TextReaderExtensions.ReadWhile(new StringReader("Foo"), (Predicate)null, inclusive: true), "condition"); + Assert.Throws("condition", () => TextReaderExtensions.ReadWhile(new StringReader("Foo"), (Predicate)null, inclusive: true)); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerCommentTest.cs b/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerCommentTest.cs index 6904f71a74..437eec33e5 100644 --- a/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerCommentTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerCommentTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerIdentifierTest.cs b/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerIdentifierTest.cs index f80c9a6efc..cd9db168cc 100644 --- a/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerIdentifierTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerIdentifierTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerLiteralTest.cs b/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerLiteralTest.cs index 022a708165..567dd282ac 100644 --- a/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerLiteralTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerLiteralTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerOperatorsTest.cs b/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerOperatorsTest.cs index cfe46837ee..d44f2584a2 100644 --- a/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerOperatorsTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerOperatorsTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerTest.cs b/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerTest.cs index 187ae1dc9f..7cb2e8668d 100644 --- a/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Tokenizer/CSharpTokenizerTest.cs @@ -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("source", () => new CSharpTokenizer(null)); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/Tokenizer/HtmlTokenizerTest.cs b/test/Microsoft.AspNet.Razor.Test/Tokenizer/HtmlTokenizerTest.cs index c3d5f4dfb6..a9f31053d2 100644 --- a/test/Microsoft.AspNet.Razor.Test/Tokenizer/HtmlTokenizerTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Tokenizer/HtmlTokenizerTest.cs @@ -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("source", () => new HtmlTokenizer(null)); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/Tokenizer/TokenizerLookaheadTest.cs b/test/Microsoft.AspNet.Razor.Test/Tokenizer/TokenizerLookaheadTest.cs index a007dc35bc..3922f8fed7 100644 --- a/test/Microsoft.AspNet.Razor.Test/Tokenizer/TokenizerLookaheadTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Tokenizer/TokenizerLookaheadTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Tokenizer/TokenizerTestBase.cs b/test/Microsoft.AspNet.Razor.Test/Tokenizer/TokenizerTestBase.cs index e329d140af..c53feaecec 100644 --- a/test/Microsoft.AspNet.Razor.Test/Tokenizer/TokenizerTestBase.cs +++ b/test/Microsoft.AspNet.Razor.Test/Tokenizer/TokenizerTestBase.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Razor.Test/Utils/DisposableActionTest.cs b/test/Microsoft.AspNet.Razor.Test/Utils/DisposableActionTest.cs index 69ad885ae7..43337f197e 100644 --- a/test/Microsoft.AspNet.Razor.Test/Utils/DisposableActionTest.cs +++ b/test/Microsoft.AspNet.Razor.Test/Utils/DisposableActionTest.cs @@ -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("action", () => new DisposableAction(null)); } [Fact] diff --git a/test/Microsoft.AspNet.Razor.Test/Utils/ExceptionHelpers.cs b/test/Microsoft.AspNet.Razor.Test/Utils/ExceptionHelpers.cs new file mode 100644 index 0000000000..06cb509641 --- /dev/null +++ b/test/Microsoft.AspNet.Razor.Test/Utils/ExceptionHelpers.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Razor.Test/Utils/MiscUtils.cs b/test/Microsoft.AspNet.Razor.Test/Utils/MiscUtils.cs index 2fd73d7cd1..435025c49c 100644 --- a/test/Microsoft.AspNet.Razor.Test/Utils/MiscUtils.cs +++ b/test/Microsoft.AspNet.Razor.Test/Utils/MiscUtils.cs @@ -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 { diff --git a/test/Microsoft.TestCommon/TestFile.cs b/test/Microsoft.AspNet.Razor.Test/Utils/TestFile.cs similarity index 84% rename from test/Microsoft.TestCommon/TestFile.cs rename to test/Microsoft.AspNet.Razor.Test/Utils/TestFile.cs index ca421002b7..d6cc3de48d 100644 --- a/test/Microsoft.TestCommon/TestFile.cs +++ b/test/Microsoft.AspNet.Razor.Test/Utils/TestFile.cs @@ -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; } diff --git a/test/Microsoft.AspNet.Razor.Test/packages.config b/test/Microsoft.AspNet.Razor.Test/packages.config deleted file mode 100644 index b19e59458c..0000000000 --- a/test/Microsoft.AspNet.Razor.Test/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/test/Microsoft.TestCommon/Assert.cs b/test/Microsoft.TestCommon/Assert.cs deleted file mode 100644 index b54d3c8593..0000000000 --- a/test/Microsoft.TestCommon/Assert.cs +++ /dev/null @@ -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 - { - } -} diff --git a/test/Microsoft.TestCommon/CultureReplacer.cs b/test/Microsoft.TestCommon/CultureReplacer.cs deleted file mode 100644 index e52d2e7c6e..0000000000 --- a/test/Microsoft.TestCommon/CultureReplacer.cs +++ /dev/null @@ -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); - } - - ///

- /// The name of the culture that is used as the default value for Thread.CurrentCulture when CultureReplacer is used. - /// - public static string DefaultCultureName - { - get { return _defaultCultureName; } - } - - /// - /// The name of the culture that is used as the default value for Thread.UICurrentCulture when CultureReplacer is used. - /// - public static string DefaultUICultureName - { - get { return _defaultUICultureName; } - } - - /// - /// The culture that is used as the default value for Thread.CurrentCulture when CultureReplacer is used. - /// - 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; - } - } - } -} diff --git a/test/Microsoft.TestCommon/DataAttribute.cs b/test/Microsoft.TestCommon/DataAttribute.cs deleted file mode 100644 index affc368d0d..0000000000 --- a/test/Microsoft.TestCommon/DataAttribute.cs +++ /dev/null @@ -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 - { - } -} diff --git a/test/Microsoft.TestCommon/ExceptionAssertions.cs b/test/Microsoft.TestCommon/ExceptionAssertions.cs deleted file mode 100644 index 3aa3f7227f..0000000000 --- a/test/Microsoft.TestCommon/ExceptionAssertions.cs +++ /dev/null @@ -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 - { - /// - /// Verifies that the exact exception is thrown (and not a derived exception type). - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static T Throws(Action testCode) - where T : Exception - { - return (T)Throws(typeof(T), testCode); - } - - /// - /// Verifies that the exact exception is thrown (and not a derived exception type). - /// Generally used to test property accessors. - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static T Throws(Func testCode) - where T : Exception - { - return (T)Throws(typeof(T), testCode); - } - - /// - /// Verifies that the exact exception is thrown (and not a derived exception type). - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static Exception Throws(Type exceptionType, Action testCode) - { - Exception exception = RecordException(testCode); - return VerifyException(exceptionType, exception); - } - - /// - /// Verifies that the exact exception is thrown (and not a derived exception type). - /// Generally used to test property accessors. - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static Exception Throws(Type exceptionType, Func testCode) - { - return Throws(exceptionType, () => { testCode(); }); - } - - /// - /// Verifies that an exception of the given type (or optionally a derived type) is thrown. - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// Pass true to allow exceptions which derive from TException; pass false, otherwise - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static TException Throws(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; - } - - /// - /// Verifies that an exception of the given type (or optionally a derived type) is thrown. - /// Generally used to test property accessors. - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// Pass true to allow exceptions which derive from TException; pass false, otherwise - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static TException Throws(Func testCode, bool allowDerivedExceptions) - where TException : Exception - { - return Throws(() => { testCode(); }, allowDerivedExceptions); - } - - /// - /// Verifies that an exception of the given type (or optionally a derived type) is thrown. - /// Also verifies that the exception message matches. - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// The exception message to verify - /// Pass true to allow exceptions which derive from TException; pass false, otherwise - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static TException Throws(Action testCode, string exceptionMessage, bool allowDerivedExceptions = false) - where TException : Exception - { - var ex = Throws(testCode, allowDerivedExceptions); - VerifyExceptionMessage(ex, exceptionMessage); - return ex; - } - - /// - /// Verifies that an exception of the given type (or optionally a derived type) is thrown. - /// Also verified that the exception message matches. - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// The exception message to verify - /// Pass true to allow exceptions which derive from TException; pass false, otherwise - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static TException Throws(Func testCode, string exceptionMessage, bool allowDerivedExceptions = false) - where TException : Exception - { - return Throws(() => { testCode(); }, exceptionMessage, allowDerivedExceptions); - } - - /// - /// Verifies that the code throws an (or optionally any exception which derives from it). - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// Pass true to allow exceptions which derive from TException; pass false, otherwise - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static ArgumentException ThrowsArgument(Action testCode, string paramName, bool allowDerivedExceptions = false) - { - var ex = Throws(testCode, allowDerivedExceptions); - - if (paramName != null) - { - Equal(paramName, ex.ParamName); - } - - return ex; - } - - /// - /// Verifies that the code throws an (or optionally any exception which derives from it). - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception message to verify - /// Pass true to allow exceptions which derive from TException; pass false, otherwise - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static ArgumentException ThrowsArgument(Action testCode, string paramName, string exceptionMessage, bool allowDerivedExceptions = false) - { - var ex = Throws(testCode, allowDerivedExceptions); - - if (paramName != null) - { - Equal(paramName, ex.ParamName); - } - - VerifyExceptionMessage(ex, exceptionMessage, partialMatch: true); - - return ex; - } - - /// - /// Verifies that the code throws an ArgumentException (or optionally any exception which derives from it). - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// Pass true to allow exceptions which derive from TException; pass false, otherwise - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static ArgumentException ThrowsArgument(Func testCode, string paramName, bool allowDerivedExceptions = false) - { - var ex = Throws(testCode, allowDerivedExceptions); - - if (paramName != null) - { - Equal(paramName, ex.ParamName); - } - - return ex; - } - - /// - /// Verifies that the code throws an ArgumentNullException (or optionally any exception which derives from it). - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static ArgumentNullException ThrowsArgumentNull(Action testCode, string paramName) - { - var ex = Throws(testCode, allowDerivedExceptions: false); - - if (paramName != null) - { - Equal(paramName, ex.ParamName); - } - - return ex; - } - - /// - /// Verifies that the code throws an ArgumentNullException with the expected message that indicates that the value cannot - /// be null or empty. - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static ArgumentException ThrowsArgumentNullOrEmpty(Action testCode, string paramName) - { - return Throws(testCode, "Value cannot be null or empty.\r\nParameter name: " + paramName, allowDerivedExceptions: false); - } - - /// - /// Verifies that the code throws an ArgumentNullException with the expected message that indicates that the value cannot - /// be null or empty string. - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static ArgumentException ThrowsArgumentNullOrEmptyString(Action testCode, string paramName) - { - return ThrowsArgument(testCode, paramName, "Value cannot be null or an empty string.", allowDerivedExceptions: true); - } - - /// - /// Verifies that the code throws an ArgumentOutOfRangeException (or optionally any exception which derives from it). - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception message to verify - /// Pass true to allow exceptions which derive from TException; pass false, otherwise - /// The actual value provided - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - 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(testCode, exceptionMessage, allowDerivedExceptions); - - if (paramName != null) - { - Equal(paramName, ex.ParamName); - } - - return ex; - } - - /// - /// Verifies that the code throws an with the expected message that indicates that - /// the value must be greater than the given . - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The actual value provided. - /// The expected limit value. - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - 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); - } - - /// - /// Verifies that the code throws an with the expected message that indicates that - /// the value must be greater than or equal to the given value. - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The expected limit value. - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - 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); - } - - /// - /// Verifies that the code throws an with the expected message that indicates that - /// the value must be less than the given . - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The actual value provided. - /// The expected limit value. - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - 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); - } - - /// - /// Verifies that the code throws an with the expected message that indicates that - /// the value must be less than or equal to the given . - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The actual value provided. - /// The expected limit value. - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - 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); - } - - /// - /// Verifies that the code throws an HttpException (or optionally any exception which derives from it). - /// - /// A delegate to the code to be tested - /// The exception message to verify - /// The expected HTTP status code of the exception - /// Pass true to allow exceptions which derive from TException; pass false, otherwise - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static HttpException ThrowsHttpException(Action testCode, string exceptionMessage, int httpCode, bool allowDerivedExceptions = false) - { - var ex = Throws(testCode, exceptionMessage, allowDerivedExceptions); - Equal(httpCode, ex.GetHttpCode()); - return ex; - } - - /// - /// Verifies that the code throws an InvalidEnumArgumentException (or optionally any exception which derives from it). - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The expected invalid value that should appear in the message - /// The type of the enumeration - /// Pass true to allow exceptions which derive from TException; pass false, otherwise - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - 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(testCode, message, allowDerivedExceptions); - } - - /// - /// Verifies that the code throws an HttpException (or optionally any exception which derives from it). - /// - /// A delegate to the code to be tested - /// The name of the object that was dispose - /// Pass true to allow exceptions which derive from TException; pass false, otherwise - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - public static ObjectDisposedException ThrowsObjectDisposed(Action testCode, string objectName, bool allowDerivedExceptions = false) - { - var ex = Throws(testCode, allowDerivedExceptions); - - if (objectName != null) - { - Equal(objectName, ex.ObjectName); - } - - return ex; - } - - /// - /// Verifies that an exception of the given type is thrown. - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// The exception that was thrown, when successful - /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown - /// - /// Unlike other Throws* methods, this method does not enforce running the exception delegate with a known Thread Culture. - /// - public static async Task ThrowsAsync(Func 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); - } - } - } -} diff --git a/test/Microsoft.TestCommon/FactAttribute.cs b/test/Microsoft.TestCommon/FactAttribute.cs deleted file mode 100644 index c8a3e9c8c8..0000000000 --- a/test/Microsoft.TestCommon/FactAttribute.cs +++ /dev/null @@ -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 -{ - /// - /// An override of that provides extended capabilities. - /// - [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})"; - } - - /// - /// Gets the platform that the unit test is currently running on. - /// - protected Platform Platform - { - get { return PlatformInfo.Platform; } - } - - /// - /// Gets or set the platforms that the unit test is compatible with. Defaults to - /// . - /// - public Platform Platforms { get; set; } - - /// - /// Gets or sets the platform skipping justification. This message can receive - /// the supported platforms as {0}, and the current platform as {1}. - /// - public string PlatformJustification { get; set; } - - /// - protected override IEnumerable EnumerateTestCommands(IMethodInfo method) - { - if ((Platforms & Platform) == 0) - { - return new[] { - new SkipCommand( - method, - DisplayName, - String.Format(PlatformJustification, Platforms.ToString().Replace(", ", " | "), Platform) - ) - }; - } - - return base.EnumerateTestCommands(method); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.TestCommon/InlineDataAttribute.cs b/test/Microsoft.TestCommon/InlineDataAttribute.cs deleted file mode 100644 index cc946bded5..0000000000 --- a/test/Microsoft.TestCommon/InlineDataAttribute.cs +++ /dev/null @@ -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) - { - } - } -} diff --git a/test/Microsoft.TestCommon/Microsoft.TestCommon.csproj b/test/Microsoft.TestCommon/Microsoft.TestCommon.csproj deleted file mode 100644 index fc7c447b43..0000000000 --- a/test/Microsoft.TestCommon/Microsoft.TestCommon.csproj +++ /dev/null @@ -1,56 +0,0 @@ - - - - {FCCC4CB7-BAF7-4A57-9F89-E5766FE536C0} - Library - Properties - Microsoft.TestCommon - Microsoft.TestCommon - ..\..\bin\$(Configuration)\Test\ - v4.5.1 - - - - false - - - - - - - - - - - - - False - ..\..\packages\xunit.1.9.1\lib\net20\xunit.dll - - - False - ..\..\packages\xunit.extensions.1.9.1\lib\net20\xunit.extensions.dll - - - - - - - - - - - - - - Code - - - - - - - - - - \ No newline at end of file diff --git a/test/Microsoft.TestCommon/Microsoft/TestCommon/TimeoutConstant.cs b/test/Microsoft.TestCommon/Microsoft/TestCommon/TimeoutConstant.cs deleted file mode 100644 index 5f810e4ca2..0000000000 --- a/test/Microsoft.TestCommon/Microsoft/TestCommon/TimeoutConstant.cs +++ /dev/null @@ -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 -{ - /// - /// MSTest timeout constants for use with the . - /// - public class TimeoutConstant - { - private const int seconds = 1000; - - /// - /// The default timeout for test methods. - /// - public const int DefaultTimeout = 30 * seconds; - - /// - /// An extended timeout for longer running test methods. - /// - public const int ExtendedTimeout = 240 * seconds; - } -} diff --git a/test/Microsoft.TestCommon/Platform.cs b/test/Microsoft.TestCommon/Platform.cs deleted file mode 100644 index 53942a2c3f..0000000000 --- a/test/Microsoft.TestCommon/Platform.cs +++ /dev/null @@ -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 -{ - /// - /// An enumeration of known platforms that the unit test might be running under. - /// - [Flags] - public enum Platform - { - /// - /// A special value used to indicate that the test is valid on all known platforms. - /// - All = 0xFFFFFF, - - /// - /// Indicates that the test wants to run on .NET 4 (when used with - /// and/or ), - /// or that the current platform that the test is running on is .NET 4 (when used with the - /// , , and/or - /// ). - /// - Net40 = 0x01, - - /// - /// Indicates that the test wants to run on .NET 4.5 (when used with - /// and/or ), - /// or that the current platform that the test is running on is .NET 4.5 (when used with the - /// , , and/or - /// ). - /// - Net45 = 0x02, - } -} diff --git a/test/Microsoft.TestCommon/PlatformInfo.cs b/test/Microsoft.TestCommon/PlatformInfo.cs deleted file mode 100644 index b7fbb0fa68..0000000000 --- a/test/Microsoft.TestCommon/PlatformInfo.cs +++ /dev/null @@ -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 -{ - /// - /// Used to retrieve the currently running platform. - /// - public static class PlatformInfo - { - private const string _net45TypeName = "System.IWellKnownStringEqualityComparer, mscorlib, Version=4.0.0.0, PublicKeyToken=b77a5c561934e089"; - private static Lazy _platform = new Lazy(GetPlatform, isThreadSafe: true); - - /// - /// Gets the platform that the unit test is currently running on. - /// - 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; - } - } -} diff --git a/test/Microsoft.TestCommon/PropertyDataAttribute.cs b/test/Microsoft.TestCommon/PropertyDataAttribute.cs deleted file mode 100644 index 540bc26e56..0000000000 --- a/test/Microsoft.TestCommon/PropertyDataAttribute.cs +++ /dev/null @@ -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) - { - } - } -} diff --git a/test/Microsoft.TestCommon/ReplaceCultureAttribute.cs b/test/Microsoft.TestCommon/ReplaceCultureAttribute.cs deleted file mode 100644 index 4784393a33..0000000000 --- a/test/Microsoft.TestCommon/ReplaceCultureAttribute.cs +++ /dev/null @@ -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 -{ - /// - /// Replaces the current culture and UI culture for the test. - /// - [AttributeUsage(AttributeTargets.Method)] - public class ReplaceCultureAttribute : Xunit.BeforeAfterTestAttribute - { - private CultureInfo _originalCulture; - private CultureInfo _originalUICulture; - - public ReplaceCultureAttribute() - { - Culture = CultureReplacer.DefaultCultureName; - UICulture = CultureReplacer.DefaultUICultureName; - } - - /// - /// Sets for the test. Defaults to en-GB. - /// - /// - /// 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. - /// - public string Culture { get; set; } - - /// - /// Sets for the test. Defaults to en-US. - /// - 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; - } - } -} diff --git a/test/Microsoft.TestCommon/TheoryAttribute.cs b/test/Microsoft.TestCommon/TheoryAttribute.cs deleted file mode 100644 index 6fced024d4..0000000000 --- a/test/Microsoft.TestCommon/TheoryAttribute.cs +++ /dev/null @@ -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})"; - } - - /// - /// Gets the platform that the unit test is currently running on. - /// - protected Platform Platform - { - get { return PlatformInfo.Platform; } - } - - /// - /// Gets or set the platforms that the unit test is compatible with. Defaults to - /// . - /// - public Platform Platforms { get; set; } - - /// - /// Gets or sets the platform skipping justification. This message can receive - /// the supported platforms as {0}, and the current platform as {1}. - /// - public string PlatformJustification { get; set; } - - /// - protected override IEnumerable EnumerateTestCommands(IMethodInfo method) - { - if ((Platforms & Platform) == 0) - { - return new[] { - new SkipCommand( - method, - DisplayName, - String.Format(PlatformJustification, Platforms.ToString().Replace(", ", " | "), Platform) - ) - }; - } - - return base.EnumerateTestCommands(method); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.TestCommon/packages.config b/test/Microsoft.TestCommon/packages.config deleted file mode 100644 index 9d80a7fba3..0000000000 --- a/test/Microsoft.TestCommon/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file