parent
ba8c6ccf6f
commit
0a25c28173
|
|
@ -1,9 +1,11 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. 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;
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc.Testing;
|
using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
|
using Microsoft.AspNetCore.TestHost;
|
||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
@ -40,9 +42,16 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void EnsureDatabaseCreated()
|
protected override TestServer CreateServer(IWebHostBuilder builder)
|
||||||
{
|
{
|
||||||
using (var scope = Services.CreateScope())
|
var result = base.CreateServer(builder);
|
||||||
|
EnsureDatabaseCreated(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnsureDatabaseCreated(TestServer server)
|
||||||
|
{
|
||||||
|
using (var scope = server.Host.Services.CreateScope())
|
||||||
{
|
{
|
||||||
scope.ServiceProvider.GetService<TContext>().Database.EnsureCreated();
|
scope.ServiceProvider.GetService<TContext>().Database.EnsureCreated();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. 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;
|
using System;
|
||||||
|
|
@ -289,8 +289,6 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
|
|
||||||
var server = ServerFactory.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices));
|
var server = ServerFactory.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices));
|
||||||
|
|
||||||
ServerFactory.EnsureDatabaseCreated();
|
|
||||||
|
|
||||||
var client = server.CreateClient();
|
var client = server.CreateClient();
|
||||||
var newClient = server.CreateClient();
|
var newClient = server.CreateClient();
|
||||||
|
|
||||||
|
|
@ -313,8 +311,6 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
|
|
||||||
var server = ServerFactory.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices));
|
var server = ServerFactory.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices));
|
||||||
|
|
||||||
ServerFactory.EnsureDatabaseCreated();
|
|
||||||
|
|
||||||
var client = server.CreateClient();
|
var client = server.CreateClient();
|
||||||
var resetPasswordClient = server.CreateClient();
|
var resetPasswordClient = server.CreateClient();
|
||||||
var newClient = server.CreateClient();
|
var newClient = server.CreateClient();
|
||||||
|
|
|
||||||
|
|
@ -289,8 +289,6 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
.WithWebHostBuilder(whb => whb.ConfigureTestServices(ConfigureTestServices))
|
.WithWebHostBuilder(whb => whb.ConfigureTestServices(ConfigureTestServices))
|
||||||
.CreateClient();
|
.CreateClient();
|
||||||
|
|
||||||
ServerFactory.EnsureDatabaseCreated();
|
|
||||||
|
|
||||||
var userName = $"{Guid.NewGuid()}@example.com";
|
var userName = $"{Guid.NewGuid()}@example.com";
|
||||||
var guid = Guid.NewGuid();
|
var guid = Guid.NewGuid();
|
||||||
var email = userName;
|
var email = userName;
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,6 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices))
|
.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices))
|
||||||
.CreateClient();
|
.CreateClient();
|
||||||
|
|
||||||
ServerFactory.EnsureDatabaseCreated();
|
|
||||||
|
|
||||||
var userName = $"{Guid.NewGuid()}@example.com";
|
var userName = $"{Guid.NewGuid()}@example.com";
|
||||||
var password = $"!Test.Password1$";
|
var password = $"!Test.Password1$";
|
||||||
|
|
||||||
|
|
@ -51,8 +49,6 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
var client = server.CreateClient();
|
var client = server.CreateClient();
|
||||||
var client2 = server.CreateClient();
|
var client2 = server.CreateClient();
|
||||||
|
|
||||||
ServerFactory.EnsureDatabaseCreated();
|
|
||||||
|
|
||||||
var userName = $"{Guid.NewGuid()}@example.com";
|
var userName = $"{Guid.NewGuid()}@example.com";
|
||||||
var password = $"!Test.Password1$";
|
var password = $"!Test.Password1$";
|
||||||
|
|
||||||
|
|
@ -85,8 +81,6 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
var client = server.CreateClient();
|
var client = server.CreateClient();
|
||||||
var client2 = server.CreateClient();
|
var client2 = server.CreateClient();
|
||||||
|
|
||||||
ServerFactory.EnsureDatabaseCreated();
|
|
||||||
|
|
||||||
var userName = $"{Guid.NewGuid()}@example.com";
|
var userName = $"{Guid.NewGuid()}@example.com";
|
||||||
var password = $"!Test.Password1$";
|
var password = $"!Test.Password1$";
|
||||||
|
|
||||||
|
|
@ -108,8 +102,6 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices))
|
.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices))
|
||||||
.CreateClient();
|
.CreateClient();
|
||||||
|
|
||||||
ServerFactory.EnsureDatabaseCreated();
|
|
||||||
|
|
||||||
var userName = $"{Guid.NewGuid()}@example.com";
|
var userName = $"{Guid.NewGuid()}@example.com";
|
||||||
var password = $"!Test.Password1$";
|
var password = $"!Test.Password1$";
|
||||||
|
|
||||||
|
|
@ -129,8 +121,6 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices))
|
.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices))
|
||||||
.CreateClient();
|
.CreateClient();
|
||||||
|
|
||||||
ServerFactory.EnsureDatabaseCreated();
|
|
||||||
|
|
||||||
var guid = Guid.NewGuid();
|
var guid = Guid.NewGuid();
|
||||||
var userName = $"{guid}";
|
var userName = $"{guid}";
|
||||||
var email = $"{guid}@example.com";
|
var email = $"{guid}@example.com";
|
||||||
|
|
@ -151,8 +141,6 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices))
|
.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices))
|
||||||
.CreateClient();
|
.CreateClient();
|
||||||
|
|
||||||
ServerFactory.EnsureDatabaseCreated();
|
|
||||||
|
|
||||||
var guid = Guid.NewGuid();
|
var guid = Guid.NewGuid();
|
||||||
var userName = $"{guid}";
|
var userName = $"{guid}";
|
||||||
var email = $"{guid}@example.com";
|
var email = $"{guid}@example.com";
|
||||||
|
|
@ -174,8 +162,6 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices))
|
.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices))
|
||||||
.CreateClient();
|
.CreateClient();
|
||||||
|
|
||||||
ServerFactory.EnsureDatabaseCreated();
|
|
||||||
|
|
||||||
var guid = Guid.NewGuid();
|
var guid = Guid.NewGuid();
|
||||||
var userName = $"{guid}";
|
var userName = $"{guid}";
|
||||||
var email = $"{guid}@example.com";
|
var email = $"{guid}@example.com";
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ namespace Microsoft.AspNetCore.Mvc.Testing
|
||||||
protected virtual Microsoft.AspNetCore.Hosting.IWebHostBuilder CreateWebHostBuilder() { throw null; }
|
protected virtual Microsoft.AspNetCore.Hosting.IWebHostBuilder CreateWebHostBuilder() { throw null; }
|
||||||
public void Dispose() { }
|
public void Dispose() { }
|
||||||
protected virtual void Dispose(bool disposing) { }
|
protected virtual void Dispose(bool disposing) { }
|
||||||
public virtual void EnsureDatabaseCreated() { }
|
|
||||||
~WebApplicationFactory() { }
|
~WebApplicationFactory() { }
|
||||||
protected virtual System.Collections.Generic.IEnumerable<System.Reflection.Assembly> GetTestAssemblies() { throw null; }
|
protected virtual System.Collections.Generic.IEnumerable<System.Reflection.Assembly> GetTestAssemblies() { throw null; }
|
||||||
public Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<TEntryPoint> WithWebHostBuilder(System.Action<Microsoft.AspNetCore.Hosting.IWebHostBuilder> configuration) { throw null; }
|
public Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<TEntryPoint> WithWebHostBuilder(System.Action<Microsoft.AspNetCore.Hosting.IWebHostBuilder> configuration) { throw null; }
|
||||||
|
|
|
||||||
|
|
@ -162,12 +162,6 @@ namespace Microsoft.AspNetCore.Mvc.Testing
|
||||||
SetContentRoot(builder);
|
SetContentRoot(builder);
|
||||||
_configuration(builder);
|
_configuration(builder);
|
||||||
_server = CreateServer(builder);
|
_server = CreateServer(builder);
|
||||||
|
|
||||||
EnsureDatabaseCreated();
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void EnsureDatabaseCreated()
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetContentRoot(IWebHostBuilder builder)
|
private void SetContentRoot(IWebHostBuilder builder)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue