Initial project commit
This commit is contained in:
41
TorLibraryTest/App.config
Normal file
41
TorLibraryTest/App.config
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<system.diagnostics>
|
||||
<trace autoflush="true" />
|
||||
<sources>
|
||||
<source name="System.Net">
|
||||
<listeners>
|
||||
<add name="System.Net"/>
|
||||
</listeners>
|
||||
</source>
|
||||
<source name="System.Net.HttpListener">
|
||||
<listeners>
|
||||
<add name="System.Net"/>
|
||||
</listeners>
|
||||
</source>
|
||||
<source name="System.Net.Sockets">
|
||||
<listeners>
|
||||
<add name="System.Net"/>
|
||||
</listeners>
|
||||
</source>
|
||||
<source name="System.Net.Cache">
|
||||
<listeners>
|
||||
<add name="System.Net"/>
|
||||
</listeners>
|
||||
</source>
|
||||
</sources>
|
||||
<sharedListeners>
|
||||
<add
|
||||
name="System.Net"
|
||||
type="System.Diagnostics.TextWriterTraceListener"
|
||||
initializeData="C:\\TorTrace.log" traceOutputOptions = "DateTime" />
|
||||
</sharedListeners>
|
||||
<switches>
|
||||
<add name="System.Net" value="Verbose" />
|
||||
<add name="System.Net.Sockets" value="Verbose" />
|
||||
<add name="System.Net.Cache" value="Verbose" />
|
||||
<add name="System.Net.HttpListener" value="Verbose" />
|
||||
</switches>
|
||||
</system.diagnostics>
|
||||
|
||||
</configuration>
|
||||
111
TorLibraryTest/ControlConnectionUnitTests.cs
Normal file
111
TorLibraryTest/ControlConnectionUnitTests.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using TorControlLibrary;
|
||||
using TorControlLibrary.Responses;
|
||||
using System.Threading;
|
||||
using Hermes.Objects;
|
||||
|
||||
namespace TorLibraryTest
|
||||
{
|
||||
[TestClass]
|
||||
public class ControlConnectionUnitTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void Connect()
|
||||
{
|
||||
ControlConnection connection = new ControlConnection();
|
||||
connection.Connect();
|
||||
connection.Close();
|
||||
}
|
||||
[TestMethod]
|
||||
public void GetCircuitStatuses()
|
||||
{
|
||||
ControlConnection connection = new ControlConnection();
|
||||
connection.Connect();
|
||||
List<CircuitStatusResponse> circuits = connection.GetCircuitStatuses();
|
||||
connection.Close();
|
||||
}
|
||||
[TestMethod]
|
||||
public void GetStreamStatuses()
|
||||
{
|
||||
ControlConnection connection = new ControlConnection();
|
||||
connection.Connect();
|
||||
List<StreamStatusResponse> circuits = connection.GetStreamStatuses();
|
||||
connection.Close();
|
||||
}
|
||||
[TestMethod]
|
||||
public void GetRouterStatuses()
|
||||
{
|
||||
ControlConnection connection = new ControlConnection();
|
||||
connection.Connect();
|
||||
List<RouterStatusResponse> routerInfo = connection.GetAllRouterStatusInfo();
|
||||
connection.Close();
|
||||
}
|
||||
[TestMethod]
|
||||
public void GetRouterStatusByName()
|
||||
{
|
||||
ControlConnection connection = new ControlConnection();
|
||||
connection.Connect();
|
||||
RouterStatusResponse routerInfo = connection.GetRouterStatusInfoByNickname("moria1");
|
||||
connection.Close();
|
||||
Assert.AreEqual("moria1", routerInfo.NickName);
|
||||
}
|
||||
[TestMethod]
|
||||
public void GetRouterDescriptionByName()
|
||||
{
|
||||
ControlConnection connection = new ControlConnection();
|
||||
connection.Connect();
|
||||
RouterDescription routerInfo = connection.GetRouterDescriptionByNickname("desync");
|
||||
connection.Close();
|
||||
Assert.AreEqual("desync", routerInfo.NickName);
|
||||
}
|
||||
[TestMethod]
|
||||
public void GetRouterStatusByID()
|
||||
{
|
||||
ControlConnection connection = new ControlConnection();
|
||||
connection.Connect();
|
||||
RouterStatusResponse routerInfo = connection.GetRouterStatusInfoByID("03C0FB35B3A0D3D12410475C5FDB8F525B7342CD");
|
||||
connection.Close();
|
||||
Assert.AreEqual("zagon", routerInfo.NickName);
|
||||
}
|
||||
[TestMethod]
|
||||
public void SendRawCommand()
|
||||
{
|
||||
ControlConnection connection = new ControlConnection();
|
||||
connection.Connect();
|
||||
CommandResponse resp = connection.SendRawCommand("getinfo version");
|
||||
Assert.AreEqual(250, resp.StatusCode);
|
||||
Assert.IsTrue(resp.Response.Contains("version"));
|
||||
}
|
||||
[TestMethod]
|
||||
public void SimpleEventTest()
|
||||
{
|
||||
ControlConnection connection = new ControlConnection();
|
||||
connection.Connect();
|
||||
connection.ServerEvent += new Action<EventResponse>(connection_ServerEvent);
|
||||
connection.SendRawCommand("SETEVENTS BW");
|
||||
Assert.IsTrue(eventTest.WaitOne(60000));
|
||||
connection.Close();
|
||||
}
|
||||
[TestMethod]
|
||||
public void SocksTest()
|
||||
{
|
||||
Socks5Stream stream = new Socks5Stream("localhost", 9050, "www.google.com", 80);
|
||||
System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
|
||||
System.IO.StreamReader reader = new System.IO.StreamReader(stream);
|
||||
writer.Write("GET / HTTP 1.1\r\nHost: www.google.com\r\n\r\n");
|
||||
writer.Flush();
|
||||
String results = reader.ReadLine();
|
||||
}
|
||||
|
||||
void connection_ServerEvent(EventResponse obj)
|
||||
{
|
||||
if (obj.EventType.Equals("BW"))
|
||||
eventTest.Set();
|
||||
}
|
||||
private AutoResetEvent eventTest = new AutoResetEvent(false);
|
||||
}
|
||||
}
|
||||
35
TorLibraryTest/Properties/AssemblyInfo.cs
Normal file
35
TorLibraryTest/Properties/AssemblyInfo.cs
Normal 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("TorLibraryTest")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("TorLibraryTest")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. 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("e3648bd4-b12a-46ee-8dda-e53d4ed94cd5")]
|
||||
|
||||
// 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 Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
72
TorLibraryTest/TorLibraryTest.csproj
Normal file
72
TorLibraryTest/TorLibraryTest.csproj
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{020A074C-B1F5-498A-8C1D-B1D90C79D50D}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TorLibraryTest</RootNamespace>
|
||||
<AssemblyName>TorLibraryTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
</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>
|
||||
</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>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
|
||||
<Visible>False</Visible>
|
||||
</CodeAnalysisDependentAssemblyPaths>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ControlConnectionUnitTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hermes\Hermes.csproj">
|
||||
<Project>{3DE6415A-1DED-4F75-9202-39BDF012BB5A}</Project>
|
||||
<Name>Hermes</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TorControlLibrary\TorControlLibrary.csproj">
|
||||
<Project>{EF216A86-F64F-4C76-9A86-EEE8E5484EF9}</Project>
|
||||
<Name>TorControlLibrary</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</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>
|
||||
Reference in New Issue
Block a user