mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-12-28 03:05:49 +08:00
Set up acceptance tests on windows
This commit is contained in:
@@ -1,24 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Ocelot;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Xunit;
|
||||
|
||||
namespace Ocelot.AcceptanceTests
|
||||
{
|
||||
public class RouterTests
|
||||
public class RouterTests : IDisposable
|
||||
{
|
||||
private readonly TestServer _server;
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public RouterTests()
|
||||
{
|
||||
// Arrange
|
||||
_server = new TestServer(new WebHostBuilder()
|
||||
.UseStartup<Startup>());
|
||||
_client = _server.CreateClient();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_route_request()
|
||||
public async Task ReturnHelloWorld()
|
||||
{
|
||||
|
||||
// Act
|
||||
var response = await _client.GetAsync("/");
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
|
||||
// Assert
|
||||
Assert.Equal("Hello from Tom",
|
||||
responseString);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_client.Dispose();
|
||||
_server.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user