Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 5ab468f

Browse files
committed
Testing additional functionalities
1 parent 128e135 commit 5ab468f

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/Microsoft.AspNet.Owin/OwinExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static IApplicationBuilder UseBuilder(this AddMiddleware app, Action<ISer
7878
}
7979
var builder = new ApplicationBuilder(serviceProvider: services?.BuildServiceProvider());
8080

81-
CreateMiddleware middleware = CreateMiddlewareFactory(exit =>
81+
var middleware = CreateMiddlewareFactory(exit =>
8282
{
8383
builder.Use(ignored => exit);
8484
return builder.Build();

test/Microsoft.AspNet.Owin.Tests/OwinExtensionTests.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.Linq;
67
using System.Threading.Tasks;
78
using Microsoft.AspNet.Builder;
89
using Microsoft.Extensions.DependencyInjection;
@@ -11,6 +12,7 @@
1112

1213
namespace Microsoft.AspNet.Owin
1314
{
15+
using AppFunc = Func<IDictionary<string, object>, Task>;
1416
using CreateMiddleware = Func<
1517
Func<IDictionary<string, object>, Task>,
1618
Func<IDictionary<string, object>, Task>
@@ -22,22 +24,32 @@ namespace Microsoft.AspNet.Owin
2224

2325
public class OwinExtensionTests
2426
{
27+
static AppFunc notFound = async env => env["owin.ResponseStatusCode"] = 404;
28+
2529
[Fact]
2630
public void OwinConfigureServicesAddsServices()
2731
{
28-
AddMiddleware build = new List<CreateMiddleware>().Add;
32+
IList<CreateMiddleware> list = new List<CreateMiddleware>();
33+
AddMiddleware build = list.Add;
2934
IServiceProvider serviceProvider = null;
35+
FakeService fakeService = null;
3036

3137
var builder = build.UseBuilder(applicationBuilder =>
3238
{
3339
serviceProvider = applicationBuilder.ApplicationServices;
34-
}
35-
, serviceCollection =>
40+
applicationBuilder.Run(async context =>
41+
{
42+
fakeService = context.ApplicationServices.GetService<FakeService>();
43+
});
44+
}, serviceCollection =>
3645
{
3746
serviceCollection.AddInstance(new FakeService());
3847
});
3948

40-
Assert.NotNull(serviceProvider);
49+
list.Reverse().Aggregate(notFound, (next, middleware) => middleware(next)).Invoke(new Dictionary<string, object>());
50+
51+
Assert.NotNull(fakeService);
52+
Assert.NotNull(serviceProvider?.GetService<FakeService>());
4153
}
4254

4355
public class FakeService

0 commit comments

Comments
 (0)