mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Began creating unit tests for RemoteDesktopConnectionDeserializer
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNGTests.Properties;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers
|
||||
{
|
||||
public class RemoteDesktopConnectionDeserializerTests
|
||||
{
|
||||
// .rdp file schema: https://technet.microsoft.com/en-us/library/ff393699(v=ws.10).aspx
|
||||
private string[] _connectionFileContents;
|
||||
private RemoteDesktopConnectionDeserializer _deserializer;
|
||||
private ConnectionTreeModel _connectionTreeModel;
|
||||
private const string ExpectedHostname = "testhostname.domain.com";
|
||||
private const string ExpectedUserName = "myusernamehere";
|
||||
private const string ExpectedDomain = "myspecialdomain";
|
||||
private const string ExpectedGatewayHostname = "gatewayhostname.domain.com";
|
||||
private const int ExpectedPort = 9933;
|
||||
private const ProtocolRDP.RDPColors ExpectedColors = ProtocolRDP.RDPColors.Colors24Bit;
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void OnetimeSetup()
|
||||
{
|
||||
_connectionFileContents = Resources.test_remotedesktopconnection_rdp.Split(Environment.NewLine.ToCharArray());
|
||||
_deserializer = new RemoteDesktopConnectionDeserializer(_connectionFileContents);
|
||||
_connectionTreeModel = _deserializer.Deserialize();
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void OnetimeTeardown()
|
||||
{
|
||||
_deserializer = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConnectionTreeModelHasARootNode()
|
||||
{
|
||||
var numberOfRootNodes = _connectionTreeModel.RootNodes.Count;
|
||||
Assert.That(numberOfRootNodes, Is.GreaterThan(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RootNodeHasConnectionInfo()
|
||||
{
|
||||
var rootNodeContents = _connectionTreeModel.RootNodes.First().Children.OfType<ConnectionInfo>();
|
||||
Assert.That(rootNodeContents, Is.Not.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HostnameImportedCorrectly()
|
||||
{
|
||||
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
|
||||
Assert.That(connectionInfo.Hostname, Is.EqualTo(ExpectedHostname));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PortImportedCorrectly()
|
||||
{
|
||||
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
|
||||
Assert.That(connectionInfo.Port, Is.EqualTo(ExpectedPort));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UsernameImportedCorrectly()
|
||||
{
|
||||
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
|
||||
Assert.That(connectionInfo.Username, Is.EqualTo(ExpectedUserName));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DomainImportedCorrectly()
|
||||
{
|
||||
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
|
||||
Assert.That(connectionInfo.Domain, Is.EqualTo(ExpectedDomain));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RdpColorsImportedCorrectly()
|
||||
{
|
||||
var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
|
||||
Assert.That(connectionInfo.Colors, Is.EqualTo(ExpectedColors));
|
||||
}
|
||||
|
||||
//[Test]
|
||||
//public void GatewayHostnameImportedCorrectly()
|
||||
//{
|
||||
// var connectionInfo = _connectionTreeModel.RootNodes.First().Children.First();
|
||||
// Assert.That(connectionInfo.RDGatewayHostname, Is.EqualTo(_expectedGatewayHostname));
|
||||
//}
|
||||
}
|
||||
}
|
||||
31
mRemoteNGTests/Properties/Resources.Designer.cs
generated
31
mRemoteNGTests/Properties/Resources.Designer.cs
generated
@@ -60,6 +60,37 @@ namespace mRemoteNGTests.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to screen mode id:i:2
|
||||
///use multimon:i:0
|
||||
///desktopwidth:i:800
|
||||
///desktopheight:i:600
|
||||
///session bpp:i:32
|
||||
///winposstr:s:0,3,0,0,800,600
|
||||
///compression:i:1
|
||||
///keyboardhook:i:2
|
||||
///audiocapturemode:i:0
|
||||
///videoplaybackmode:i:1
|
||||
///connection type:i:7
|
||||
///networkautodetect:i:1
|
||||
///bandwidthautodetect:i:1
|
||||
///displayconnectionbar:i:1
|
||||
///username:s:myusernamehere
|
||||
///enableworkspacereconnect:i:0
|
||||
///disable wallpaper:i:0
|
||||
///allow font smoothing:i:0
|
||||
///allow desktop composition:i:0
|
||||
///disable full window drag:i:1
|
||||
///disable menu anims:i:1
|
||||
///disable themes:i:0
|
||||
/// [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string test_remotedesktopconnection_rdp {
|
||||
get {
|
||||
return ResourceManager.GetString("test_remotedesktopconnection_rdp", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?>
|
||||
///<Connections Name="Connections" Export="False" Protected="95syzRuZ4mRxpNkZQzoyX8SDpQXLyMq3GncO8o4SyTBoYvn3TAWgn05ZEU2DrjkM" ConfVersion="2.5">
|
||||
|
||||
@@ -121,4 +121,7 @@
|
||||
<data name="TestConfCons" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\TestConfCons.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
<data name="test_remotedesktopconnection_rdp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\test_remotedesktopconnection.rdp.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
|
||||
</data>
|
||||
</root>
|
||||
BIN
mRemoteNGTests/Resources/test_remotedesktopconnection.rdp.txt
Normal file
BIN
mRemoteNGTests/Resources/test_remotedesktopconnection.rdp.txt
Normal file
Binary file not shown.
@@ -108,6 +108,7 @@
|
||||
<Compile Include="BinaryFileTests.cs" />
|
||||
<Compile Include="Config\Connections\DataTableSerializerTests.cs" />
|
||||
<Compile Include="Config\Connections\XmlConnectionsDeserializerTests.cs" />
|
||||
<Compile Include="Config\Serializers\RemoteDesktopConnectionDeserializerTests.cs" />
|
||||
<Compile Include="Connection\AbstractConnectionInfoDataTests.cs" />
|
||||
<Compile Include="Tree\ConnectionTreeDragAndDropHandlerTests.cs" />
|
||||
<Compile Include="Tree\ConnectionTreeModelTests.cs" />
|
||||
@@ -145,6 +146,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Resources\test_remotedesktopconnection.rdp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\mRemoteV1\mRemoteV1.csproj">
|
||||
@@ -163,6 +165,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\TestConfCons.xml" />
|
||||
<None Include="Resources\test_remotedesktopconnection.rdp.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Choose>
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
{
|
||||
public class RemoteDesktopConnectionDeserializer : IDeserializer
|
||||
{
|
||||
// .rdp file schema: https://technet.microsoft.com/en-us/library/ff393699(v=ws.10).aspx
|
||||
private readonly string[] _fileContent;
|
||||
|
||||
public RemoteDesktopConnectionDeserializer(string[] fileContent)
|
||||
|
||||
Reference in New Issue
Block a user