#122 - Rename IBuilder to IApplicationBuilder.
This commit is contained in:
parent
ba4f44c4ea
commit
335895d9b4
|
|
@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
/// <param name="pathMatch">The path to match</param>
|
/// <param name="pathMatch">The path to match</param>
|
||||||
/// <param name="configuration">The branch to take for positive path matches</param>
|
/// <param name="configuration">The branch to take for positive path matches</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IBuilder Map([NotNull] this IBuilder app, [NotNull] string pathMatch, [NotNull] Action<IBuilder> configuration)
|
public static IApplicationBuilder Map([NotNull] this IApplicationBuilder app, [NotNull] string pathMatch, [NotNull] Action<IApplicationBuilder> configuration)
|
||||||
{
|
{
|
||||||
return Map(app, new PathString(pathMatch), configuration);
|
return Map(app, new PathString(pathMatch), configuration);
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
/// <param name="pathMatch">The path to match</param>
|
/// <param name="pathMatch">The path to match</param>
|
||||||
/// <param name="configuration">The branch to take for positive path matches</param>
|
/// <param name="configuration">The branch to take for positive path matches</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IBuilder Map([NotNull] this IBuilder app, PathString pathMatch, [NotNull] Action<IBuilder> configuration)
|
public static IApplicationBuilder Map([NotNull] this IApplicationBuilder app, PathString pathMatch, [NotNull] Action<IApplicationBuilder> configuration)
|
||||||
{
|
{
|
||||||
if (pathMatch.HasValue && pathMatch.Value.EndsWith("/", StringComparison.Ordinal))
|
if (pathMatch.HasValue && pathMatch.Value.EndsWith("/", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
|
|
@ -38,7 +38,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
}
|
}
|
||||||
|
|
||||||
// create branch
|
// create branch
|
||||||
IBuilder branchBuilder = app.New();
|
var branchBuilder = app.New();
|
||||||
configuration(branchBuilder);
|
configuration(branchBuilder);
|
||||||
var branch = branchBuilder.Build();
|
var branch = branchBuilder.Build();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ namespace Microsoft.AspNet.Builder
|
||||||
/// <param name="predicate">Invoked with the request environment to determine if the branch should be taken</param>
|
/// <param name="predicate">Invoked with the request environment to determine if the branch should be taken</param>
|
||||||
/// <param name="configuration">Configures a branch to take</param>
|
/// <param name="configuration">Configures a branch to take</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IBuilder MapWhen([NotNull] this IBuilder app, [NotNull] Predicate predicate, [NotNull] Action<IBuilder> configuration)
|
public static IApplicationBuilder MapWhen([NotNull] this IApplicationBuilder app, [NotNull] Predicate predicate, [NotNull] Action<IApplicationBuilder> configuration)
|
||||||
{
|
{
|
||||||
// create branch
|
// create branch
|
||||||
IBuilder branchBuilder = app.New();
|
var branchBuilder = app.New();
|
||||||
configuration(branchBuilder);
|
configuration(branchBuilder);
|
||||||
var branch = branchBuilder.Build();
|
var branch = branchBuilder.Build();
|
||||||
|
|
||||||
|
|
@ -46,10 +46,10 @@ namespace Microsoft.AspNet.Builder
|
||||||
/// <param name="predicate">Invoked asynchronously with the request environment to determine if the branch should be taken</param>
|
/// <param name="predicate">Invoked asynchronously with the request environment to determine if the branch should be taken</param>
|
||||||
/// <param name="configuration">Configures a branch to take</param>
|
/// <param name="configuration">Configures a branch to take</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IBuilder MapWhenAsync([NotNull] this IBuilder app, [NotNull] PredicateAsync predicate, [NotNull] Action<IBuilder> configuration)
|
public static IApplicationBuilder MapWhenAsync([NotNull] this IApplicationBuilder app, [NotNull] PredicateAsync predicate, [NotNull] Action<IApplicationBuilder> configuration)
|
||||||
{
|
{
|
||||||
// create branch
|
// create branch
|
||||||
IBuilder branchBuilder = app.New();
|
var branchBuilder = app.New();
|
||||||
configuration(branchBuilder);
|
configuration(branchBuilder);
|
||||||
var branch = branchBuilder.Build();
|
var branch = branchBuilder.Build();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
{
|
{
|
||||||
public static class RunExtensions
|
public static class RunExtensions
|
||||||
{
|
{
|
||||||
public static void Run([NotNull] this IBuilder app, [NotNull] RequestDelegate handler)
|
public static void Run([NotNull] this IApplicationBuilder app, [NotNull] RequestDelegate handler)
|
||||||
{
|
{
|
||||||
app.Use(_ => handler);
|
app.Use(_ => handler);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
/// <param name="app"></param>
|
/// <param name="app"></param>
|
||||||
/// <param name="middleware">A function that handles the request or calls the given next function.</param>
|
/// <param name="middleware">A function that handles the request or calls the given next function.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IBuilder Use(this IBuilder app, Func<HttpContext, Func<Task>, Task> middleware)
|
public static IApplicationBuilder Use(this IApplicationBuilder app, Func<HttpContext, Func<Task>, Task> middleware)
|
||||||
{
|
{
|
||||||
return app.Use(next =>
|
return app.Use(next =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Builder
|
namespace Microsoft.AspNet.Builder
|
||||||
{
|
{
|
||||||
public interface IBuilder
|
public interface IApplicationBuilder
|
||||||
{
|
{
|
||||||
IServiceProvider ApplicationServices { get; set; }
|
IServiceProvider ApplicationServices { get; set; }
|
||||||
|
|
||||||
|
|
@ -14,9 +14,9 @@ namespace Microsoft.AspNet.Builder
|
||||||
|
|
||||||
IDictionary<string, object> Properties { get; set; }
|
IDictionary<string, object> Properties { get; set; }
|
||||||
|
|
||||||
IBuilder Use(Func<RequestDelegate, RequestDelegate> middleware);
|
IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware);
|
||||||
|
|
||||||
IBuilder New();
|
IApplicationBuilder New();
|
||||||
|
|
||||||
RequestDelegate Build();
|
RequestDelegate Build();
|
||||||
}
|
}
|
||||||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
|
|
||||||
public static class OwinExtensions
|
public static class OwinExtensions
|
||||||
{
|
{
|
||||||
public static AddMiddleware UseOwin(this IBuilder builder)
|
public static AddMiddleware UseOwin(this IApplicationBuilder builder)
|
||||||
{
|
{
|
||||||
AddMiddleware add = middleware =>
|
AddMiddleware add = middleware =>
|
||||||
{
|
{
|
||||||
|
|
@ -58,17 +58,17 @@ namespace Microsoft.AspNet.Builder
|
||||||
return add;
|
return add;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBuilder UseOwin(this IBuilder builder, Action<AddMiddleware> pipeline)
|
public static IApplicationBuilder UseOwin(this IApplicationBuilder builder, Action<AddMiddleware> pipeline)
|
||||||
{
|
{
|
||||||
pipeline(builder.UseOwin());
|
pipeline(builder.UseOwin());
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBuilder UseBuilder(this AddMiddleware app)
|
public static IApplicationBuilder UseBuilder(this AddMiddleware app)
|
||||||
{
|
{
|
||||||
// Adapt WebSockets by default.
|
// Adapt WebSockets by default.
|
||||||
app(OwinWebSocketAcceptAdapter.AdaptWebSockets);
|
app(OwinWebSocketAcceptAdapter.AdaptWebSockets);
|
||||||
var builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
|
|
||||||
CreateMiddleware middleware = CreateMiddlewareFactory(exit =>
|
CreateMiddleware middleware = CreateMiddlewareFactory(exit =>
|
||||||
{
|
{
|
||||||
|
|
@ -111,7 +111,7 @@ namespace Microsoft.AspNet.Builder
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AddMiddleware UseBuilder(this AddMiddleware app, Action<IBuilder> pipeline)
|
public static AddMiddleware UseBuilder(this AddMiddleware app, Action<IApplicationBuilder> pipeline)
|
||||||
{
|
{
|
||||||
var builder = app.UseBuilder();
|
var builder = app.UseBuilder();
|
||||||
pipeline(builder);
|
pipeline(builder);
|
||||||
|
|
|
||||||
|
|
@ -5,22 +5,21 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Http;
|
|
||||||
using Microsoft.AspNet.Http.Infrastructure;
|
using Microsoft.AspNet.Http.Infrastructure;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Builder
|
namespace Microsoft.AspNet.Builder
|
||||||
{
|
{
|
||||||
public class Builder : IBuilder
|
public class ApplicationBuilder : IApplicationBuilder
|
||||||
{
|
{
|
||||||
private readonly IList<Func<RequestDelegate, RequestDelegate>> _components = new List<Func<RequestDelegate, RequestDelegate>>();
|
private readonly IList<Func<RequestDelegate, RequestDelegate>> _components = new List<Func<RequestDelegate, RequestDelegate>>();
|
||||||
|
|
||||||
public Builder(IServiceProvider serviceProvider)
|
public ApplicationBuilder(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
Properties = new Dictionary<string, object>();
|
Properties = new Dictionary<string, object>();
|
||||||
ApplicationServices = serviceProvider;
|
ApplicationServices = serviceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Builder(Builder builder)
|
private ApplicationBuilder(ApplicationBuilder builder)
|
||||||
{
|
{
|
||||||
Properties = builder.Properties;
|
Properties = builder.Properties;
|
||||||
}
|
}
|
||||||
|
|
@ -62,15 +61,15 @@ namespace Microsoft.AspNet.Builder
|
||||||
Properties[key] = value;
|
Properties[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBuilder Use(Func<RequestDelegate, RequestDelegate> middleware)
|
public IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware)
|
||||||
{
|
{
|
||||||
_components.Add(middleware);
|
_components.Add(middleware);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBuilder New()
|
public IApplicationBuilder New()
|
||||||
{
|
{
|
||||||
return new Builder(this);
|
return new ApplicationBuilder(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RequestDelegate Build()
|
public RequestDelegate Build()
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
{
|
{
|
||||||
public class MapPathMiddlewareTests
|
public class MapPathMiddlewareTests
|
||||||
{
|
{
|
||||||
private static readonly Action<IBuilder> ActionNotImplemented = new Action<IBuilder>(_ => { throw new NotImplementedException(); });
|
private static readonly Action<IApplicationBuilder> ActionNotImplemented = new Action<IApplicationBuilder>(_ => { throw new NotImplementedException(); });
|
||||||
|
|
||||||
private static Task Success(HttpContext context)
|
private static Task Success(HttpContext context)
|
||||||
{
|
{
|
||||||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
return Task.FromResult<object>(null);
|
return Task.FromResult<object>(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UseSuccess(IBuilder app)
|
private static void UseSuccess(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.Run(Success);
|
app.Run(Success);
|
||||||
}
|
}
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UseNotImplemented(IBuilder app)
|
private static void UseNotImplemented(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.Run(NotImplemented);
|
app.Run(NotImplemented);
|
||||||
}
|
}
|
||||||
|
|
@ -41,8 +41,8 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
[Fact]
|
[Fact]
|
||||||
public void NullArguments_ArgumentNullException()
|
public void NullArguments_ArgumentNullException()
|
||||||
{
|
{
|
||||||
var builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
var noMiddleware = new Builder(serviceProvider: null).Build();
|
var noMiddleware = new ApplicationBuilder(serviceProvider: null).Build();
|
||||||
var noOptions = new MapOptions();
|
var noOptions = new MapOptions();
|
||||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.Map(null, ActionNotImplemented));
|
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.Map(null, ActionNotImplemented));
|
||||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.Map("/foo", (Action<IBuilder>)null));
|
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.Map("/foo", (Action<IBuilder>)null));
|
||||||
|
|
@ -61,7 +61,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
public void PathMatchFunc_BranchTaken(string matchPath, string basePath, string requestPath)
|
public void PathMatchFunc_BranchTaken(string matchPath, string basePath, string requestPath)
|
||||||
{
|
{
|
||||||
HttpContext context = CreateRequest(basePath, requestPath);
|
HttpContext context = CreateRequest(basePath, requestPath);
|
||||||
IBuilder builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
builder.Map(matchPath, UseSuccess);
|
builder.Map(matchPath, UseSuccess);
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
app.Invoke(context).Wait();
|
app.Invoke(context).Wait();
|
||||||
|
|
@ -82,7 +82,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
public void PathMatchAction_BranchTaken(string matchPath, string basePath, string requestPath)
|
public void PathMatchAction_BranchTaken(string matchPath, string basePath, string requestPath)
|
||||||
{
|
{
|
||||||
HttpContext context = CreateRequest(basePath, requestPath);
|
HttpContext context = CreateRequest(basePath, requestPath);
|
||||||
IBuilder builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
builder.Map(matchPath, subBuilder => subBuilder.Run(Success));
|
builder.Map(matchPath, subBuilder => subBuilder.Run(Success));
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
app.Invoke(context).Wait();
|
app.Invoke(context).Wait();
|
||||||
|
|
@ -98,7 +98,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
[InlineData("/foo/cho/")]
|
[InlineData("/foo/cho/")]
|
||||||
public void MatchPathWithTrailingSlashThrowsException(string matchPath)
|
public void MatchPathWithTrailingSlashThrowsException(string matchPath)
|
||||||
{
|
{
|
||||||
Should.Throw<ArgumentException>(() => new Builder(serviceProvider: null).Map(matchPath, map => { }).Build());
|
Should.Throw<ArgumentException>(() => new ApplicationBuilder(serviceProvider: null).Map(matchPath, map => { }).Build());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
|
@ -112,7 +112,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
public void PathMismatchFunc_PassedThrough(string matchPath, string basePath, string requestPath)
|
public void PathMismatchFunc_PassedThrough(string matchPath, string basePath, string requestPath)
|
||||||
{
|
{
|
||||||
HttpContext context = CreateRequest(basePath, requestPath);
|
HttpContext context = CreateRequest(basePath, requestPath);
|
||||||
IBuilder builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
builder.Map(matchPath, UseNotImplemented);
|
builder.Map(matchPath, UseNotImplemented);
|
||||||
builder.Run(Success);
|
builder.Run(Success);
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
@ -134,7 +134,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
public void PathMismatchAction_PassedThrough(string matchPath, string basePath, string requestPath)
|
public void PathMismatchAction_PassedThrough(string matchPath, string basePath, string requestPath)
|
||||||
{
|
{
|
||||||
HttpContext context = CreateRequest(basePath, requestPath);
|
HttpContext context = CreateRequest(basePath, requestPath);
|
||||||
IBuilder builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
builder.Map(matchPath, UseNotImplemented);
|
builder.Map(matchPath, UseNotImplemented);
|
||||||
builder.Run(Success);
|
builder.Run(Success);
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
@ -148,7 +148,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ChainedRoutes_Success()
|
public void ChainedRoutes_Success()
|
||||||
{
|
{
|
||||||
IBuilder builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
builder.Map("/route1", map =>
|
builder.Map("/route1", map =>
|
||||||
{
|
{
|
||||||
map.Map((string)"/subroute1", UseSuccess);
|
map.Map((string)"/subroute1", UseSuccess);
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
return Task.FromResult<object>(null);
|
return Task.FromResult<object>(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UseSuccess(IBuilder app)
|
private static void UseSuccess(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.Run(Success);
|
app.Run(Success);
|
||||||
}
|
}
|
||||||
|
|
@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UseNotImplemented(IBuilder app)
|
private static void UseNotImplemented(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.Run(NotImplemented);
|
app.Run(NotImplemented);
|
||||||
}
|
}
|
||||||
|
|
@ -64,8 +64,8 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
[Fact]
|
[Fact]
|
||||||
public void NullArguments_ArgumentNullException()
|
public void NullArguments_ArgumentNullException()
|
||||||
{
|
{
|
||||||
var builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
var noMiddleware = new Builder(serviceProvider: null).Build();
|
var noMiddleware = new ApplicationBuilder(serviceProvider: null).Build();
|
||||||
var noOptions = new MapWhenOptions();
|
var noOptions = new MapWhenOptions();
|
||||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.MapWhen(null, UseNotImplemented));
|
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.MapWhen(null, UseNotImplemented));
|
||||||
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.MapWhen(NotImplementedPredicate, (Action<IBuilder>)null));
|
// TODO: [NotNull] Assert.Throws<ArgumentNullException>(() => builder.MapWhen(NotImplementedPredicate, (Action<IBuilder>)null));
|
||||||
|
|
@ -82,7 +82,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
public void PredicateTrue_BranchTaken()
|
public void PredicateTrue_BranchTaken()
|
||||||
{
|
{
|
||||||
HttpContext context = CreateRequest();
|
HttpContext context = CreateRequest();
|
||||||
IBuilder builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
builder.MapWhen(TruePredicate, UseSuccess);
|
builder.MapWhen(TruePredicate, UseSuccess);
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
app.Invoke(context).Wait();
|
app.Invoke(context).Wait();
|
||||||
|
|
@ -94,7 +94,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
public void PredicateTrueAction_BranchTaken()
|
public void PredicateTrueAction_BranchTaken()
|
||||||
{
|
{
|
||||||
HttpContext context = CreateRequest();
|
HttpContext context = CreateRequest();
|
||||||
IBuilder builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
builder.MapWhen(TruePredicate, UseSuccess);
|
builder.MapWhen(TruePredicate, UseSuccess);
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
app.Invoke(context).Wait();
|
app.Invoke(context).Wait();
|
||||||
|
|
@ -106,7 +106,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
public void PredicateFalseAction_PassThrough()
|
public void PredicateFalseAction_PassThrough()
|
||||||
{
|
{
|
||||||
HttpContext context = CreateRequest();
|
HttpContext context = CreateRequest();
|
||||||
IBuilder builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
builder.MapWhen(FalsePredicate, UseNotImplemented);
|
builder.MapWhen(FalsePredicate, UseNotImplemented);
|
||||||
builder.Run(Success);
|
builder.Run(Success);
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
@ -119,7 +119,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
public void PredicateAsyncTrueAction_BranchTaken()
|
public void PredicateAsyncTrueAction_BranchTaken()
|
||||||
{
|
{
|
||||||
HttpContext context = CreateRequest();
|
HttpContext context = CreateRequest();
|
||||||
IBuilder builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
builder.MapWhenAsync(TruePredicateAsync, UseSuccess);
|
builder.MapWhenAsync(TruePredicateAsync, UseSuccess);
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
app.Invoke(context).Wait();
|
app.Invoke(context).Wait();
|
||||||
|
|
@ -131,7 +131,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
public void PredicateAsyncFalseAction_PassThrough()
|
public void PredicateAsyncFalseAction_PassThrough()
|
||||||
{
|
{
|
||||||
HttpContext context = CreateRequest();
|
HttpContext context = CreateRequest();
|
||||||
IBuilder builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
builder.MapWhenAsync(FalsePredicateAsync, UseNotImplemented);
|
builder.MapWhenAsync(FalsePredicateAsync, UseNotImplemented);
|
||||||
builder.Run(Success);
|
builder.Run(Success);
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
@ -143,7 +143,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ChainedPredicates_Success()
|
public void ChainedPredicates_Success()
|
||||||
{
|
{
|
||||||
IBuilder builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
builder.MapWhen(TruePredicate, map1 =>
|
builder.MapWhen(TruePredicate, map1 =>
|
||||||
{
|
{
|
||||||
map1.MapWhen((Predicate)FalsePredicate, UseNotImplemented);
|
map1.MapWhen((Predicate)FalsePredicate, UseNotImplemented);
|
||||||
|
|
@ -160,7 +160,7 @@ namespace Microsoft.AspNet.Builder.Extensions
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ChainedPredicatesAsync_Success()
|
public void ChainedPredicatesAsync_Success()
|
||||||
{
|
{
|
||||||
IBuilder builder = new Builder(serviceProvider: null);
|
var builder = new ApplicationBuilder(serviceProvider: null);
|
||||||
builder.MapWhenAsync(TruePredicateAsync, map1 =>
|
builder.MapWhenAsync(TruePredicateAsync, map1 =>
|
||||||
{
|
{
|
||||||
map1.MapWhenAsync((PredicateAsync)FalsePredicateAsync, UseNotImplemented);
|
map1.MapWhenAsync((PredicateAsync)FalsePredicateAsync, UseNotImplemented);
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Builder.Tests
|
namespace Microsoft.AspNet.Builder.Tests
|
||||||
{
|
{
|
||||||
public class BuilderTests
|
public class ApplicationBuilderTests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void BuildReturnsCallableDelegate()
|
public void BuildReturnsCallableDelegate()
|
||||||
{
|
{
|
||||||
var builder = new Builder(null);
|
var builder = new ApplicationBuilder(null);
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
var mockHttpContext = new Moq.Mock<HttpContext>();
|
var mockHttpContext = new Moq.Mock<HttpContext>();
|
||||||
Loading…
Reference in New Issue