Modifying tests to run in both in aspnet50 and aspnetcore50

* Additionally trimming references from project.json
This commit is contained in:
Pranav K 2014-10-18 08:24:40 -07:00
parent 99fe8294e9
commit 473f642dde
25 changed files with 105 additions and 62 deletions

View File

@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Razor.Runtime
} }
/// <summary> /// <summary>
/// Cannot resolve TagHelper containing assembly '{0}'. Error: '{1}'. /// Cannot resolve TagHelper containing assembly '{0}'.
/// </summary> /// </summary>
internal static string TagHelperTypeResolver_CannotResolveTagHelperAssembly internal static string TagHelperTypeResolver_CannotResolveTagHelperAssembly
{ {
@ -39,11 +39,11 @@ namespace Microsoft.AspNet.Razor.Runtime
} }
/// <summary> /// <summary>
/// Cannot resolve TagHelper containing assembly '{0}'. Error: '{1}'. /// Cannot resolve TagHelper containing assembly '{0}'.
/// </summary> /// </summary>
internal static string FormatTagHelperTypeResolver_CannotResolveTagHelperAssembly(object p0, object p1) internal static string FormatTagHelperTypeResolver_CannotResolveTagHelperAssembly(object p0)
{ {
return string.Format(CultureInfo.CurrentCulture, GetString("TagHelperTypeResolver_CannotResolveTagHelperAssembly"), p0, p1); return string.Format(CultureInfo.CurrentCulture, GetString("TagHelperTypeResolver_CannotResolveTagHelperAssembly"), p0);
} }
/// <summary> /// <summary>

View File

@ -123,7 +123,7 @@
"typeName, assemblyName"</value> "typeName, assemblyName"</value>
</data> </data>
<data name="TagHelperTypeResolver_CannotResolveTagHelperAssembly" xml:space="preserve"> <data name="TagHelperTypeResolver_CannotResolveTagHelperAssembly" xml:space="preserve">
<value>Cannot resolve TagHelper containing assembly '{0}'. Error: '{1}'.</value> <value>Cannot resolve TagHelper containing assembly '{0}'.</value>
</data> </data>
<data name="TagHelperTypeResolver_TagHelperAssemblyNameCannotBeEmptyOrNull" xml:space="preserve"> <data name="TagHelperTypeResolver_TagHelperAssemblyNameCannotBeEmptyOrNull" xml:space="preserve">
<value>Tag helper directive assembly name cannot be null or empty.</value> <value>Tag helper directive assembly name cannot be null or empty.</value>

View File

@ -57,8 +57,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
catch (Exception ex) catch (Exception ex)
{ {
throw new InvalidOperationException( throw new InvalidOperationException(
Resources.FormatTagHelperTypeResolver_CannotResolveTagHelperAssembly(assemblyName.Name, Resources.FormatTagHelperTypeResolver_CannotResolveTagHelperAssembly(assemblyName.Name), ex);
ex.Message));
} }
} }

View File

