mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
finished updating some tests for default inheritance
This commit is contained in:
@@ -26,19 +26,6 @@ namespace mRemoteNGTests.Connection
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
//TODO - finish test
|
||||
//[TestCaseSource(nameof(GetInheritanceProperties))]
|
||||
public void LoadingDefaultInfoUpdatesAllInheritanceProperties(PropertyInfo property)
|
||||
{
|
||||
DefaultConnectionInfo.Instance.Inheritance.TurnOffInheritanceCompletely();
|
||||
_randomizedConnectionInfo.Inheritance.TurnOnInheritanceCompletely();
|
||||
|
||||
DefaultConnectionInfo.Instance.LoadFrom(_randomizedConnectionInfo);
|
||||
var valueInDestination = property.GetValue(DefaultConnectionInfo.Instance.Inheritance);
|
||||
var valueInSource = property.GetValue(_randomizedConnectionInfo.Inheritance);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(GetConnectionInfoProperties))]
|
||||
public void SavingDefaultConnectionInfoExportsAllProperties(PropertyInfo property)
|
||||
{
|
||||
@@ -67,14 +54,9 @@ namespace mRemoteNGTests.Connection
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
private static IEnumerable<PropertyInfo> GetConnectionInfoProperties()
|
||||
private static IEnumerable<PropertyInfo> GetConnectionInfoProperties()
|
||||
{
|
||||
return new ConnectionInfo().GetSerializableProperties();
|
||||
}
|
||||
|
||||
private static IEnumerable<PropertyInfo> GetInheritanceProperties()
|
||||
{
|
||||
return new ConnectionInfoInheritance(new object(), true).GetProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,40 @@
|
||||
using mRemoteNG.Connection;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using mRemoteNG.Connection;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
namespace mRemoteNGTests.Connection
|
||||
{
|
||||
public class DefaultConnectionInheritanceTests
|
||||
public class DefaultConnectionInheritanceTests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
[TestCaseSource(nameof(GetInheritanceProperties))]
|
||||
public void LoadingDefaultInheritanceUpdatesAllProperties(PropertyInfo property)
|
||||
{
|
||||
DefaultConnectionInheritance.Instance.TurnOffInheritanceCompletely();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadingDefaultInheritanceUpdatesAllProperties()
|
||||
{
|
||||
var inheritanceSource = new ConnectionInfoInheritance(new object(), true);
|
||||
var inheritanceSource = new ConnectionInfoInheritance(new object(), true);
|
||||
inheritanceSource.TurnOnInheritanceCompletely();
|
||||
DefaultConnectionInheritance.Instance.LoadFrom(inheritanceSource);
|
||||
Assert.That(DefaultConnectionInheritance.Instance.EverythingInherited, Is.True);
|
||||
}
|
||||
DefaultConnectionInheritance.Instance.TurnOffInheritanceCompletely();
|
||||
|
||||
[Test]
|
||||
public void SavingDefaultInheritanceExportsAllProperties()
|
||||
DefaultConnectionInheritance.Instance.LoadFrom(inheritanceSource);
|
||||
|
||||
var valueInDestination = property.GetValue(DefaultConnectionInheritance.Instance);
|
||||
var valueInSource = property.GetValue(inheritanceSource);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(GetInheritanceProperties))]
|
||||
public void SavingDefaultInheritanceExportsAllProperties(PropertyInfo property)
|
||||
{
|
||||
var inheritanceDestination = new ConnectionInfoInheritance(new object(), true);
|
||||
DefaultConnectionInheritance.Instance.AutomaticResize = true;
|
||||
DefaultConnectionInheritance.Instance.SaveTo(inheritanceDestination);
|
||||
Assert.That(inheritanceDestination.AutomaticResize, Is.True);
|
||||
}
|
||||
var saveTarget = new ConnectionInfoInheritance(new object(), true);
|
||||
saveTarget.TurnOffInheritanceCompletely();
|
||||
DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();
|
||||
|
||||
DefaultConnectionInheritance.Instance.SaveTo(saveTarget);
|
||||
|
||||
var valueInDestination = property.GetValue(saveTarget);
|
||||
var valueInSource = property.GetValue(DefaultConnectionInheritance.Instance);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NewInheritanceInstancesCreatedWithDefaultInheritanceValues()
|
||||
@@ -38,12 +44,20 @@ namespace mRemoteNGTests.Connection
|
||||
Assert.That(inheritanceInstance.Domain, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NewInheritanceInstancesCreatedWithAllDefaultInheritanceValues()
|
||||
[TestCaseSource(nameof(GetInheritanceProperties))]
|
||||
public void NewInheritanceInstancesCreatedWithAllDefaultInheritanceValues(PropertyInfo property)
|
||||
{
|
||||
DefaultConnectionInheritance.Instance.TurnOnInheritanceCompletely();
|
||||
var inheritanceInstance = new ConnectionInfoInheritance(new object());
|
||||
Assert.That(inheritanceInstance.EverythingInherited, Is.True);
|
||||
}
|
||||
}
|
||||
|
||||
var valueInDestination = property.GetValue(inheritanceInstance);
|
||||
var valueInSource = property.GetValue(DefaultConnectionInheritance.Instance);
|
||||
Assert.That(valueInDestination, Is.EqualTo(valueInSource));
|
||||
}
|
||||
|
||||
private static IEnumerable<PropertyInfo> GetInheritanceProperties()
|
||||
{
|
||||
return new ConnectionInfoInheritance(new object(), true).GetProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Tree
|
||||
{
|
||||
public class NodeSearcherTests
|
||||
public class NodeSearcherTests
|
||||
{
|
||||
private NodeSearcher _nodeSearcher;
|
||||
private ContainerInfo _folder1;
|
||||
@@ -104,6 +104,14 @@ namespace mRemoteNGTests.Tree
|
||||
_con4 = new ConnectionInfo { Name = "con4", Description="description6", Hostname="hostname6" };
|
||||
_con5 = new ConnectionInfo { Name = "con5", Description="description7", Hostname="hostname7" };
|
||||
|
||||
_folder1.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con1.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con2.Inheritance.TurnOffInheritanceCompletely();
|
||||
_folder2.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con3.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con4.Inheritance.TurnOffInheritanceCompletely();
|
||||
_con5.Inheritance.TurnOffInheritanceCompletely();
|
||||
|
||||
connectionTreeModel.AddRootNode(root);
|
||||
root.AddChildRange(new [] { _folder1, _folder2, _con5 });
|
||||
_folder1.AddChildRange(new [] { _con1, _con2 });
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace mRemoteNG.Connection
|
||||
private DefaultConnectionInfo()
|
||||
{
|
||||
IsDefault = true;
|
||||
Inheritance = DefaultConnectionInheritance.Instance;
|
||||
}
|
||||
|
||||
public void LoadFrom<TSource>(TSource sourceInstance, Func<string, string> propertyNameMutator = null)
|
||||
|
||||
@@ -8,7 +8,7 @@ using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Tree
|
||||
{
|
||||
public sealed class ConnectionTreeModel : INotifyCollectionChanged, INotifyPropertyChanged
|
||||
public sealed class ConnectionTreeModel : INotifyCollectionChanged, INotifyPropertyChanged
|
||||
{
|
||||
public List<ContainerInfo> RootNodes { get; } = new List<ContainerInfo>();
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace mRemoteNG.Tree
|
||||
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, rootNode));
|
||||
}
|
||||
|
||||
public IEnumerable<ConnectionInfo> GetRecursiveChildList()
|
||||
public IReadOnlyList<ConnectionInfo> GetRecursiveChildList()
|
||||
{
|
||||
var list = new List<ConnectionInfo>();
|
||||
foreach (var rootNode in RootNodes)
|
||||
|
||||
@@ -5,7 +5,7 @@ using mRemoteNG.Connection;
|
||||
|
||||
namespace mRemoteNG.Tree
|
||||
{
|
||||
public class NodeSearcher
|
||||
public class NodeSearcher
|
||||
{
|
||||
private readonly ConnectionTreeModel _connectionTreeModel;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace mRemoteNG.Tree
|
||||
{
|
||||
ResetMatches();
|
||||
if (searchText == "") return Matches;
|
||||
var nodes = (List<ConnectionInfo>)_connectionTreeModel.GetRecursiveChildList();
|
||||
var nodes = _connectionTreeModel.GetRecursiveChildList();
|
||||
var searchTextLower = searchText.ToLowerInvariant();
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user