91 lines
2.4 KiB
C#
91 lines
2.4 KiB
C#
using System;
|
|
using Endpoint;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
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 HttpEndpoint Constructor
|
|
///</summary>
|
|
[TestMethod]
|
|
public void HttpEndpointConstructorTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint {Uri = _goodUri};
|
|
Assert.AreEqual(_goodUri, endpoint.Uri);
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for UrlString
|
|
///</summary>
|
|
[TestMethod]
|
|
public void UrlStringTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint {UriString = "http://uri/"};
|
|
Assert.AreEqual("http://uri/", endpoint.Uri.AbsoluteUri);
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for GetStatus
|
|
///</summary>
|
|
[TestMethod]
|
|
public void GetStatusGoodTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint {Uri = _goodUri};
|
|
Assert.AreEqual(Status.Up, endpoint.GetStatus());
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for GetStatus
|
|
///</summary>
|
|
[TestMethod]
|
|
public void GetStatusMissingTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint {Uri = _missingUri};
|
|
Assert.AreEqual(Status.Unreachable, endpoint.GetStatus());
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for GetStatus
|
|
///</summary>
|
|
[TestMethod]
|
|
public void GetStatusUnreachableTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint {Uri = _unreachableDomainUri};
|
|
Assert.AreEqual(Status.Unreachable, endpoint.GetStatus());
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for GetStatus
|
|
///</summary>
|
|
[TestMethod]
|
|
public void GetStatusDownTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint {Uri = _downUri};
|
|
Assert.AreEqual(Status.Unreachable, endpoint.GetStatus());
|
|
}
|
|
|
|
/// <summary>
|
|
///A test for GetStatus
|
|
///</summary>
|
|
[TestMethod]
|
|
public void GetHttpsTest()
|
|
{
|
|
HttpEndpoint endpoint = new HttpEndpoint {Uri = _httpsUri};
|
|
Assert.AreEqual(Status.Up, endpoint.GetStatus());
|
|
}
|
|
}
|
|
}
|