Fixing up unit tests

This commit is contained in:
Ian Dunkerly
2021-08-26 22:59:35 +01:00
parent 5ed78cc3b6
commit f77848e3d9
21 changed files with 176 additions and 192 deletions

View File

@@ -32,9 +32,12 @@
//Contributed by: Ian Cooper
using System;
using System.Collections;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;
using NUnit.Extensions.Forms;
using mRemoteNGTests.TestHelpers;
namespace mRemoteNGTests
{
@@ -44,8 +47,11 @@ namespace mRemoteNGTests
/// <remarks>
/// It includes helper methods for selecting items from the list
/// and for clearing those selections.</remarks>
public class ListViewTester : ControlTester
public class ListViewTester
{
private readonly string _name;
private readonly Form _form;
/// <summary>
/// Creates a ControlTester from the control name and the form instance.
/// </summary>
@@ -56,62 +62,11 @@ namespace mRemoteNGTests
/// <param name="name">The Control name.</param>
/// <param name="form">The Form instance.</param>
public ListViewTester(string name, Form form)
: base(name, form)
{
_name = name;
_form = form;
}
/// <summary>
/// Creates a ControlTester from the control name and the form name.
/// </summary>
/// <remarks>
/// It is best to use the overloaded Constructor that requires just the name
/// parameter if possible.
/// </remarks>
/// <param name="name">The Control name.</param>
/// <param name="formName">The Form name..</param>
public ListViewTester(string name, string formName)
: base(name, formName)
{
}
/// <summary>
/// Creates a ControlTester from the control name.
/// </summary>
/// <remarks>
/// This is the best constructor.</remarks>
/// <param name="name">The Control name.</param>
public ListViewTester(string name)
: base(name)
{
}
/// <summary>
/// Creates a ControlTester from a ControlTester and an index where the
/// original tester's name is not unique.
/// </summary>
/// <remarks>
/// It is best to use the overloaded Constructor that requires just the name
/// parameter if possible.
/// </remarks>
/// <param name="tester">The ControlTester.</param>
/// <param name="index">The index to test.</param>
public ListViewTester(ControlTester tester, int index)
: base(tester, index)
{
}
/// <summary>
/// Allows you to find a ListViewTester by index where the name is not unique.
/// </summary>
/// <remarks>
/// This was added to support the ability to find controls where their name is
/// not unique. If all of your controls are uniquely named (I recommend this) then
/// you will not need this.
/// </remarks>
/// <value>The ControlTester at the specified index.</value>
/// <param name="index">The index of the ListViewTester.</param>
public new ListViewTester this[int index] => new ListViewTester(this, index);
/// <summary>
/// Provides access to all of the Properties of the ListBox.
/// </summary>
@@ -119,7 +74,7 @@ namespace mRemoteNGTests
/// Allows typed access to all of the properties of the underlying control.
/// </remarks>
/// <value>The underlying control.</value>
public ListView Properties => (ListView)Control;
public ListView Properties => _form.FindControl<ListView>(_name);
/// <summary>
/// Helper method to return the List View's Items property
@@ -149,9 +104,17 @@ namespace mRemoteNGTests
public void Select(int i)
{
Properties.Items[i].Selected = true;
FireEvent("ItemActivate");
}
private void FireEvent(string eventName)
{
var ctrl = Properties;
MethodInfo method = typeof(ListView).GetMethod("On" + eventName, BindingFlags.Instance | BindingFlags.NonPublic);
method.Invoke(ctrl, new object[] { EventArgs.Empty });
}
/// <summary>
/// Selects an item in the list according to its string value.
/// </summary>

View File

@@ -1,28 +0,0 @@
using System.Windows.Forms;
using mRemoteNG.UI.Controls;
using NUnit.Extensions.Forms;
namespace mRemoteNGTests.NUnitExtensions
{
public class SecureTextBoxTester : ControlTester
{
public SecureTextBoxTester(string name, string formName) : base(name, formName)
{
}
public SecureTextBoxTester(string name, Form form) : base(name, form)
{
}
public SecureTextBoxTester(string name) : base(name)
{
}
public SecureTextBoxTester(ControlTester tester, int index) : base(tester, index)
{
}
public SecureTextBox Properties => (SecureTextBox) Control;
}
}

View File

@@ -112,12 +112,12 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="beta_update" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\beta-update.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
@@ -154,6 +154,9 @@
<data name="dev_update_portable" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\dev-update-portable.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="TestImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\testimage.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="test_puttyConnectionManager_database" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\test_puttyConnectionManager_database.dat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
</data>

View File

@@ -0,0 +1,20 @@
using System.Linq;
using System.Windows.Forms;
namespace mRemoteNGTests.TestHelpers
{
public static class FormExtensions
{
/// <summary>
/// Finds a control with the specified name on a form.
/// </summary>
/// <typeparam name="T">The type of control to find.</typeparam>
/// <param name="form">The form.</param>
/// <param name="name">The name of the control to find.</param>
/// <returns>The control or null if not found or the wrong type.</returns>
public static T FindControl<T>(this Form form, string name) where T : Control
{
return form.Controls.Find(name, true).SingleOrDefault() as T;
}
}
}

View File

@@ -1,9 +1,10 @@
using mRemoteNG.Security;
using mRemoteNGTests.NUnitExtensions;
using System.Threading;
using mRemoteNG.Security;
using NUnit.Framework;
namespace mRemoteNGTests.UI.Controls
{
[Apartment(ApartmentState.STA)]
public class SecureTextBoxTests
{
private SecureTextBoxTestForm _testForm;
@@ -26,10 +27,10 @@ namespace mRemoteNGTests.UI.Controls
[Test]
public void TextboxInputGetsAddedToSecureString()
{
var textBox = new SecureTextBoxTester(_testForm.secureTextBox1.Name);
var textBox = _testForm.secureTextBox1;
const string textToSend = "abc123";
textBox.Properties.Text = textToSend;
Assert.That(textBox.Properties.SecString.ConvertToUnsecureString(), Is.EqualTo(textToSend));
textBox.Text = textToSend;
Assert.That(textBox.SecString.ConvertToUnsecureString(), Is.EqualTo(textToSend));
}
}
}

View File

@@ -1,10 +1,11 @@
using mRemoteNG.UI;
using NUnit.Extensions.Forms;
using System.Threading;
using mRemoteNG.UI;
using NUnit.Framework;
namespace mRemoteNGTests.UI.Controls
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public class TextBoxExtensionsTests
{
private TextBoxExtensionsTestForm _textBoxExtensionsTestForm;
@@ -29,17 +30,17 @@ namespace mRemoteNGTests.UI.Controls
public void SetCueBannerSetsTheBannerText()
{
const string text = "Type Here";
var textBox = new TextBoxTester(_textBoxExtensionsTestForm.textBox1.Name);
Assert.That(textBox.Properties.SetCueBannerText(text), Is.True);
var textBox = _textBoxExtensionsTestForm.textBox1;
Assert.That(textBox.SetCueBannerText(text), Is.True);
}
[Test]
public void GetCueBannerReturnsCorrectValue()
{
const string text = "Type Here";
var textBox = new TextBoxTester(_textBoxExtensionsTestForm.textBox1.Name);
textBox.Properties.SetCueBannerText(text);
Assert.That(textBox.Properties.GetCueBannerText(), Is.EqualTo(text));
var textBox = _textBoxExtensionsTestForm.textBox1;
textBox.SetCueBannerText(text);
Assert.That(textBox.GetCueBannerText(), Is.EqualTo(text));
}
}
}

View File

@@ -1,15 +1,12 @@
using mRemoteNG.App;
using mRemoteNG.Messages;
using mRemoteNG.UI.Window;
using NUnit.Extensions.Forms;
using NUnit.Framework;
using System;
using NUnit.Framework;
using System.Threading;
using WeifenLuo.WinFormsUI.Docking;
using System.Windows.Forms;
using mRemoteNGTests.TestHelpers;
namespace mRemoteNGTests.UI.Forms
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public class OptionsFormTests : OptionsFormSetupAndTeardown
{
[Test]
@@ -17,26 +14,24 @@ namespace mRemoteNGTests.UI.Forms
{
bool eventFired = false;
_optionsForm.FormClosed += (o, e) => eventFired = true;
ButtonTester cancelButton = new ButtonTester("CancelButtonControl", _optionsForm);
cancelButton.Click();
Button cancelButton = _optionsForm.FindControl<Button>("btnCancel");
cancelButton.PerformClick();
Assert.That(eventFired, Is.True);
}
[Test]
public void ClickingOKButtonClosesTheForm()
public void ClickingOKButtonSetsDialogResult()
{
bool eventFired = false;
_optionsForm.FormClosed += (o, e) => eventFired = true;
ButtonTester cancelButton = new ButtonTester("OkButton", _optionsForm);
cancelButton.Click();
Assert.That(eventFired, Is.True);
Button cancelButton = _optionsForm.FindControl<Button>("btnOK");
cancelButton.PerformClick();
Assert.That(_optionsForm.DialogResult, Is.EqualTo(DialogResult.OK));
}
[Test]
public void ListViewContainsOptionsPages()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
Assert.That(listViewTester.Items.Count, Is.EqualTo(8));
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items.Count, Is.EqualTo(11));
}
}
}

