Update xunit in text project and add k10 version

This commit is contained in:
Ryan Nowak 2014-03-17 14:48:30 -07:00
parent ea8f19f186
commit e1a8b5e140
9 changed files with 71 additions and 59 deletions

View File

@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Routing.Te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RoutingSample.k10", "samples\RoutingSample\RoutingSample.k10.csproj", "{1BB31C1A-C6F8-4C00-BD30-92EF775276BE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Routing.Tests.k10", "test\Microsoft.AspNet.Routing.Tests\Microsoft.AspNet.Routing.Tests.k10.csproj", "{83E74560-2C7F-415E-A324-BB31D41E2466}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -45,6 +47,10 @@ Global
{1BB31C1A-C6F8-4C00-BD30-92EF775276BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BB31C1A-C6F8-4C00-BD30-92EF775276BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BB31C1A-C6F8-4C00-BD30-92EF775276BE}.Release|Any CPU.Build.0 = Release|Any CPU
{83E74560-2C7F-415E-A324-BB31D41E2466}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83E74560-2C7F-415E-A324-BB31D41E2466}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83E74560-2C7F-415E-A324-BB31D41E2466}.Release|Any CPU.ActiveCfg = Release|Any CPU
{83E74560-2C7F-415E-A324-BB31D41E2466}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -55,5 +61,6 @@ Global
{121DC7B4-E29B-45E1-BF7E-314842F99A0D} = {C3ADD55B-B9C7-4061-8AD4-6A70D1AE3B2E}
{1BB31C1A-C6F8-4C00-BD30-92EF775276BE} = {C3ADD55B-B9C7-4061-8AD4-6A70D1AE3B2E}
{3775A966-0876-45C3-A67F-0E544BC48D55} = {95359B4B-4C85-4B44-A75B-0621905C4CF6}
{83E74560-2C7F-415E-A324-BB31D41E2466} = {95359B4B-4C85-4B44-A75B-0621905C4CF6}
EndGlobalSection
EndGlobal

View File

@ -1,22 +0,0 @@
using System;
namespace Microsoft.AspNet.Routing
{
// Placeholder until we get our 'real' rich support for these asserts.
public class Assert : Xunit.Assert
{
public static T Throws<T>(Assert.ThrowsDelegate action, string message) where T : Exception
{
T exception = Assert.Throws<T>(action);
Assert.Equal<string>(message, exception.Message);
return exception;
}
public static T Throws<T>(Assert.ThrowsDelegateWithReturn action, string message) where T : Exception
{
T exception = Assert.Throws<T>(action);
Assert.Equal<string>(message, exception.Message);
return exception;
}
}
}

View File

@ -1,4 +1,6 @@

#if NET45
using System.Threading.Tasks;
using Microsoft.AspNet.Abstractions;
using Moq;
@ -108,3 +110,5 @@ namespace Microsoft.AspNet.Routing.Tests
}
}
}
#endif

View File

@ -2,7 +2,7 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
using Microsoft.AspNet.Testing;
using Xunit;
namespace Microsoft.AspNet.Routing.Tests
@ -161,7 +161,7 @@ namespace Microsoft.AspNet.Routing.Tests
var obj = new { controller = "Home", Controller = "Home" };
// Act & Assert
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => new RouteValueDictionary(obj),
"An item with the same key has already been added.");
}

View File

