93 lines
2.6 KiB
C#
93 lines
2.6 KiB
C#
using System.Diagnostics;
|
|
using System.Net;
|
|
using Endpoint;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System;
|
|
|
|
namespace EndpointTest
|
|
{
|
|
/// <summary>
|
|
///This is a test class for HttpEndpointTest and is intended
|
|
///to contain all HttpEndpointTest Unit Tests
|
|
///</summary>
|
|
[TestClass()]
|
|
public class HttpEndpointTest
|
|
{
|
|
private readonly Uri _goodUri = new Uri("http://www.google.com");
|
|
private readonly Uri _missingUri = new Uri("http://www.google.com/gasdfasdh598yqwejbiasalsdjfhaogle");
|
|
private readonly Uri _unreachableDomainUri = new Uri("http://gasdfasdh598yqwejbiasalsdjfhaogle");
|
|
private readonly Uri _downUri = new Uri("http://192.168.0.153");
|
|
private readonly Uri _httpsUri = new Uri("https://sourceforge.net/");
|
|
|
|
/// <summary>
|
|
///A test for Url
|
|
///</summary>
|
|
[TestMethod]
|
|
public void UrlTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _goodUri));
|
|
Assert.AreEqual(_goodUri, endpoint.HttpEndpointConfiguration.Uri);
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for GetStatus
|
|
///</summary>
|
|
[TestMethod]
|
|
public void GetStatusGoodTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _goodUri));
|
|
Assert.AreEqual(Status.Up, endpoint.GetStatus());
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for GetStatus
|
|
///</summary>
|
|
[TestMethod]
|
|
public void GetStatusMissingTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _missingUri));
|
|
Assert.AreEqual(Status.Unreachable, endpoint.GetStatus());
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for GetStatus
|
|
///</summary>
|
|
[TestMethod]
|
|
public void GetStatusUnreachableTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _unreachableDomainUri));
|
|
Assert.AreEqual(Status.Unreachable, endpoint.GetStatus());
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for GetStatus
|
|
///</summary>
|
|
[TestMethod]
|
|
public void GetStatusDownTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _downUri));
|
|
Assert.AreEqual(Status.Unreachable, endpoint.GetStatus());
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for GetStatus
|
|
///</summary>
|
|
[TestMethod]
|
|
public void GetHttpsTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _httpsUri));
|
|
Assert.AreEqual(Status.Up, endpoint.GetStatus());
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for HttpEndpoint Constructor
|
|
///</summary>
|
|
[TestMethod]
|
|
public void HttpEndpointConstructorTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _goodUri));
|
|
Assert.AreEqual(_goodUri, endpoint.HttpEndpointConfiguration.Uri);
|
|
}
|
|
}
|
|
}
|