View File

@@ -1,34 +1,36 @@
using System;
using System.Threading;
using System.Windows.Forms;
using mRemoteNGTests.TestHelpers;
using NUnit.Framework;
using mRemoteNGTests.UI.Forms;
using NUnit.Extensions.Forms;
namespace mRemoteNGTests.UI.Forms.OptionsPages
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public class OptionsAdvancedPageTests : OptionsFormSetupAndTeardown
{
[Test]
public void AdvancedPageLinkExistsInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
Assert.That(listViewTester.Items[7].Text, Does.Match("Advanced"));
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[10].Text, Does.Match("Advanced"));
}
[Test]
public void AdvancedIconShownInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
Assert.That(listViewTester.Items[7].ImageList, Is.Not.Null);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[10].ImageList, Is.Not.Null);
}
[Test]
public void SelectingAdvancedPageLoadsSettings()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
listViewTester.Select("Advanced");
CheckBoxTester checkboxTester = new CheckBoxTester("chkWriteLogFile", _optionsForm);
Assert.That(checkboxTester.Text, Does.Match("Write log file"));
CheckBox checkboxTester = _optionsForm.FindControl<CheckBox>("chkAutomaticReconnect");
Assert.That(checkboxTester.Text, Is.EqualTo("Automatically try to reconnect when disconnected from server (RDP && ICA only)"));
}
}
}

View File

@@ -1,33 +1,34 @@
using System;
using System.Threading;
using System.Windows.Forms;
using mRemoteNGTests.TestHelpers;
using NUnit.Framework;
using mRemoteNGTests.UI.Forms;
using NUnit.Extensions.Forms;
namespace mRemoteNGTests.UI.Forms.OptionsPages
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public class OptionsAppearancePageTests : OptionsFormSetupAndTeardown
{
[Test]
public void AppearancePageLinkExistsInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[1].Text, Does.Match("Appearance"));
}
[Test]
public void IconShownInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[1].ImageList, Is.Not.Null);
}
[Test]
public void SelectingAppearancePageLoadsSettings()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
listViewTester.Select("Appearance");
CheckBoxTester checkboxTester = new CheckBoxTester("chkShowSystemTrayIcon", _optionsForm);
CheckBox checkboxTester = _optionsForm.FindControl<CheckBox>("chkShowSystemTrayIcon");
Assert.That(checkboxTester.Text, Does.Match("show notification area icon"));
}
}

View File

@@ -1,33 +1,34 @@
using System;
using System.Threading;
using System.Windows.Forms;
using mRemoteNGTests.TestHelpers;
using NUnit.Framework;
using mRemoteNGTests.UI.Forms;
using NUnit.Extensions.Forms;
namespace mRemoteNGTests.UI.Forms.OptionsPages
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public class OptionsConnectionsPageTests : OptionsFormSetupAndTeardown
{
[Test]
public void ConnectionsPageLinkExistsInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
Assert.That(listViewTester.Items[3].Text, Does.Match("Connections"));
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[4].Text, Does.Match("Connections"));
}
[Test]
public void ConnectionsIconShownInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
Assert.That(listViewTester.Items[3].ImageList, Is.Not.Null);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[4].ImageList, Is.Not.Null);
}
[Test]
public void SelectingConnectionsPageLoadsSettings()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
listViewTester.Select("Connections");
CheckBoxTester checkboxTester = new CheckBoxTester("chkSingleClickOnConnectionOpensIt", _optionsForm);
CheckBox checkboxTester = _optionsForm.FindControl<CheckBox>("chkSingleClickOnConnectionOpensIt");
Assert.That(checkboxTester.Text, Does.Match("Single click on connection"));
}
}

View File