@ -5,6 +5,7 @@
}, },
"frameworks": { "frameworks": {
"net45": { }, "net45": { },
"aspnet50": { },
"aspnetcore50": { "aspnetcore50": {
"dependencies": { "dependencies": {
"System.Reflection.Extensions": "4.0.0-beta-*" "System.Reflection.Extensions": "4.0.0-beta-*"

View File

@ -427,13 +427,13 @@ namespace Microsoft.AspNet.Razor.Editor
else else
{ {
RazorEditorTrace.TraceLine(RazorResources.FormatTrace_NoChangesArrived(fileNameOnly)); RazorEditorTrace.TraceLine(RazorResources.FormatTrace_NoChangesArrived(fileNameOnly));
#if NET45 #if ASPNETCORE50
// This does the equivalent of thread.yield under the covers.
spinWait.SpinOnce();
#else
// No Yield in CoreCLR // No Yield in CoreCLR
Thread.Yield(); Thread.Yield();
#else
// This does the equivalent of thread.yield under the covers.
spinWait.SpinOnce();
#endif #endif
} }
} }

View File

@ -2,20 +2,17 @@
"version": "4.0.0-*", "version": "4.0.0-*",
"frameworks": { "frameworks": {
"net45": { }, "net45": { },
"aspnet50": { },
"aspnetcore50": { "aspnetcore50": {
"dependencies": { "dependencies": {
"System.Collections": "4.0.10-beta-*", "System.Collections": "4.0.10-beta-*",
"System.Diagnostics.Debug": "4.0.10-beta-*", "System.Diagnostics.Debug": "4.0.10-beta-*",
"System.Diagnostics.Tools": "4.0.0-beta-*", "System.Diagnostics.Tools": "4.0.0-beta-*",
"System.Globalization": "4.0.10-beta-*",
"System.IO": "4.0.10-beta-*",
"System.IO.FileSystem": "4.0.0-beta-*", "System.IO.FileSystem": "4.0.0-beta-*",
"System.Linq": "4.0.0-beta-*", "System.Linq": "4.0.0-beta-*",
"System.Reflection": "4.0.10-beta-*", "System.Reflection": "4.0.10-beta-*",
"System.Resources.ResourceManager": "4.0.0-beta-*", "System.Resources.ResourceManager": "4.0.0-beta-*",
"System.Runtime": "4.0.20-beta-*",
"System.Runtime.Extensions": "4.0.10-beta-*", "System.Runtime.Extensions": "4.0.10-beta-*",
"System.Runtime.InteropServices": "4.0.20-beta-*",
"System.Threading": "4.0.0-beta-*", "System.Threading": "4.0.0-beta-*",
"System.Threading.Tasks": "4.0.10-beta-*", "System.Threading.Tasks": "4.0.10-beta-*",
"System.Threading.Thread": "4.0.0-beta-*", "System.Threading.Thread": "4.0.0-beta-*",

View File

@ -1,6 +1,7 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Reflection;
using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.AspNet.Razor.TagHelpers;
using Xunit; using Xunit;

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -40,10 +41,8 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
var tagHelperTypeResolver = new TagHelperTypeResolver(); var tagHelperTypeResolver = new TagHelperTypeResolver();
var expectedErrorMessage = string.Format( var expectedErrorMessage = string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"Cannot resolve TagHelper containing assembly '{0}'. Error: '{1}'.", "Cannot resolve TagHelper containing assembly '{0}'.",
"abcd", "abcd");
"Could not load file or assembly 'abcd' or one of its dependencies. " +
"The system cannot find the file specified.");
// Act & Assert // Act & Assert
var ex = Assert.Throws<InvalidOperationException>(() => var ex = Assert.Throws<InvalidOperationException>(() =>
@ -51,7 +50,12 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
tagHelperTypeResolver.Resolve("abcd"); tagHelperTypeResolver.Resolve("abcd");
}); });
Assert.Equal(expectedErrorMessage, ex.Message, StringComparer.OrdinalIgnoreCase); Assert.Equal(expectedErrorMessage, ex.Message);
#if ASPNETCORE50
Assert.IsType<FileLoadException>(ex.InnerException);
#else
Assert.IsType<FileNotFoundException>(ex.InnerException);
#endif
} }
[Fact] [Fact]

View File

@ -2,12 +2,18 @@
"version": "1.0.0", "version": "1.0.0",
"dependencies": { "dependencies": {
"Microsoft.AspNet.Razor.Runtime": "4.0.0-*", "Microsoft.AspNet.Razor.Runtime": "4.0.0-*",
"Microsoft.AspNet.Razor.Test": "1.0.0" "Microsoft.AspNet.Testing": "1.0.0-*",
"Xunit.KRunner": "1.0.0-*"
}, },
"commands": { "commands": {
"test": "Xunit.KRunner" "test": "Xunit.KRunner"
}, },
"frameworks": { "frameworks": {
"aspnet50": { } "aspnet50": { },
"aspnetcore50": {
"dependencies": {
"System.Runtime.Extensions": "4.0.10-beta-*"
}
}
} }
} }

View File

@ -11,7 +11,6 @@ using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Test.Utils; using Microsoft.AspNet.Razor.Test.Utils;
using Microsoft.AspNet.Razor.Text; using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Testing; using Microsoft.AspNet.Testing;
using Moq;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Razor.Test.Editor namespace Microsoft.AspNet.Razor.Test.Editor
@ -176,11 +175,6 @@ namespace Microsoft.AspNet.Razor.Test.Editor
return new TextChange(0, 0, new StringTextBuffer(String.Empty), 3, new StringTextBuffer("foo")); return new TextChange(0, 0, new StringTextBuffer(String.Empty), 3, new StringTextBuffer("foo"));
} }
private static Mock<RazorEditorParser> CreateMockParser()
{
return new Mock<RazorEditorParser>(CreateHost(), TestLinePragmaFileName) { CallBase = true };
}
private static RazorEditorParser CreateClientParser() private static RazorEditorParser CreateClientParser()
{ {
return new RazorEditorParser(CreateHost(), TestLinePragmaFileName); return new RazorEditorParser(CreateHost(), TestLinePragmaFileName);

View File

@ -5,7 +5,6 @@ using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Razor.Generator.Compiler; using Microsoft.AspNet.Razor.Generator.Compiler;
using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.AspNet.Razor.TagHelpers;
using Moq;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Razor.Test.Generator namespace Microsoft.AspNet.Razor.Test.Generator
@ -46,9 +45,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
public void TagHelpers_WithinHelpersAndSections_GeneratesExpectedOutput(string testType) public void TagHelpers_WithinHelpersAndSections_GeneratesExpectedOutput(string testType)
{ {
// Arrange // Arrange
var propertyInfoMock = new Mock<PropertyInfo>(); var propertyInfo = typeof(TestType).GetProperty("BoundProperty");
propertyInfoMock.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(string));
propertyInfoMock.Setup(propertyInfo => propertyInfo.Name).Returns("BoundProperty");
var tagHelperDescriptors = new TagHelperDescriptor[] var tagHelperDescriptors = new TagHelperDescriptor[]
{ {
new TagHelperDescriptor("MyTagHelper", new TagHelperDescriptor("MyTagHelper",
@ -56,7 +53,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
ContentBehavior.None, ContentBehavior.None,
new [] { new [] {
new TagHelperAttributeDescriptor("BoundProperty", new TagHelperAttributeDescriptor("BoundProperty",
propertyInfoMock.Object) propertyInfo)
}), }),
new TagHelperDescriptor("NestedTagHelper", "NestedTagHelper", ContentBehavior.Modify) new TagHelperDescriptor("NestedTagHelper", "NestedTagHelper", ContentBehavior.Modify)
}; };
@ -72,35 +69,29 @@ namespace Microsoft.AspNet.Razor.Test.Generator
public void TagHelpers_GenerateExpectedOutput(string testType) public void TagHelpers_GenerateExpectedOutput(string testType)
{ {
// Arrange // Arrange
var pFooPropertyInfo = new Mock<PropertyInfo>(); var pFooPropertyInfo = typeof(TestType).GetProperty("Foo");
pFooPropertyInfo.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(int)); var inputTypePropertyInfo = typeof(TestType).GetProperty("Type");
pFooPropertyInfo.Setup(propertyInfo => propertyInfo.Name).Returns("Foo"); var checkedPropertyInfo = typeof(TestType).GetProperty("Checked");
var inputTypePropertyInfo = new Mock<PropertyInfo>();
inputTypePropertyInfo.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(string));
inputTypePropertyInfo.Setup(propertyInfo => propertyInfo.Name).Returns("Type");
var checkedPropertyInfo = new Mock<PropertyInfo>();
checkedPropertyInfo.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(bool));
checkedPropertyInfo.Setup(propertyInfo => propertyInfo.Name).Returns("Checked");
var tagHelperDescriptors = new TagHelperDescriptor[] var tagHelperDescriptors = new TagHelperDescriptor[]
{ {
new TagHelperDescriptor("p", new TagHelperDescriptor("p",
"PTagHelper", "PTagHelper",
ContentBehavior.None, ContentBehavior.None,
new [] { new [] {
new TagHelperAttributeDescriptor("foo", pFooPropertyInfo.Object) new TagHelperAttributeDescriptor("foo", pFooPropertyInfo)
}), }),
new TagHelperDescriptor("input", new TagHelperDescriptor("input",
"InputTagHelper", "InputTagHelper",
ContentBehavior.None, ContentBehavior.None,
new TagHelperAttributeDescriptor[] { new TagHelperAttributeDescriptor[] {
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object) new TagHelperAttributeDescriptor("type", inputTypePropertyInfo)
}), }),
new TagHelperDescriptor("input", new TagHelperDescriptor("input",
"InputTagHelper2", "InputTagHelper2",
ContentBehavior.None, ContentBehavior.None,
new TagHelperAttributeDescriptor[] { new TagHelperAttributeDescriptor[] {
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object), new TagHelperAttributeDescriptor("type", inputTypePropertyInfo),
new TagHelperAttributeDescriptor("checked", checkedPropertyInfo.Object) new TagHelperAttributeDescriptor("checked", checkedPropertyInfo)
}) })
}; };
@ -124,5 +115,16 @@ namespace Microsoft.AspNet.Razor.Test.Generator
// Act & Assert // Act & Assert
RunTagHelperTest("ContentBehaviorTagHelpers", tagHelperDescriptors: tagHelperDescriptors); RunTagHelperTest("ContentBehaviorTagHelpers", tagHelperDescriptors: tagHelperDescriptors);
} }
private class TestType
{
public int Foo { get; set; }
public string Type { get; set; }
public bool Checked { get; set; }
public string BoundProperty { get; set; }
}
} }
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if !ASPNETCORE50
using Microsoft.AspNet.Razor.Generator; using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Utils; using Microsoft.AspNet.Razor.Test.Utils;
@ -41,3 +42,4 @@ namespace Microsoft.AspNet.Razor.Test.Generator.CodeTree
} }
} }
} }
#endif

