Fix DataProtection DI dependencies.

This commit is contained in:
Chris Ross 2014-11-18 14:51:36 -08:00
parent 0fee3c87a0
commit b37966f7ef
7 changed files with 64 additions and 7 deletions

View File

@ -18,8 +18,6 @@ using Microsoft.AspNet.Http.Security;
using Microsoft.AspNet.TestHost;
using Shouldly;
using Xunit;
using Microsoft.Framework.OptionsModel;
using Microsoft.Framework.DependencyInjection;
namespace Microsoft.AspNet.Security.Cookies
{
@ -367,7 +365,7 @@ namespace Microsoft.AspNet.Security.Cookies
private static TestServer CreateServer(Action<CookieAuthenticationOptions> configureOptions, Func<HttpContext, Task> testpath = null)
{
return TestServer.Create(app =>
return TestServer.Create(TestServices.CreateTestServices(), app =>
{
app.UseCookieAuthentication(configureOptions);
app.Use(async (context, next) =>

View File

@ -107,7 +107,7 @@ namespace Microsoft.AspNet.Security.Facebook
private static TestServer CreateServer(Action<IApplicationBuilder> configure, Func<HttpContext, bool> handler)
{
return TestServer.Create(app =>
return TestServer.Create(TestServices.CreateTestServices(), app =>
{
if (configure != null)
{

View File

@ -463,7 +463,7 @@ namespace Microsoft.AspNet.Security.Google
private static TestServer CreateServer(Action<GoogleAuthenticationOptions> configureOptions, Func<HttpContext, Task> testpath = null)
{
return TestServer.Create(app =>
return TestServer.Create(TestServices.CreateTestServices(), app =>
{
app.UseServices(services =>
{

View File

@ -161,7 +161,7 @@ namespace Microsoft.AspNet.Security.Tests.MicrosoftAccount
private static TestServer CreateServer(Action<MicrosoftAccountAuthenticationOptions> configureOptions, Func<HttpContext, bool> handler)
{
return TestServer.Create(app =>
return TestServer.Create(TestServices.CreateTestServices(), app =>
{
app.UseServices(services =>
{

View File

@ -0,0 +1,37 @@
// 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.Runtime.Versioning;
using Microsoft.Framework.Runtime;
namespace Microsoft.AspNet.Security
{
public class TestApplicationEnvironment : IApplicationEnvironment
{
public string ApplicationBasePath
{
get { return Environment.CurrentDirectory; }
}
public string ApplicationName
{
get { return "Test App environment"; }
}
public string Configuration
{
get { return "Test"; }
}
public FrameworkName RuntimeFramework
{
get { return new FrameworkName(".NETFramework", new Version(4, 5)); }
}
public string Version
{
get { return "1.0.0"; }
}
}
}

View File

@ -0,0 +1,22 @@
// 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.Security.DataProtection;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.DependencyInjection.Fallback;
using Microsoft.Framework.Runtime;
namespace Microsoft.AspNet.Security
{
public static class TestServices
{
public static IServiceProvider CreateTestServices()
{
var collection = new ServiceCollection();
collection.AddSingleton<IApplicationEnvironment, TestApplicationEnvironment>();
collection.Add(DataProtectionServices.GetDefaultServices());
return collection.BuildServiceProvider();
}
}
}

View File

@ -107,7 +107,7 @@ namespace Microsoft.AspNet.Security.Twitter
private static TestServer CreateServer(Action<IApplicationBuilder> configure, Func<HttpContext, bool> handler)
{
return TestServer.Create(app =>
return TestServer.Create(TestServices.CreateTestServices(), app =>
{
app.UseServices(services =>
{