Files
isn/test/nuget.host.tests/UnitTestWebHost.cs

45 lines
1.3 KiB
C#

using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore;
using nuget_host;
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 async Task TestHaveTestDbContext()
{
IWebHost webhost = BuildWebHost( new string[] { "--urls", testingUrl});
Assert.NotNull(webhost);
webhost.Start();
await webhost.StopAsync();
}
[Fact]
public async Task TestHaveConfig()
{
string envVar = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
Assert.Equal("Development", envVar);
IWebHost webhost = BuildWebHost( new string[] { "--urls", testingUrl });
Assert.NotNull(webhost);
webhost.Start();
await webhost.StopAsync();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
}