37 lines
914 B
C#
37 lines
914 B
C#
using System;
|
|
using ln.http.client;
|
|
using NUnit.Framework;
|
|
|
|
namespace ln.http.tests
|
|
{
|
|
public class ClientTests
|
|
{
|
|
private HttpClient HttpClient;
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
HttpClient = new HttpClient();
|
|
}
|
|
|
|
[Test]
|
|
public void TestClient()
|
|
{
|
|
var o = HttpClient.Get("http://l--n.de");
|
|
if (o && o.Value is HttpClientResponse response)
|
|
{
|
|
Assert.AreEqual(HttpStatusCode.Found, response.StatusCode);
|
|
Assert.AreEqual("https://l--n.de/", response.Headers.Get("Location"));
|
|
}
|
|
|
|
HttpClient.FollowRedirects = true;
|
|
o = HttpClient.Get("http://l--n.de");
|
|
if (o && o.Value is HttpClientResponse response2)
|
|
{
|
|
Assert.AreEqual(HttpStatusCode.OK, response2.StatusCode);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
} |