View File

@ -1,4 +1,8 @@
using Microsoft.AspNet.Razor.Generator; // 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.
#if !ASPNETCORE50
using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Generator.Compiler; using Microsoft.AspNet.Razor.Generator.Compiler;
using Moq; using Moq;
using Moq.Protected; using Moq.Protected;
@ -40,3 +44,4 @@ namespace Microsoft.AspNet.Razor
} }
} }
} }
#endif

View File

@ -7,7 +7,6 @@ using Microsoft.AspNet.Razor.Generator;
using Microsoft.AspNet.Razor.Generator.Compiler; using Microsoft.AspNet.Razor.Generator.Compiler;
using Microsoft.AspNet.Razor.Generator.Compiler.CSharp; using Microsoft.AspNet.Razor.Generator.Compiler.CSharp;
using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.AspNet.Razor.TagHelpers;
using Moq;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Razor.Test.Generator namespace Microsoft.AspNet.Razor.Test.Generator
@ -18,12 +17,8 @@ namespace Microsoft.AspNet.Razor.Test.Generator
public void TagHelpers_CanReplaceAttributeCodeGeneratorLogic() public void TagHelpers_CanReplaceAttributeCodeGeneratorLogic()
{ {
// Arrange // Arrange
var inputTypePropertyInfo = new Mock<PropertyInfo>(); var inputTypePropertyInfo = typeof(TestType).GetProperty("Type");
inputTypePropertyInfo.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(string)); var checkedPropertyInfo = typeof(TestType).GetProperty("Checked");
inputTypePropertyInfo.Setup(propertyInfo => propertyInfo.Name).Returns("Type");
var checkedPropertyInfo = new Mock<PropertyInfo>();
checkedPropertyInfo.Setup(propertyInfo => propertyInfo.PropertyType).Returns(typeof(bool));
checkedPropertyInfo.Setup(propertyInfo => propertyInfo.Name).Returns("Checked");
var tagHelperDescriptors = new TagHelperDescriptor[] var tagHelperDescriptors = new TagHelperDescriptor[]
{ {
new TagHelperDescriptor("p", "PTagHelper", ContentBehavior.None), new TagHelperDescriptor("p", "PTagHelper", ContentBehavior.None),
@ -31,14 +26,14 @@ namespace Microsoft.AspNet.Razor.Test.Generator
"InputTagHelper", "InputTagHelper",
ContentBehavior.None, ContentBehavior.None,
new TagHelperAttributeDescriptor[] { new TagHelperAttributeDescriptor[] {
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object) new TagHelperAttributeDescriptor("type", inputTypePropertyInfo)
}), }),
new TagHelperDescriptor("input", new TagHelperDescriptor("input",
"InputTagHelper2", "InputTagHelper2",
ContentBehavior.None, ContentBehavior.None,
new TagHelperAttributeDescriptor[] { new TagHelperAttributeDescriptor[] {
new TagHelperAttributeDescriptor("type", inputTypePropertyInfo.Object), new TagHelperAttributeDescriptor("type", inputTypePropertyInfo),
new TagHelperAttributeDescriptor("checked", checkedPropertyInfo.Object) new TagHelperAttributeDescriptor("checked", checkedPropertyInfo)
}) })
}; };
@ -96,5 +91,12 @@ namespace Microsoft.AspNet.Razor.Test.Generator
base.RenderAttributeValue(attributeInfo, writer, context, renderAttributeValue); base.RenderAttributeValue(attributeInfo, writer, context, renderAttributeValue);
} }
} }
private class TestType
{
public string Type { get; set; }
public bool Checked { get; set; }
}
} }
} }