@@ -1,33 +1,34 @@
using System;
using System.Threading;
using System.Windows.Forms;
using mRemoteNGTests.TestHelpers;
using NUnit.Framework;
using mRemoteNGTests.UI.Forms;
using NUnit.Extensions.Forms;
namespace mRemoteNGTests.UI.Forms.OptionsPages
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public class OptionsSQLPageTests : OptionsFormSetupAndTeardown
{
[Test]
public void SQLPageLinkExistsInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
Assert.That(listViewTester.Items[4].Text, Does.Match("SQL Server"));
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[6].Text, Does.Match("SQL Server"));
}
[Test]
public void SQLIconShownInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
Assert.That(listViewTester.Items[4].ImageList, Is.Not.Null);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[6].ImageList, Is.Not.Null);
}
[Test]
public void SelectingSQLPageLoadsSettings()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
listViewTester.Select("SQL Server");
CheckBoxTester checkboxTester = new CheckBoxTester("chkUseSQLServer", _optionsForm);
CheckBox checkboxTester = _optionsForm.FindControl<CheckBox>("chkUseSQLServer");
Assert.That(checkboxTester.Text, Does.Match("Use SQL"));
}
}

View File

@@ -1,33 +1,34 @@
using System;
using System.Threading;
using System.Windows.Forms;
using mRemoteNGTests.TestHelpers;
using NUnit.Framework;
using mRemoteNGTests.UI.Forms;
using NUnit.Extensions.Forms;
namespace mRemoteNGTests.UI.Forms.OptionsPages
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public class OptionsStartupExitPageTests : OptionsFormSetupAndTeardown
{
[Test]
public void StartupExitPageLinkExistsInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[0].Text, Does.Match("Startup/Exit"));
}
[Test]
public void IconShownInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[0].ImageList, Is.Not.Null);
}
[Test]
public void SelectingStartupExitPageLoadsSettings()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
listViewTester.Select("Startup/Exit");
CheckBoxTester checkboxTester = new CheckBoxTester("chkSaveConsOnExit", _optionsForm);
CheckBox checkboxTester = _optionsForm.FindControl<CheckBox>("chkSaveConsOnExit");
Assert.That(checkboxTester.Text, Does.Match("Save connections"));
}
}

View File

@@ -1,31 +1,34 @@
using NUnit.Extensions.Forms;
using System.Threading;
using System.Windows.Forms;
using mRemoteNGTests.TestHelpers;
using NUnit.Framework;
namespace mRemoteNGTests.UI.Forms.OptionsPages
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public class OptionsTabsPanelPageTests : OptionsFormSetupAndTeardown
{
[Test]
public void TabsPanelPageLinkExistsInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[2].Text, Does.Match("Tabs & Panels"));
}
[Test]
public void TabsPanelIconShownInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[2].ImageList, Is.Not.Null);
}
[Test]
public void SelectingTabsPanelPageLoadsSettings()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
listViewTester.Select("Tabs & Panels");
CheckBoxTester checkboxTester = new CheckBoxTester("chkAlwaysShowPanelTabs", _optionsForm);
CheckBox checkboxTester = _optionsForm.FindControl<CheckBox>("chkAlwaysShowPanelTabs");
Assert.That(checkboxTester.Text, Does.Match("Always show panel tabs"));
}
}

View File

@@ -1,33 +1,34 @@
using System;
using System.Threading;
using System.Windows.Forms;
using mRemoteNGTests.TestHelpers;
using NUnit.Framework;
using mRemoteNGTests.UI.Forms;
using NUnit.Extensions.Forms;
namespace mRemoteNGTests.UI.Forms.OptionsPages
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public class OptionsThemePageTests : OptionsFormSetupAndTeardown
{
[Test]
public void ThemePageLinkExistsInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
Assert.That(listViewTester.Items[6].Text, Does.Match("Theme"));
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[8].Text, Does.Match("Theme"));
}
[Test]
public void ThemeIconShownInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
Assert.That(listViewTester.Items[6].ImageList, Is.Not.Null);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[8].ImageList, Is.Not.Null);
}
[Test]
public void SelectingThemePageLoadsSettings()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
listViewTester.Select("Theme");
ButtonTester buttonTester = new ButtonTester("btnThemeNew", _optionsForm);
Button buttonTester = _optionsForm.FindControl<Button>("btnThemeNew");
Assert.That(buttonTester.Text, Does.Match("New"));
}
}

