This commit is contained in:
2025-10-11 09:42:00 -04:00
parent dc4f980a55
commit 0e59b296a3
49 changed files with 3559 additions and 0 deletions
+117
View File
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{76D78812-B640-4EF0-957B-15D0E9000A84}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EndpointTest</RootNamespace>
<AssemblyName>EndpointTest</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="HtmlAgilityPack, Version=1.3.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Endpoint\References\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Endpoint\References\Oracle.DataAccess.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="SoapEndpointTest.cs" />
<Compile Include="HtmlEndpointTest.cs" />
<Compile Include="HttpEndpointTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WindowsServiceEndpointTest.cs" />
<Compile Include="WmiEndpointTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Endpoint\Endpoint.csproj">
<Project>{7686BAA6-A0C5-4FA5-BE6E-FA044C2FFDD4}</Project>
<Name>Endpoint</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+53
View File
@@ -0,0 +1,53 @@
using System;
using Endpoint;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace EndpointTest
{
/// <summary>
///This is a test class for HtmlEndpointTest and is intended
///to contain all HtmlEndpointTest Unit Tests
///</summary>
[TestClass]
public class HtmlEndpointTest
{
// Random website for functional testing
private readonly Uri _goodUri = new Uri("http://www.seekwellness.com/sca/");
/// <summary>
///A test for HtmlEndpointConfiguration
///</summary>
[TestMethod]
public void HtmlEndpointConfigurationTest()
{
var target = new HtmlEndpoint
{
UriString = _goodUri.OriginalString,
XpathQuery = "//td[contains(text(), 'Use this form')]/text()",
ExpectedXpathResult = "Use this form to order your",
RequestContent = "redeem_coupon=true&f_coupon_code=stuff"
};
var status = target.GetStatus();
Assert.AreEqual(Status.Up, status, target.StatusDescription);
}
/// <summary>
///A test for HtmlEndpointConfiguration
///</summary>
[TestMethod]
public void HtmlEndpointFormTest()
{
var target = new HtmlEndpoint
{
UriString = _goodUri.OriginalString,
XpathQuery = "//p[@class='errorMsg']/text()",
ExpectedXpathResult = "- Please enter a valid coupon code.",
RequestContent = "redeem_coupon=true&f_coupon_code=stuff"
};
var status = target.GetStatus();
Assert.AreEqual(Status.Up, status, target.StatusDescription);
}
}
}
+90
View File
@@ -0,0 +1,90 @@
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());
}
}
}
+35
View File
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EndpointTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EndpointTest")]
[assembly: AssemblyCopyright("Copyright © 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM componenets. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b5dcbcfc-f05e-4e58-bd8b-e4cbf660065d")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,57 @@
using System;
using System.IO;
using Endpoint;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
namespace EndpointTest
{
///// <summary>
/////This is a test class for ServiceEndpointConfigurationTest and is intended
/////to contain all ServiceEndpointConfigurationTest Unit Tests
/////</summary>
//[TestClass()]
//public class ServiceEndpointConfigurationTest
//{
// private readonly Uri _uri = new Uri("http://www.google.com");
// private const string _testFilename = "testFilename.xml";
// /// <summary>
// ///A test for SaveConfigurationList
// ///</summary>
// [TestMethod]
// public void SaveAndLoadConfigurationListTest()
// {
// try
// {
// HttpEndpointConfiguration httpEndpoint = new HttpEndpointConfiguration("", _uri);
// OracleEndpointConfiguration oracleEndpoint = new OracleEndpointConfiguration("", "connection", "query", "result");
// List<IServiceEndpointConfiguration> serviceEndpointConfigurations
// = new List<IServiceEndpointConfiguration> { httpEndpoint, oracleEndpoint };
// IServiceEndpointConfiguration.SaveConfigurationList(serviceEndpointConfigurations, _testFilename);
// // load the results
// List<IServiceEndpointConfiguration> loadedList = IServiceEndpointConfiguration.LoadConfigurationList(_testFilename);
// // verify that they're the same
// foreach (IServiceEndpointConfiguration serviceEndpointConfiguration in serviceEndpointConfigurations)
// {
// IServiceEndpointConfiguration tmp = serviceEndpointConfiguration;
// IServiceEndpointConfiguration foundConfig
// = loadedList.Find(loadedEndpointConfig => loadedEndpointConfig.Equals(tmp));
// Assert.IsNotNull(foundConfig);
// }
// }
// finally
// {
// FileInfo f = new FileInfo(_testFilename);
// // f.CopyTo(@"c:\test.xml");
// if (f.Exists)
// f.Delete();
// }
// }
//}
}
+62
View File
@@ -0,0 +1,62 @@
using Endpoint;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace EndpointTest
{
/// <summary>
/// Functional Tests for SoapEndpoint
/// </summary>
[TestClass]
public class SoapEndpointTest
{
// Random internet webservice
private const string URISTRING = @"http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php";
private const string SOAPACTION =
@"http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl#GmlTimeSeries";
private const string SOAPREQUEST =
@"<soapenv:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ndf=""http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl"">"
+ @" <soapenv:Header/>"
+ @" <soapenv:Body>"
+ @" <ndf:GmlTimeSeries soapenv:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">"
+ @" <listLatLon xsi:type=""dwml:listLatLonType"" xmlns:dwml=""http://www.weather.gov/forecasts/xml/DWMLgen/schema/DWML.xsd"">?</listLatLon>"
+ @" <startTime xsi:type=""xsd:dateTime"">?</startTime>"
+ @" <endTime xsi:type=""xsd:dateTime"">?</endTime>"
+ @" <compType xsi:type=""dwml:compTypeType"" xmlns:dwml=""http://www.weather.gov/forecasts/xml/DWMLgen/schema/DWML.xsd"">?</compType>"
+ @" <featureType xsi:type=""dwml:featureTypeType"" xmlns:dwml=""http://www.weather.gov/forecasts/xml/DWMLgen/schema/DWML.xsd"">?</featureType>"
+ @" <propertyName xsi:type=""xsd:string"">?</propertyName>"
+ @" </ndf:GmlTimeSeries>"
+ @" </soapenv:Body>"
+ @"</soapenv:Envelope>";
private const string XPATHNAMESPACES =
@"a,http://www.opengis.net/ows";
private const string XPATHQUERY =
@"//a:Exception[1]/@ExceptionText";
private const string EXPECTEDXPATHRESULT =
@"VERSION key not found";
/// <summary>
/// Runs GetStatus
/// </summary>
[TestMethod]
public void GetStatusTest()
{
var target = new SoapEndpoint
{
UriString = URISTRING,
XpathQuery = XPATHQUERY,
ExpectedXpathResult = EXPECTEDXPATHRESULT,
SoapAction = SOAPACTION,
SoapRequest = SOAPREQUEST,
XpathNamespaces = XPATHNAMESPACES
};
var status = target.GetStatus();
Assert.AreEqual(Status.Up, status);
}
}
}
@@ -0,0 +1,32 @@
using Endpoint;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace EndpointTest
{
/// <summary>
/// Tests for WindowsServiceEndpoint
/// </summary>
[TestClass]
public class WindowsServiceEndpointTest
{
/// <summary>
/// Use a service that should always be running on localhost
/// </summary>
private const string SERVICENAME = "Windows Time";
/// <summary>
/// Runs GetStatus
/// </summary>
[TestMethod]
public void GetStatusTest()
{
var target = new WindowsServiceEndpoint
{
ServiceName = SERVICENAME
};
var status = target.GetStatus();
Assert.AreEqual(Status.Up, status);
}
}
}
+141
View File
@@ -0,0 +1,141 @@
using Endpoint;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace EndpointTest
{
/// <summary>
/// Tests for WmiEndpoint
/// </summary>
[TestClass]
public class WmiEndpointTest
{
private const string MACHINENAME = @"\\localhost";
/// <summary>
/// Run GetStatus using "UpResult" expecting an up status.
/// </summary>
[TestMethod]
public void GetStatusUpPositiveTest()
{
var target = new WmiEndpoint
{
MachineName = MACHINENAME,
ObjectQueryString = "Select * from Win32_Process",
ResultPropertyName = "Name",
UpResult = "System Idle Process"
};
var status = target.GetStatus();
Assert.AreEqual(Status.Up, status);
Assert.AreEqual("System Idle Process", target.StatusDescription);
}
/// <summary>
/// Run GetStatus using "UpResult" expecting an error status.
/// </summary>
[TestMethod]
public void GetStatusUpNegativeTest()
{
var target = new WmiEndpoint
{
MachineName = MACHINENAME,
ObjectQueryString = "Select * from Win32_Process",
ResultPropertyName = "Name",
UpResult = "Not A Real Process"
};
var status = target.GetStatus();
Assert.AreEqual(Status.Error, status);
}
/// <summary>
/// Run GetStatus using "ErrorResult" expecting an error status.
/// </summary>
[TestMethod]
public void GetStatusErrorPositiveTest()
{
var target = new WmiEndpoint
{
MachineName = MACHINENAME,
ObjectQueryString = "Select * from Win32_Process",
ResultPropertyName = "Name",
ErrorResult = "System Idle Process"
};
var status = target.GetStatus();
Assert.AreEqual(Status.Error, status);
}
/// <summary>
/// Run GetStatus using "MinimumThreshold" expecting an up status.
/// </summary>
[TestMethod]
public void GetStatusMinimumThresholdPositiveTest()
{
var target = new WmiEndpoint
{
MachineName = MACHINENAME,
ObjectQueryString = "select FreeSpace from Win32_LogicalDisk where DeviceID='C:'",
ResultPropertyName = "FreeSpace",
MinimumThreshold = 10 // assume you have more than 10B free on C:
};
var status = target.GetStatus();
Assert.AreEqual(Status.Up, status);
}
/// <summary>
/// Run GetStatus using "MinimumThreshold" expecting an up status.
/// </summary>
[TestMethod]
public void GetStatusMinimumThresholdNegativeTest()
{
var target = new WmiEndpoint
{
MachineName = MACHINENAME,
ObjectQueryString = "select FreeSpace from Win32_LogicalDisk where DeviceID='C:'",
ResultPropertyName = "FreeSpace",
MinimumThreshold = 1e15 // assume you have less than a petabyte free on C:
};
var status = target.GetStatus();
Assert.AreEqual(Status.Error, status);
}
/// <summary>
/// Run GetStatus using "MaximumThreshold" expecting an up status.
/// </summary>
[TestMethod]
public void GetStatusMaximumThresholdPositiveTest()
{
var target = new WmiEndpoint
{
MachineName = MACHINENAME,
ObjectQueryString = "select FreeSpace from Win32_LogicalDisk where DeviceID='C:'",
ResultPropertyName = "FreeSpace",
MaximumThreshold = 1e15 // assume you have less than a petabyte free on C:
};
var status = target.GetStatus();
Assert.AreEqual(Status.Up, status);
}
/// <summary>
/// Run GetStatus using "MaximumThreshold" expecting an up status.
/// </summary>
[TestMethod]
public void GetStatusMaximumThresholdNegativeTest()
{
var target = new WmiEndpoint
{
MachineName = MACHINENAME,
ObjectQueryString = "select FreeSpace from Win32_LogicalDisk where DeviceID='C:'",
ResultPropertyName = "FreeSpace",
MaximumThreshold = 10 // assume you have less than a 10B free on C:
};
var status = target.GetStatus();
Assert.AreEqual(Status.Error, status);
}
}
}