View File

@ -7,7 +7,9 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework; using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text; using Microsoft.AspNet.Razor.Text;
#if !ASPNETCORE50
using Moq; using Moq;
#endif
using Xunit; using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser namespace Microsoft.AspNet.Razor.Test.Parser
@ -69,6 +71,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser
RunOnEndBlockTest(endBlockCallback => new CallbackVisitor(_ => { }, _ => { }, _ => { }, endBlockCallback)); RunOnEndBlockTest(endBlockCallback => new CallbackVisitor(_ => { }, _ => { }, _ => { }, endBlockCallback));
} }
#if !ASPNETCORE50
[Fact] [Fact]
public void ListenerCallsOnEndSpanCallbackUsingSynchronizationContextIfSpecified() public void ListenerCallsOnEndSpanCallbackUsingSynchronizationContextIfSpecified()
{ {
@ -120,6 +123,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
}); });
} }
#endif
private static void RunOnStartBlockTest(Func<Action<BlockType>, CallbackVisitor> ctor, Action<BlockType, BlockType> verifyResults = null) private static void RunOnStartBlockTest(Func<Action<BlockType>, CallbackVisitor> ctor, Action<BlockType, BlockType> verifyResults = null)
{ {

View File

@ -8,7 +8,9 @@ using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework; using Microsoft.AspNet.Razor.Test.Framework;
using Microsoft.AspNet.Razor.Text; using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer.Symbols; using Microsoft.AspNet.Razor.Tokenizer.Symbols;
#if !ASPNETCORE50
using Moq; using Moq;
#endif
using Xunit; using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser namespace Microsoft.AspNet.Razor.Test.Parser
@ -137,6 +139,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser
Assert.Equal(BlockType.Expression, context.BlockStack.Peek().Type); Assert.Equal(BlockType.Expression, context.BlockStack.Peek().Type);
} }
#if !ASPNETCORE50
[Fact] [Fact]
public void EndBlockAddsCurrentBlockToParentBlock() public void EndBlockAddsCurrentBlockToParentBlock()
{ {
@ -185,6 +188,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser
// Assert // Assert
ParserTestBase.EvaluateResults(context.CompleteParse(), expected.Build()); ParserTestBase.EvaluateResults(context.CompleteParse(), expected.Build());
} }
#endif
[Fact] [Fact]
public void SwitchActiveParserSetsMarkupParserAsActiveIfCodeParserCurrentlyActive() public void SwitchActiveParserSetsMarkupParserAsActiveIfCodeParserCurrentlyActive()

View File

@ -1,6 +1,7 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if !ASPNETCORE50
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
@ -83,3 +84,4 @@ namespace Microsoft.AspNet.Razor.Test.Parser
} }
} }
} }
#endif

View File

@ -9,8 +9,10 @@ using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.AspNet.Razor.Test.Framework; using Microsoft.AspNet.Razor.Test.Framework;
#if !ASPNETCORE50
using Moq; using Moq;
using Moq.Protected; using Moq.Protected;
#endif
using Xunit; using Xunit;
namespace Microsoft.AspNet.Razor.Test.Parser namespace Microsoft.AspNet.Razor.Test.Parser
@ -64,6 +66,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser
factory.Markup(" baz"))); factory.Markup(" baz")));
} }
#if !ASPNETCORE50
[Fact] [Fact]
public void GetTagHelperDescriptors_IsInvokedToLocateTagHelperDescriptors() public void GetTagHelperDescriptors_IsInvokedToLocateTagHelperDescriptors()
{ {
@ -84,6 +87,7 @@ namespace Microsoft.AspNet.Razor.Test.Parser
// Assert // Assert
parser.Verify(); parser.Verify();
} }
#endif
[Fact] [Fact]
public void ParseMethodSetsUpRunWithSpecifiedCodeParserMarkupParserAndListenerAndPassesToMarkupParser() public void ParseMethodSetsUpRunWithSpecifiedCodeParserMarkupParserAndListenerAndPassesToMarkupParser()

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Linq; using System.Reflection;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Razor.Test namespace Microsoft.AspNet.Razor.Test
@ -21,8 +21,9 @@ namespace Microsoft.AspNet.Razor.Test
public void EnsureRazorDirectiveProperties() public void EnsureRazorDirectiveProperties()
{ {
// Arrange // Arrange
var attribute = (AttributeUsageAttribute)typeof(RazorDirectiveAttribute).GetCustomAttributes(typeof(AttributeUsageAttribute), inherit: false) var attribute = typeof(RazorDirectiveAttribute)
.SingleOrDefault(); .GetTypeInfo()
.GetCustomAttribute<AttributeUsageAttribute>(inherit: false);
// Assert // Assert
Assert.True(attribute.AllowMultiple); Assert.True(attribute.AllowMultiple);

View File

@ -1,6 +1,7 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if !ASPNETCORE50
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -330,3 +331,4 @@ namespace Microsoft.AspNet.Razor.Test
} }
} }
} }
#endif