View File

@@ -1,31 +1,34 @@
using NUnit.Framework;
using NUnit.Extensions.Forms;
using System.Threading;
using System.Windows.Forms;
using mRemoteNGTests.TestHelpers;
using NUnit.Framework;
namespace mRemoteNGTests.UI.Forms.OptionsPages
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public class OptionsUpdatesPageTests : OptionsFormSetupAndTeardown
{
[Test]
public void UpdatesPageLinkExistsInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
Assert.That(listViewTester.Items[5].Text, Does.Match("Updates"));
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[7].Text, Does.Match("Updates"));
}
[Test]
public void UpdatesIconShownInListView()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
Assert.That(listViewTester.Items[5].ImageList, Is.Not.Null);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
Assert.That(listViewTester.Items[7].ImageList, Is.Not.Null);
}
[Test]
public void SelectingUpdatesPageLoadsSettings()
{
ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm);
ListViewTester listViewTester = new ListViewTester("lstOptionPages", _optionsForm);
listViewTester.Select("Updates");
CheckBoxTester checkboxTester = new CheckBoxTester("chkCheckForUpdatesOnStartup", _optionsForm);
CheckBox checkboxTester = _optionsForm.FindControl<CheckBox>("chkCheckForUpdatesOnStartup");
Assert.That(checkboxTester.Text, Does.Match("Check for updates"));
}
}

View File

@@ -1,10 +1,13 @@
using mRemoteNG.UI.Forms;
using NUnit.Extensions.Forms;
using System.Threading;
using System.Windows.Forms;
using mRemoteNG.UI.Forms;
using mRemoteNGTests.TestHelpers;
using NUnit.Framework;
namespace mRemoteNGTests.UI.Forms
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public class PasswordFormTests
{
FrmPassword _passwordForm;
@@ -30,8 +33,7 @@ namespace mRemoteNGTests.UI.Forms
[SetUICulture("en-US")]
public void PasswordFormText()
{
var formTester = new FormTester("PasswordForm");
Assert.That(formTester.Text, Does.Match("mRemoteNG password"));
Assert.That(_passwordForm.Text, Does.Match("mRemoteNG password"));
}
[Test]
@@ -39,8 +41,8 @@ namespace mRemoteNGTests.UI.Forms
{
bool eventFired = false;
_passwordForm.FormClosed += (o, e) => eventFired = true;
ButtonTester cancelButton = new ButtonTester("btnCancel", _passwordForm);
cancelButton.Click();
Button cancelButton = _passwordForm.FindControl<Button>("btnCancel");
cancelButton.PerformClick();
Assert.That(eventFired, Is.True);
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.RDP;
@@ -12,6 +13,7 @@ using NUnit.Framework;
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
{
[Apartment(ApartmentState.STA)]
public class ConfigWindowGeneralTests
{
private ConfigWindow _configWindow;

View File

@@ -1,9 +1,11 @@
using mRemoteNG.Connection.Protocol;
using System.Threading;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.RDP;
using NUnit.Framework;
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
{
[Apartment(ApartmentState.STA)]
public class ConfigWindowRdpSpecialTests : ConfigWindowSpecialTestsBase
{
protected override ProtocolType Protocol => ProtocolType.RDP;

View File

@@ -1,9 +1,11 @@
using mRemoteNG.Connection.Protocol;
using System.Threading;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Connection.Protocol.VNC;
using NUnit.Framework;
namespace mRemoteNGTests.UI.Window.ConfigWindowTests
{
[Apartment(ApartmentState.STA)]
public class ConfigWindowVncSpecialTests : ConfigWindowSpecialTestsBase
{
protected override ProtocolType Protocol => ProtocolType.VNC;

View File

@@ -6,6 +6,7 @@ using WeifenLuo.WinFormsUI.Docking;
namespace mRemoteNGTests.UI.Window
{
[Apartment(ApartmentState.STA)]
public class ConnectionTreeWindowTests
{
private ConnectionTreeWindow _connectionTreeWindow;

View File

@@ -18,13 +18,11 @@
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit.Console" Version="3.12.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.12.0" />
<PackageReference Include="NUnit.Extensions" Version="2.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnitForms.Framework" Version="1.3.1" />
</ItemGroup>
<ItemGroup>
@@ -33,8 +31,17 @@
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>