Réussi! - échec : 0, réussite : 2, ignorée(s) : 0, total : 2, durée : 444 ms
This commit is contained in:
@ -6,35 +6,32 @@ using Xunit;
|
||||
using nuget_host.Data;
|
||||
using Microsoft.Extensions.Options;
|
||||
using nuget_host.Entities;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace nuget.host.tests
|
||||
{
|
||||
public class UnitTestWebHost
|
||||
{
|
||||
|
||||
const string testingUrl = "http://localhost:5003";
|
||||
[Fact]
|
||||
public void TestHaveTestDbContext()
|
||||
public async Task TestHaveTestDbContext()
|
||||
{
|
||||
IWebHost webhost = BuildWebHost( new string[] { "--urls", "localhost:5003" });
|
||||
IWebHost webhost = BuildWebHost( new string[] { "--urls", testingUrl});
|
||||
Assert.NotNull(webhost);
|
||||
ApplicationDbContext dbcontext = (ApplicationDbContext) webhost.Services.GetService(typeof(ApplicationDbContext));
|
||||
Assert.NotNull(dbcontext);
|
||||
dbcontext.Database.EnsureCreated();
|
||||
webhost.Start();
|
||||
await webhost.StopAsync();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestHaveConfig()
|
||||
public async Task TestHaveConfig()
|
||||
{
|
||||
string envVar = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
Assert.Equal("Testing", envVar);
|
||||
IWebHost webhost = BuildWebHost( new string[] { "--urls", "localhost:5003" });
|
||||
Assert.Equal("Development", envVar);
|
||||
IWebHost webhost = BuildWebHost( new string[] { "--urls", testingUrl });
|
||||
Assert.NotNull(webhost);
|
||||
IOptions<NugetSettings> configOptions = (IOptions<NugetSettings>) webhost.Services.GetService(typeof(IOptions<NugetSettings>));
|
||||
NugetSettings nugetConfig = configOptions.Value;
|
||||
|
||||
Assert.NotNull(nugetConfig.ProtectionTitle);
|
||||
Assert.NotNull(nugetConfig.PackagesRootDir);
|
||||
Assert.True(nugetConfig.MaxUserKeyCount>0);
|
||||
webhost.Start();
|
||||
|
||||
await webhost.StopAsync();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user