View File

@ -155,11 +155,13 @@ namespace Microsoft.AspNet.Razor.Test.Text
RunDisposeTest(r => r.Dispose()); RunDisposeTest(r => r.Dispose());
} }
#if !ASPNETCORE50
[Fact] [Fact]
public void CloseDisposesSourceReader() public void CloseDisposesSourceReader()
{ {
RunDisposeTest(r => r.Close()); RunDisposeTest(r => r.Close());
} }
#endif
[Fact] [Fact]
public void ReadWithBufferSupportsLookahead() public void ReadWithBufferSupportsLookahead()

View File

@ -142,11 +142,13 @@ namespace Microsoft.AspNet.Razor.Test.Text
RunDisposeTest(r => r.Dispose()); RunDisposeTest(r => r.Dispose());
} }
#if !ASPNETCORE50
[Fact] [Fact]
public void CloseDisposesSourceReader() public void CloseDisposesSourceReader()
{ {
RunDisposeTest(r => r.Close()); RunDisposeTest(r => r.Close());
} }
#endif
[Fact] [Fact]
public void ReadWithBufferSupportsLookahead() public void ReadWithBufferSupportsLookahead()

View File

@ -4,13 +4,16 @@
using System; using System;
using System.Web.WebPages.TestUtils; using System.Web.WebPages.TestUtils;
using Microsoft.AspNet.Razor.Text; using Microsoft.AspNet.Razor.Text;
#if !ASPNETCORE50
using Moq; using Moq;
#endif
using Xunit; using Xunit;
namespace Microsoft.AspNet.Razor.Test.Text namespace Microsoft.AspNet.Razor.Test.Text
{ {
public class TextChangeTest public class TextChangeTest
{ {
#if !ASPNETCORE50
[Fact] [Fact]
public void ConstructorRequiresNonNegativeOldPosition() public void ConstructorRequiresNonNegativeOldPosition()
{ {
@ -158,6 +161,7 @@ namespace Microsoft.AspNet.Razor.Test.Text
Assert.Equal(1, change.NewText.Length); Assert.Equal(1, change.NewText.Length);
Assert.Equal(5, change.OldText.Length); Assert.Equal(5, change.OldText.Length);
} }
#endif
[Fact] [Fact]
public void OldTextReturnsOldSpanFromOldBuffer() public void OldTextReturnsOldSpanFromOldBuffer()

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Razor.Test
public static TestFile Create(string localResourceName) public static TestFile Create(string localResourceName)
{ {
return new TestFile(localResourceName, Assembly.GetCallingAssembly()); return new TestFile(localResourceName, typeof(TestFile).GetTypeInfo().Assembly);
} }
public Stream OpenRead() public Stream OpenRead()

View File

@ -11,6 +11,11 @@
"test": "Xunit.KRunner" "test": "Xunit.KRunner"
}, },
"frameworks": { "frameworks": {
"aspnet50": { } "aspnet50": { },
"aspnetcore50": {
"dependencies": {
"System.Diagnostics.TraceSource": "4.0.0-beta-*"
}
}
} }
} }