@ -3,7 +3,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using Xunit.Extensions;
namespace Microsoft.AspNet.Routing.Template.Tests
{
@ -118,7 +117,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
}
[Theory]
[PropertyData("EmptyAndNullDefaultValues")]
[MemberData("EmptyAndNullDefaultValues")]
public void Binding_WithEmptyAndNull_DefaultValues(
string template,
IDictionary<string, object> defaults,

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using Xunit;
using Xunit.Extensions;
namespace Microsoft.AspNet.Routing.Template.Tests
{

View File

@ -2,8 +2,8 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Testing;
using Xunit;
using Xunit.Extensions;
namespace Microsoft.AspNet.Routing.Template.Tests
{
@ -192,7 +192,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_WithRepeatedParameter()
{
var ex = Assert.Throws<ArgumentException>(
var ex = ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{Controller}.mvc/{id}/{controller}"),
"The route parameter name 'controller' appears more than one time in the route template." + Environment.NewLine + "Parameter name: routeTemplate");
}
@ -206,7 +206,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[InlineData("p1}}p2{")]
public void InvalidTemplate_WithMismatchedBraces(string template)
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse(template),
@"There is an incomplete parameter in the route template. Check that each '{' character has a matching '}' character." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -215,7 +215,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_CannotHaveCatchAllInMultiSegment()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("123{a}abc{*moo}"),
"A path segment that contains more than one section, such as a literal section or a parameter, cannot contain a catch-all parameter." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -224,7 +224,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_CannotHaveMoreThanOneCatchAll()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{*p1}/{*p2}"),
"A catch-all parameter can only appear as the last segment of the route template." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -233,7 +233,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_CannotHaveMoreThanOneCatchAllInMultiSegment()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{*p1}abc{*p2}"),
"A path segment that contains more than one section, such as a literal section or a parameter, cannot contain a catch-all parameter." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -242,7 +242,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_CannotHaveCatchAllWithNoName()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("foo/{*}"),
"The route parameter name '' is invalid. Route parameter names must be non-empty and cannot contain these characters: '{', '}', '/'. " +
"The '?' character marks a parameter as optional, and can only occur at the end of the parameter." + Environment.NewLine +
@ -252,7 +252,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_CannotHaveConsecutiveOpenBrace()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("foo/{{p1}"),
"There is an incomplete parameter in the route template. Check that each '{' character has a matching '}' character." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -261,7 +261,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_CannotHaveConsecutiveCloseBrace()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("foo/{p1}}"),
"There is an incomplete parameter in the route template. Check that each '{' character has a matching '}' character." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -270,7 +270,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_SameParameterTwiceThrows()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{aaa}/{AAA}"),
"The route parameter name 'AAA' appears more than one time in the route template." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -279,7 +279,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_SameParameterTwiceAndOneCatchAllThrows()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{aaa}/{*AAA}"),
"The route parameter name 'AAA' appears more than one time in the route template." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -288,7 +288,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_InvalidParameterNameWithCloseBracketThrows()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{a}/{aa}a}/{z}"),
"There is an incomplete parameter in the route template. Check that each '{' character has a matching '}' character." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -297,7 +297,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_InvalidParameterNameWithOpenBracketThrows()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{a}/{a{aa}/{z}"),
"The route parameter name 'a{aa' is invalid. Route parameter names must be non-empty and cannot contain these characters: '{', '}', '/'. " +
"The '?' character marks a parameter as optional, and can only occur at the end of the parameter." + Environment.NewLine +
@ -307,7 +307,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_InvalidParameterNameWithEmptyNameThrows()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{a}/{}/{z}"),
"The route parameter name '' is invalid. Route parameter names must be non-empty and cannot contain these characters: '{', '}', '/'. " +
"The '?' character marks a parameter as optional, and can only occur at the end of the parameter." + Environment.NewLine +
@ -317,7 +317,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_InvalidParameterNameWithQuestionThrows()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{Controller}.mvc/{?}"),
"The route parameter name '' is invalid. Route parameter names must be non-empty and cannot contain these characters: '{', '}', '/'. " +
"The '?' character marks a parameter as optional, and can only occur at the end of the parameter." + Environment.NewLine +
@ -327,7 +327,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_ConsecutiveSeparatorsSlashSlashThrows()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{a}//{z}"),
"The route template separator character '/' cannot appear consecutively. It must be separated by either a parameter or a literal value." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -336,7 +336,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_WithCatchAllNotAtTheEndThrows()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("foo/{p1}/{*p2}/{p3}"),
"A catch-all parameter can only appear as the last segment of the route template." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -345,7 +345,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_RepeatedParametersThrows()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("foo/aa{p1}{p2}"),
"A path segment cannot contain two consecutive parameters. They must be separated by a '/' or by a literal string." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -354,7 +354,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_CannotStartWithSlash()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("/foo"),
"The route template cannot start with a '/' or '~' character." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -363,7 +363,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_CannotStartWithTilde()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("~foo"),
"The route template cannot start with a '/' or '~' character." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -372,7 +372,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_CannotContainQuestionMark()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("foor?bar"),
"The literal section 'foor?bar' is invalid. Literal sections cannot contain the '?' character." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -381,7 +381,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_ParameterCannotContainQuestionMark_UnlessAtEnd()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{foor?b}"),
"The route parameter name 'foor?b' is invalid. Route parameter names must be non-empty and cannot contain these characters: '{', '}', '/'. " +
"The '?' character marks a parameter as optional, and can only occur at the end of the parameter." + Environment.NewLine +
@ -391,7 +391,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_MultiSegmentParameterCannotContainOptionalParameter()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{foorb?}-bar-{z}"),
"A path segment that contains more than one section, such as a literal section or a parameter, cannot contain an optional parameter." + Environment.NewLine +
"Parameter name: routeTemplate");
@ -400,7 +400,7 @@ namespace Microsoft.AspNet.Routing.Template.Tests
[Fact]
public void InvalidTemplate_CatchAllMarkedOptional()
{
Assert.Throws<ArgumentException>(
ExceptionAssert.Throws<ArgumentException>(
() => TemplateParser.Parse("{a}/{*b?}"),
"A catch-all parameter cannot be marked optional." + Environment.NewLine +
"Parameter name: routeTemplate");

View File

@ -1,6 +1,9 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
#if NET45
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNet.Abstractions;
using Moq;
using Xunit;
@ -87,7 +90,9 @@ namespace Microsoft.AspNet.Routing.Template.Tests
// Assert
Assert.False(context.IsHandled);
Assert.Null(context.Values);
// Issue #16 tracks this.
Assert.NotNull(context.Values);
}
private static RouteContext CreateRouteContext(string requestPath)
@ -204,9 +209,12 @@ namespace Microsoft.AspNet.Routing.Template.Tests
target
.Setup(e => e.RouteAsync(It.IsAny<RouteContext>()))
.Callback<RouteContext>(async (c) => c.IsHandled = accept);
.Callback<RouteContext>(async (c) => c.IsHandled = accept)
.Returns(Task.FromResult<object>(null));
return target.Object;
}
}
}
#endif

View File

@ -2,16 +2,33 @@
"version": "0.1-alpha-*",
"dependencies": {
"Microsoft.AspNet.Abstractions" : "0.1-alpha-*",
"Microsoft.AspNet.Routing" : ""
"Microsoft.AspNet.Routing" : "",
"Microsoft.AspNet.Testing" : "0.1-alpha-*",
"Xunit.KRunner": "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-*"
},
"configurations": {
"k10": {
"dependencies": {
"System.Collections": "4.0.0.0",
"System.Linq": "4.0.0.0",
"System.Runtime": "4.0.20.0",
"System.Runtime.Extensions": "4.0.10.0",
"System.Threading": "4.0.0.0",
"System.Threading.Tasks": "4.0.0.0"
}
},
"net45": {
"dependencies": {
"Moq": "4.2.1402.2112",
"Owin": "1.0",
"xunit": "1.9.2",
"xunit.extensions": "1.9.2"
"dependencies": {
"Moq": "4.2.1402.2112",
"System.Runtime": ""
}
}
},
"commands": {
"test": "Xunit.KRunner"
}
}