mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 09:15:47 +00:00
continued line endings struggle ...
continued line endings struggle ...
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
Source = http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf
|
||||
Code = .\Renci.SshNet\Common\DerData.cs
|
||||
Source = http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf
|
||||
Code = .\Renci.SshNet\Common\DerData.cs
|
||||
Wiki = http://en.wikipedia.org/wiki/Distinguished_Encoding_Rules
|
||||
@@ -1,66 +1,66 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace Renci.SshNet
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of different extension method specific for .NET 3.5
|
||||
/// </summary>
|
||||
internal static partial class Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Disposes the specified socket.
|
||||
/// </summary>
|
||||
/// <param name="socket">The socket.</param>
|
||||
[DebuggerNonUserCode]
|
||||
internal static void Dispose(this Socket socket)
|
||||
{
|
||||
if (socket == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
socket.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the specified handle.
|
||||
/// </summary>
|
||||
/// <param name="handle">The handle.</param>
|
||||
[DebuggerNonUserCode]
|
||||
internal static void Dispose(this WaitHandle handle)
|
||||
{
|
||||
if (handle == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
handle.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the specified algorithm.
|
||||
/// </summary>
|
||||
/// <param name="algorithm">The algorithm.</param>
|
||||
[DebuggerNonUserCode]
|
||||
internal static void Dispose(this HashAlgorithm algorithm)
|
||||
{
|
||||
if (algorithm == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
algorithm.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the contents of the string builder.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The <see cref="StringBuilder"/> to clear.
|
||||
/// </param>
|
||||
public static void Clear(this StringBuilder value)
|
||||
{
|
||||
value.Length = 0;
|
||||
value.Capacity = 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace Renci.SshNet
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of different extension method specific for .NET 3.5
|
||||
/// </summary>
|
||||
internal static partial class Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Disposes the specified socket.
|
||||
/// </summary>
|
||||
/// <param name="socket">The socket.</param>
|
||||
[DebuggerNonUserCode]
|
||||
internal static void Dispose(this Socket socket)
|
||||
{
|
||||
if (socket == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
socket.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the specified handle.
|
||||
/// </summary>
|
||||
/// <param name="handle">The handle.</param>
|
||||
[DebuggerNonUserCode]
|
||||
internal static void Dispose(this WaitHandle handle)
|
||||
{
|
||||
if (handle == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
handle.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the specified algorithm.
|
||||
/// </summary>
|
||||
/// <param name="algorithm">The algorithm.</param>
|
||||
[DebuggerNonUserCode]
|
||||
internal static void Dispose(this HashAlgorithm algorithm)
|
||||
{
|
||||
if (algorithm == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
algorithm.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the contents of the string builder.
|
||||
/// </summary>
|
||||
/// <param name="value">
|
||||
/// The <see cref="StringBuilder"/> to clear.
|
||||
/// </param>
|
||||
public static void Clear(this StringBuilder value)
|
||||
{
|
||||
value.Length = 0;
|
||||
value.Capacity = 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("SSH.NET .NET 3.5")]
|
||||
[assembly: Guid("a9698831-4993-469b-81f1-aed4e5379252")]
|
||||
[assembly: InternalsVisibleTo("Renci.SshNet.Tests.NET35, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f9194e1eb66b7e2575aaee115ee1d27bc100920e7150e43992d6f668f9737de8b9c7ae892b62b8a36dd1d57929ff1541665d101dc476d6e02390846efae7e5186eec409710fdb596e3f83740afef0d4443055937649bc5a773175b61c57615dac0f0fd10f52b52fedf76c17474cc567b3f7a79de95dde842509fb39aaf69c6c2")]
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("SSH.NET .NET 3.5")]
|
||||
[assembly: Guid("a9698831-4993-469b-81f1-aed4e5379252")]
|
||||
[assembly: InternalsVisibleTo("Renci.SshNet.Tests.NET35, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f9194e1eb66b7e2575aaee115ee1d27bc100920e7150e43992d6f668f9737de8b9c7ae892b62b8a36dd1d57929ff1541665d101dc476d6e02390846efae7e5186eec409710fdb596e3f83740afef0d4443055937649bc5a773175b61c57615dac0f0fd10f52b52fedf76c17474cc567b3f7a79de95dde842509fb39aaf69c6c2")]
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,62 +1,62 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using Renci.SshNet.Messages;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Renci.SshNet
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides functionality to connect and interact with SSH server.
|
||||
/// </summary>
|
||||
public partial class Session
|
||||
{
|
||||
private static readonly Dictionary<Type, MethodInfo> _handlers;
|
||||
|
||||
static Session()
|
||||
{
|
||||
_handlers = new Dictionary<Type, MethodInfo>();
|
||||
|
||||
foreach (var method in typeof(Session).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).Where(x => x.Name == "HandleMessage"))
|
||||
{
|
||||
if (method.IsGenericMethod) continue;
|
||||
|
||||
var args = method.GetParameters();
|
||||
if (args.Length != 1) continue;
|
||||
|
||||
var argType = args[0].ParameterType;
|
||||
if (!argType.IsSubclassOf(typeof(Message))) continue;
|
||||
|
||||
_handlers.Add(argType, method);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles SSH messages.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
partial void HandleMessageCore(Message message)
|
||||
{
|
||||
Debug.Assert(message != null);
|
||||
|
||||
MethodInfo method;
|
||||
|
||||
if (_handlers.TryGetValue(message.GetType(), out method))
|
||||
{
|
||||
try
|
||||
{
|
||||
method.Invoke(this, new object[] { message });
|
||||
}
|
||||
catch (TargetInvocationException ex)
|
||||
{
|
||||
throw ex.InnerException ?? ex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Linq;
|
||||
using System;
|
||||
using Renci.SshNet.Messages;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Renci.SshNet
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides functionality to connect and interact with SSH server.
|
||||
/// </summary>
|
||||
public partial class Session
|
||||
{
|
||||
private static readonly Dictionary<Type, MethodInfo> _handlers;
|
||||
|
||||
static Session()
|
||||
{
|
||||
_handlers = new Dictionary<Type, MethodInfo>();
|
||||
|
||||
foreach (var method in typeof(Session).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).Where(x => x.Name == "HandleMessage"))
|
||||
{
|
||||
if (method.IsGenericMethod) continue;
|
||||
|
||||
var args = method.GetParameters();
|
||||
if (args.Length != 1) continue;
|
||||
|
||||
var argType = args[0].ParameterType;
|
||||
if (!argType.IsSubclassOf(typeof(Message))) continue;
|
||||
|
||||
_handlers.Add(argType, method);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles SSH messages.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
partial void HandleMessageCore(Message message)
|
||||
{
|
||||
Debug.Assert(message != null);
|
||||
|
||||
MethodInfo method;
|
||||
|
||||
if (_handlers.TryGetValue(message.GetType(), out method))
|
||||
{
|
||||
try
|
||||
{
|
||||
method.Invoke(this, new object[] { message });
|
||||
}
|
||||
catch (TargetInvocationException ex)
|
||||
{
|
||||
throw ex.InnerException ?? ex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Security.Cryptography;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Renci.SshNet.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of different extension method specific for Silverlight
|
||||
/// </summary>
|
||||
internal static partial class Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Disposes the specified socket.
|
||||
/// </summary>
|
||||
/// <param name="socket">The socket.</param>
|
||||
[DebuggerNonUserCode]
|
||||
internal static void Dispose(this Socket socket)
|
||||
{
|
||||
if (socket == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
socket.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the specified handle.
|
||||
/// </summary>
|
||||
/// <param name="handle">The handle.</param>
|
||||
[DebuggerNonUserCode]
|
||||
internal static void Dispose(this WaitHandle handle)
|
||||
{
|
||||
if (handle == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
handle.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the specified algorithm.
|
||||
/// </summary>
|
||||
/// <param name="algorithm">The algorithm.</param>
|
||||
[DebuggerNonUserCode]
|
||||
internal static void Dispose(this HashAlgorithm algorithm)
|
||||
{
|
||||
if (algorithm == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
algorithm.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Security.Cryptography;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Renci.SshNet.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of different extension method specific for Silverlight
|
||||
/// </summary>
|
||||
internal static partial class Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Disposes the specified socket.
|
||||
/// </summary>
|
||||
/// <param name="socket">The socket.</param>
|
||||
[DebuggerNonUserCode]
|
||||
internal static void Dispose(this Socket socket)
|
||||
{
|
||||
if (socket == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
socket.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the specified handle.
|
||||
/// </summary>
|
||||
/// <param name="handle">The handle.</param>
|
||||
[DebuggerNonUserCode]
|
||||
internal static void Dispose(this WaitHandle handle)
|
||||
{
|
||||
if (handle == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
handle.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the specified algorithm.
|
||||
/// </summary>
|
||||
/// <param name="algorithm">The algorithm.</param>
|
||||
[DebuggerNonUserCode]
|
||||
internal static void Dispose(this HashAlgorithm algorithm)
|
||||
{
|
||||
if (algorithm == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
algorithm.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("SSH.NET Silverlight 4")]
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("SSH.NET Silverlight 4")]
|
||||
[assembly: Guid("2b3f6251-8079-48aa-a76b-df70e40092e2")]
|
||||
@@ -1,12 +1,12 @@
|
||||
using Renci.SshNet.Messages;
|
||||
|
||||
namespace Renci.SshNet
|
||||
{
|
||||
public partial class Session
|
||||
{
|
||||
partial void HandleMessageCore(Message message)
|
||||
{
|
||||
this.HandleMessage((dynamic) message);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Messages;
|
||||
|
||||
namespace Renci.SshNet
|
||||
{
|
||||
public partial class Session
|
||||
{
|
||||
partial void HandleMessageCore(Message message)
|
||||
{
|
||||
this.HandleMessage((dynamic) message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace Renci.SshNet
|
||||
{
|
||||
public partial class Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the socket is connected.
|
||||
/// </summary>
|
||||
/// <param name="isConnected"><c>true</c> if the socket is connected; otherwise, <c>false</c></param>
|
||||
partial void IsSocketConnected(ref bool isConnected)
|
||||
{
|
||||
isConnected = (_socket != null && _socket.Connected);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Linq;
|
||||
|
||||
namespace Renci.SshNet
|
||||
{
|
||||
public partial class Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the socket is connected.
|
||||
/// </summary>
|
||||
/// <param name="isConnected"><c>true</c> if the socket is connected; otherwise, <c>false</c></param>
|
||||
partial void IsSocketConnected(ref bool isConnected)
|
||||
{
|
||||
isConnected = (_socket != null && _socket.Connected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("SSH.NET Silverlight 5")]
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("SSH.NET Silverlight 5")]
|
||||
[assembly: Guid("2b3f6251-8079-48aa-a76b-df70e40092e2")]
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.SshClientTests
|
||||
{
|
||||
public partial class ForwardedPortLocalTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.SshClientTests
|
||||
{
|
||||
public partial class ForwardedPortLocalTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.SshClientTests
|
||||
{
|
||||
public partial class ForwardedPortRemoteTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.SshClientTests
|
||||
{
|
||||
public partial class ForwardedPortRemoteTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.SshClientTests
|
||||
{
|
||||
public partial class SshCommandTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.SshClientTests
|
||||
{
|
||||
public partial class SshCommandTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("SSH.NET Tests .NET 3.5")]
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("SSH.NET Tests .NET 3.5")]
|
||||
[assembly: Guid("7c827904-40c1-4fe3-8ed1-8a729b8417a9")]
|
||||
+206
-206
@@ -1,206 +1,206 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18010
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Renci.SshNet.Tests.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Renci.SshNet.Tests.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to -----BEGIN DSA PRIVATE KEY-----
|
||||
///Proc-Type: 4,ENCRYPTED
|
||||
///DEK-Info: DES-EDE3-CBC,053105DCFC6132E7
|
||||
///
|
||||
///nVjIhJr3Eeqk0aBfyYK38B6cF0g35U2acgq5t3zG8fCM5JLSnFcmkkYvohbmCLva
|
||||
///swNHMfmwumoX8Ga94cxGu6vW1qf+IMvgEU4U53DtJqRoeICMwIre1yUq2cCrV+gI
|
||||
///qQ6MAVMDgfMs7HrPs5999m+KoDh7oYsA1l5q+axU/rqM4g3lySr/1oT6oAQx5Qp2
|
||||
///2DYkZEwnX5+NTw6aoMXl2qgIHBVxa7wZRMp9L0yAlEFk8T7fMuPrLSAEUBghcIaP
|
||||
///iBY1OY+M9MgDTTU56ZjLl+DfT3XfKzsZ3fmn1+bLqTRreiuS4/WF6xIa/DQu1sQd
|
||||
///nnjYgnKYcTWSvWWK9AcIVSpoiW2y6FcPkMAIw54ABrzBp4Rz0//Ykwv2Ga7AZxxm
|
||||
///P+lkxKf2RWnh406F [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string DSA_KEY_WITH_PASS {
|
||||
get {
|
||||
return ResourceManager.GetString("DSA_KEY_WITH_PASS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to -----BEGIN DSA PRIVATE KEY-----
|
||||
///MIIBvAIBAAKBgQDdQrrwGvknwD+pb9Gpv/vDxj8yqFUg0cUuC/tkjm3u+lQj86Rw
|
||||
///fA8RJOV+OP4Gtvs9zOSsxiuginoB/uEiT+6jbHvyvJeJp2fsDWLx/tVRXxpi8Nwe
|
||||
///bfb455R0wVVZdqnFKsAZLrQAT589EUtLgyVAFQbUP5Fz6px8H8AG0qlybQIVALn7
|
||||
///UOxnbFR7fDfZkq2Pc7ZCVegpAoGBANRKf9vezuz1aGUnUGWILHO09SibHK255fkr
|
||||
///u4//zvCbdawWSZOoU+vMnplLUhNaVMoSyYE/TYOZvvbG9UtPvr8wZGdNPipvIXIB
|
||||
///xlpr+FH0mnSx0qlaRy3PEoDRAmw6msRCzVYV3vZ8ZTEUdt+phuru+pn0W9EugzCM
|
||||
///HikVVhJMAoGASHB5nNlWhpqvungn+otYyGKoVoATkRdRfSiUo3fb0mJLTmxrEhEH
|
||||
///4UOFA/UFdQ0TYXXW0 [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string DSA_KEY_WITHOUT_PASS {
|
||||
get {
|
||||
return ResourceManager.GetString("DSA_KEY_WITHOUT_PASS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to oleg-centos.edc.renci.org.
|
||||
/// </summary>
|
||||
internal static string HOST {
|
||||
get {
|
||||
return ResourceManager.GetString("HOST", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to -----BEGIN DSA PRIVATE KEY-----
|
||||
///MIIBugIBAAKBgQCG3ij/JvdNp+1VUsK2zmLM5QWNN4MRRm/FCOHDknDJrWdSKheO
|
||||
///h6BbCgyFOw+k5qYtwXQnt3DpQfxPi7PIjr3tQJ9gB8LzqH2DwT2hMXm9VV2ImX2P
|
||||
///12aj8hZVM99WOp/ma6+ivLSFHnwET19eaqS9SRb0ftIqZXpWGE3ddW07qQIVAOfT
|
||||
///1OPSsvAnOsSrYc5HG5K3xIWlAoGAAzhTmi29+v0YTIsW2W1FihsexeAnpPPjYgRO
|
||||
///eT6HreyTvh20UASxDP+IJ2Ba+41G6MU0isuAijp8Z4CCC4RpoS46Ksc3JtPsZiRy
|
||||
///wAjwlb7JKGRBoY8V3aT47Xyx+iTSclZfzTmv0Z0bb56NZ6KEU8WRnks2d7tsb0fq
|
||||
///JTAgLkkCgYBvt5EoxhlCwEUgm8j3nD4TLSRYt1lt6LVulBYA9qlV4F68b2cJUuOi
|
||||
///YTV9H2SWRF6UF+GiR [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string INVALID_KEY {
|
||||
get {
|
||||
return ResourceManager.GetString("INVALID_KEY", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to tester.
|
||||
/// </summary>
|
||||
internal static string PASSWORD {
|
||||
get {
|
||||
return ResourceManager.GetString("PASSWORD", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to 22.
|
||||
/// </summary>
|
||||
internal static string PORT {
|
||||
get {
|
||||
return ResourceManager.GetString("PORT", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to proxy.oleg-centos.edc.renci.org.
|
||||
/// </summary>
|
||||
internal static string PROXY_HOST {
|
||||
get {
|
||||
return ResourceManager.GetString("PROXY_HOST", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to 8123.
|
||||
/// </summary>
|
||||
internal static string PROXY_PORT {
|
||||
get {
|
||||
return ResourceManager.GetString("PROXY_PORT", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to -----BEGIN RSA PRIVATE KEY-----
|
||||
///Proc-Type: 4,ENCRYPTED
|
||||
///DEK-Info: DES-EDE3-CBC,B3475536EDD1B442
|
||||
///
|
||||
///Xa6Y7FYTfz19CMzPcVbCpBHEh8x3tnA9PutKEDNMwKbR+NVUvBx5fN1QjrLpltCr
|
||||
///uX7yD3vLCeyihg4oaK3nTBZBcsB/1TZx+MlLgpvMfV1JKmbKCmebBZ3lUpsypHlG
|
||||
///FpCY41miFwdHmBe6tuwL9XA3vz26eJwSgJGMkVN9EBvNbiOHinEPhSW0whzBfbv+
|
||||
///OfseG73gvHc4jZS6Sw8h5VDBAmlldJEfkP/s/1/iTbCXFQ22xRb4Z6NilEyKiWpB
|
||||
///nQviXmaucTWCEuNF5QDA7oV7Ugwm5cAXuBqFIs9ZGaKV4/XpfX1tClOLfB3Lguh+
|
||||
///bbkwjPb0ztlhKa4gkwXiMs0S/lhoueXBae4QStM0qJBXHtFhhRYIn4JeIZ8CJ0k6
|
||||
///SMP7QVfPf5aJIaa8 [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string RSA_KEY_WITH_PASS {
|
||||
get {
|
||||
return ResourceManager.GetString("RSA_KEY_WITH_PASS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to -----BEGIN RSA PRIVATE KEY-----
|
||||
///MIIEogIBAAKCAQEA8ZsD8jgH7ySXnd4dprEFFkJ+zs1ne81E8febjR8hekiKrc+D
|
||||
///9GjeEykchy0PsrsBrf2F8J3GtLNISVerkl+EnVh1E0pi9Vllc1vcpQHvBeNPG/jl
|
||||
///9Dnum/DcaaMKLot+ARXjBuMX/xJVfnlgkvfpBvoq4QzQ6E27rOMbcPlvrN7KeYba
|
||||
///orsTpDMUraHX5u99P1evvw7sOuNl3lc9YpIgmjHT6dWUGTqBx9T2SEKXBRVk2NNb
|
||||
///d2UctQkr5BJn1gGehA+1KYS30FMiCSN8F8ZOlpYj1+K6xzs0srq1z30LailIyy7Q
|
||||
///mYp739BJlOF3cVywdcFXGre35H2cJylcNV2e+QIBIwKCAQAbnK/+bM207j02nQqz
|
||||
///9vlEX17zECkVdouJXiBn5kz4CEpdAcXwC/wfcmmpDHbSmQeBmVEi0DP3ZPJRhlzA
|
||||
///RW493jlECIBWjd+1a [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string RSA_KEY_WITHOUT_PASS {
|
||||
get {
|
||||
return ResourceManager.GetString("RSA_KEY_WITHOUT_PASS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to tester.
|
||||
/// </summary>
|
||||
internal static string USERNAME {
|
||||
get {
|
||||
return ResourceManager.GetString("USERNAME", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18010
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Renci.SshNet.Tests.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Renci.SshNet.Tests.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to -----BEGIN DSA PRIVATE KEY-----
|
||||
///Proc-Type: 4,ENCRYPTED
|
||||
///DEK-Info: DES-EDE3-CBC,053105DCFC6132E7
|
||||
///
|
||||
///nVjIhJr3Eeqk0aBfyYK38B6cF0g35U2acgq5t3zG8fCM5JLSnFcmkkYvohbmCLva
|
||||
///swNHMfmwumoX8Ga94cxGu6vW1qf+IMvgEU4U53DtJqRoeICMwIre1yUq2cCrV+gI
|
||||
///qQ6MAVMDgfMs7HrPs5999m+KoDh7oYsA1l5q+axU/rqM4g3lySr/1oT6oAQx5Qp2
|
||||
///2DYkZEwnX5+NTw6aoMXl2qgIHBVxa7wZRMp9L0yAlEFk8T7fMuPrLSAEUBghcIaP
|
||||
///iBY1OY+M9MgDTTU56ZjLl+DfT3XfKzsZ3fmn1+bLqTRreiuS4/WF6xIa/DQu1sQd
|
||||
///nnjYgnKYcTWSvWWK9AcIVSpoiW2y6FcPkMAIw54ABrzBp4Rz0//Ykwv2Ga7AZxxm
|
||||
///P+lkxKf2RWnh406F [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string DSA_KEY_WITH_PASS {
|
||||
get {
|
||||
return ResourceManager.GetString("DSA_KEY_WITH_PASS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to -----BEGIN DSA PRIVATE KEY-----
|
||||
///MIIBvAIBAAKBgQDdQrrwGvknwD+pb9Gpv/vDxj8yqFUg0cUuC/tkjm3u+lQj86Rw
|
||||
///fA8RJOV+OP4Gtvs9zOSsxiuginoB/uEiT+6jbHvyvJeJp2fsDWLx/tVRXxpi8Nwe
|
||||
///bfb455R0wVVZdqnFKsAZLrQAT589EUtLgyVAFQbUP5Fz6px8H8AG0qlybQIVALn7
|
||||
///UOxnbFR7fDfZkq2Pc7ZCVegpAoGBANRKf9vezuz1aGUnUGWILHO09SibHK255fkr
|
||||
///u4//zvCbdawWSZOoU+vMnplLUhNaVMoSyYE/TYOZvvbG9UtPvr8wZGdNPipvIXIB
|
||||
///xlpr+FH0mnSx0qlaRy3PEoDRAmw6msRCzVYV3vZ8ZTEUdt+phuru+pn0W9EugzCM
|
||||
///HikVVhJMAoGASHB5nNlWhpqvungn+otYyGKoVoATkRdRfSiUo3fb0mJLTmxrEhEH
|
||||
///4UOFA/UFdQ0TYXXW0 [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string DSA_KEY_WITHOUT_PASS {
|
||||
get {
|
||||
return ResourceManager.GetString("DSA_KEY_WITHOUT_PASS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to oleg-centos.edc.renci.org.
|
||||
/// </summary>
|
||||
internal static string HOST {
|
||||
get {
|
||||
return ResourceManager.GetString("HOST", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to -----BEGIN DSA PRIVATE KEY-----
|
||||
///MIIBugIBAAKBgQCG3ij/JvdNp+1VUsK2zmLM5QWNN4MRRm/FCOHDknDJrWdSKheO
|
||||
///h6BbCgyFOw+k5qYtwXQnt3DpQfxPi7PIjr3tQJ9gB8LzqH2DwT2hMXm9VV2ImX2P
|
||||
///12aj8hZVM99WOp/ma6+ivLSFHnwET19eaqS9SRb0ftIqZXpWGE3ddW07qQIVAOfT
|
||||
///1OPSsvAnOsSrYc5HG5K3xIWlAoGAAzhTmi29+v0YTIsW2W1FihsexeAnpPPjYgRO
|
||||
///eT6HreyTvh20UASxDP+IJ2Ba+41G6MU0isuAijp8Z4CCC4RpoS46Ksc3JtPsZiRy
|
||||
///wAjwlb7JKGRBoY8V3aT47Xyx+iTSclZfzTmv0Z0bb56NZ6KEU8WRnks2d7tsb0fq
|
||||
///JTAgLkkCgYBvt5EoxhlCwEUgm8j3nD4TLSRYt1lt6LVulBYA9qlV4F68b2cJUuOi
|
||||
///YTV9H2SWRF6UF+GiR [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string INVALID_KEY {
|
||||
get {
|
||||
return ResourceManager.GetString("INVALID_KEY", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to tester.
|
||||
/// </summary>
|
||||
internal static string PASSWORD {
|
||||
get {
|
||||
return ResourceManager.GetString("PASSWORD", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to 22.
|
||||
/// </summary>
|
||||
internal static string PORT {
|
||||
get {
|
||||
return ResourceManager.GetString("PORT", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to proxy.oleg-centos.edc.renci.org.
|
||||
/// </summary>
|
||||
internal static string PROXY_HOST {
|
||||
get {
|
||||
return ResourceManager.GetString("PROXY_HOST", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to 8123.
|
||||
/// </summary>
|
||||
internal static string PROXY_PORT {
|
||||
get {
|
||||
return ResourceManager.GetString("PROXY_PORT", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to -----BEGIN RSA PRIVATE KEY-----
|
||||
///Proc-Type: 4,ENCRYPTED
|
||||
///DEK-Info: DES-EDE3-CBC,B3475536EDD1B442
|
||||
///
|
||||
///Xa6Y7FYTfz19CMzPcVbCpBHEh8x3tnA9PutKEDNMwKbR+NVUvBx5fN1QjrLpltCr
|
||||
///uX7yD3vLCeyihg4oaK3nTBZBcsB/1TZx+MlLgpvMfV1JKmbKCmebBZ3lUpsypHlG
|
||||
///FpCY41miFwdHmBe6tuwL9XA3vz26eJwSgJGMkVN9EBvNbiOHinEPhSW0whzBfbv+
|
||||
///OfseG73gvHc4jZS6Sw8h5VDBAmlldJEfkP/s/1/iTbCXFQ22xRb4Z6NilEyKiWpB
|
||||
///nQviXmaucTWCEuNF5QDA7oV7Ugwm5cAXuBqFIs9ZGaKV4/XpfX1tClOLfB3Lguh+
|
||||
///bbkwjPb0ztlhKa4gkwXiMs0S/lhoueXBae4QStM0qJBXHtFhhRYIn4JeIZ8CJ0k6
|
||||
///SMP7QVfPf5aJIaa8 [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string RSA_KEY_WITH_PASS {
|
||||
get {
|
||||
return ResourceManager.GetString("RSA_KEY_WITH_PASS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to -----BEGIN RSA PRIVATE KEY-----
|
||||
///MIIEogIBAAKCAQEA8ZsD8jgH7ySXnd4dprEFFkJ+zs1ne81E8febjR8hekiKrc+D
|
||||
///9GjeEykchy0PsrsBrf2F8J3GtLNISVerkl+EnVh1E0pi9Vllc1vcpQHvBeNPG/jl
|
||||
///9Dnum/DcaaMKLot+ARXjBuMX/xJVfnlgkvfpBvoq4QzQ6E27rOMbcPlvrN7KeYba
|
||||
///orsTpDMUraHX5u99P1evvw7sOuNl3lc9YpIgmjHT6dWUGTqBx9T2SEKXBRVk2NNb
|
||||
///d2UctQkr5BJn1gGehA+1KYS30FMiCSN8F8ZOlpYj1+K6xzs0srq1z30LailIyy7Q
|
||||
///mYp739BJlOF3cVywdcFXGre35H2cJylcNV2e+QIBIwKCAQAbnK/+bM207j02nQqz
|
||||
///9vlEX17zECkVdouJXiBn5kz4CEpdAcXwC/wfcmmpDHbSmQeBmVEi0DP3ZPJRhlzA
|
||||
///RW493jlECIBWjd+1a [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string RSA_KEY_WITHOUT_PASS {
|
||||
get {
|
||||
return ResourceManager.GetString("RSA_KEY_WITHOUT_PASS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to tester.
|
||||
/// </summary>
|
||||
internal static string USERNAME {
|
||||
get {
|
||||
return ResourceManager.GetString("USERNAME", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,244 +1,244 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<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>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="DSA_KEY_WITHOUT_PASS" xml:space="preserve">
|
||||
<value>-----BEGIN DSA PRIVATE KEY-----
|
||||
MIIBvAIBAAKBgQDdQrrwGvknwD+pb9Gpv/vDxj8yqFUg0cUuC/tkjm3u+lQj86Rw
|
||||
fA8RJOV+OP4Gtvs9zOSsxiuginoB/uEiT+6jbHvyvJeJp2fsDWLx/tVRXxpi8Nwe
|
||||
bfb455R0wVVZdqnFKsAZLrQAT589EUtLgyVAFQbUP5Fz6px8H8AG0qlybQIVALn7
|
||||
UOxnbFR7fDfZkq2Pc7ZCVegpAoGBANRKf9vezuz1aGUnUGWILHO09SibHK255fkr
|
||||
u4//zvCbdawWSZOoU+vMnplLUhNaVMoSyYE/TYOZvvbG9UtPvr8wZGdNPipvIXIB
|
||||
xlpr+FH0mnSx0qlaRy3PEoDRAmw6msRCzVYV3vZ8ZTEUdt+phuru+pn0W9EugzCM
|
||||
HikVVhJMAoGASHB5nNlWhpqvungn+otYyGKoVoATkRdRfSiUo3fb0mJLTmxrEhEH
|
||||
4UOFA/UFdQ0TYXXW0wRX/amynT4iTEXAx0FjxUNK5ryxloeoXiXEH4FK7D8RtJO1
|
||||
1UsaRrN+nqWiSTVAehl6tzoMCPargGcWeFlAZZnPGN76OD9J1GiKZj8CFQCl8SkF
|
||||
GWfS+mH8xhLsxh1nI7rfJw==
|
||||
-----END DSA PRIVATE KEY-----</value>
|
||||
</data>
|
||||
<data name="DSA_KEY_WITH_PASS" xml:space="preserve">
|
||||
<value>-----BEGIN DSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: DES-EDE3-CBC,053105DCFC6132E7
|
||||
|
||||
nVjIhJr3Eeqk0aBfyYK38B6cF0g35U2acgq5t3zG8fCM5JLSnFcmkkYvohbmCLva
|
||||
swNHMfmwumoX8Ga94cxGu6vW1qf+IMvgEU4U53DtJqRoeICMwIre1yUq2cCrV+gI
|
||||
qQ6MAVMDgfMs7HrPs5999m+KoDh7oYsA1l5q+axU/rqM4g3lySr/1oT6oAQx5Qp2
|
||||
2DYkZEwnX5+NTw6aoMXl2qgIHBVxa7wZRMp9L0yAlEFk8T7fMuPrLSAEUBghcIaP
|
||||
iBY1OY+M9MgDTTU56ZjLl+DfT3XfKzsZ3fmn1+bLqTRreiuS4/WF6xIa/DQu1sQd
|
||||
nnjYgnKYcTWSvWWK9AcIVSpoiW2y6FcPkMAIw54ABrzBp4Rz0//Ykwv2Ga7AZxxm
|
||||
P+lkxKf2RWnh406FxBvBZzwB3rQeeM7QTg2IcFqGnlf005FIikp6SlyhZ/3M/Nl3
|
||||
FW235vuO37jLCL8qosGt4NOWAstXaxDujfIb/Q+IYxUpWZrdiH5tM/mUXARK0Sjf
|
||||
D8DHbFwAT2mUv1QxRXYJO1y4pENboEzT6LUqxJgE+ae/F/29g2RD9DhtwqKqWjhM
|
||||
7jB0kNVZrz3qUKnoJHIozA==
|
||||
-----END DSA PRIVATE KEY-----</value>
|
||||
</data>
|
||||
<data name="HOST" xml:space="preserve">
|
||||
<value>oleg-centos.edc.renci.org</value>
|
||||
</data>
|
||||
<data name="INVALID_KEY" xml:space="preserve">
|
||||
<value>-----BEGIN DSA PRIVATE KEY-----
|
||||
MIIBugIBAAKBgQCG3ij/JvdNp+1VUsK2zmLM5QWNN4MRRm/FCOHDknDJrWdSKheO
|
||||
h6BbCgyFOw+k5qYtwXQnt3DpQfxPi7PIjr3tQJ9gB8LzqH2DwT2hMXm9VV2ImX2P
|
||||
12aj8hZVM99WOp/ma6+ivLSFHnwET19eaqS9SRb0ftIqZXpWGE3ddW07qQIVAOfT
|
||||
1OPSsvAnOsSrYc5HG5K3xIWlAoGAAzhTmi29+v0YTIsW2W1FihsexeAnpPPjYgRO
|
||||
eT6HreyTvh20UASxDP+IJ2Ba+41G6MU0isuAijp8Z4CCC4RpoS46Ksc3JtPsZiRy
|
||||
wAjwlb7JKGRBoY8V3aT47Xyx+iTSclZfzTmv0Z0bb56NZ6KEU8WRnks2d7tsb0fq
|
||||
JTAgLkkCgYBvt5EoxhlCwEUgm8j3nD4TLSRYt1lt6LVulBYA9qlV4F68b2cJUuOi
|
||||
YTV9H2SWRF6UF+GiR5SajChveS106T9O+tepip+7V5YgFfW+ALOxwar+6V8VoUF4
|
||||
xNvNTWtaw+wK8xsgxhhYDaWVhVLVhR40QmeQhx/BQm+EYkSSa9kkCQIURGd0R+Zj
|
||||
tM7dZpB+reWl9L5e2L8=
|
||||
-----END DSA PRIVATE KEY-----</value>
|
||||
</data>
|
||||
<data name="PASSWORD" xml:space="preserve">
|
||||
<value>tester</value>
|
||||
</data>
|
||||
<data name="PORT" xml:space="preserve">
|
||||
<value>22</value>
|
||||
</data>
|
||||
<data name="PROXY_HOST" xml:space="preserve">
|
||||
<value>proxy.oleg-centos.edc.renci.org</value>
|
||||
</data>
|
||||
<data name="PROXY_PORT" xml:space="preserve">
|
||||
<value>8123</value>
|
||||
</data>
|
||||
<data name="RSA_KEY_WITHOUT_PASS" xml:space="preserve">
|
||||
<value>-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEogIBAAKCAQEA8ZsD8jgH7ySXnd4dprEFFkJ+zs1ne81E8febjR8hekiKrc+D
|
||||
9GjeEykchy0PsrsBrf2F8J3GtLNISVerkl+EnVh1E0pi9Vllc1vcpQHvBeNPG/jl
|
||||
9Dnum/DcaaMKLot+ARXjBuMX/xJVfnlgkvfpBvoq4QzQ6E27rOMbcPlvrN7KeYba
|
||||
orsTpDMUraHX5u99P1evvw7sOuNl3lc9YpIgmjHT6dWUGTqBx9T2SEKXBRVk2NNb
|
||||
d2UctQkr5BJn1gGehA+1KYS30FMiCSN8F8ZOlpYj1+K6xzs0srq1z30LailIyy7Q
|
||||
mYp739BJlOF3cVywdcFXGre35H2cJylcNV2e+QIBIwKCAQAbnK/+bM207j02nQqz
|
||||
9vlEX17zECkVdouJXiBn5kz4CEpdAcXwC/wfcmmpDHbSmQeBmVEi0DP3ZPJRhlzA
|
||||
RW493jlECIBWjd+1aZWPM2vGKJtTp2q802u6DOX9cbgFUcVB899ugFqDjREVxLqU
|
||||
dBqhtjDJQ0sTPBVy2CBkrsrvLy7AZd4LlaqxpdTdpkD/auUxg4zdThHT/XeQ0V0G
|
||||
3BS5vGehfqgkDOQpQSm7HexM+9GDJnnzMdNXjmWBPxZU49QAlxujZeZ1M2IgKwMq
|
||||
eNkWAOnZJidfsfwYluSCi8OHPN2i1s/b7pgn6ffb50S/k2mmhTHxNChDdGTlW91G
|
||||
6CFLAoGBAPlGA4qzZCG4SLBQicGhhXZlwaKKfTvWNi4xNPZeoJezC0G+yZZT7IIV
|
||||
zCj83t3dteaRRw15e+7NuIXZx3zl2hANfEpBZwnS4sOekvbS9/S7cEVzOEk53jRU
|
||||
TOtHRsvNxS2xK3RywqoaqzcPaK2Df917yzbqvEajMRudRPrsTvYdAoGBAPggB/kJ
|
||||
+VxZf13JqV2KgrFoVvykJpRlw2F5+lkH69ON9gdl976J3TNJDqAmHeWFxBUL+6Lt
|
||||
9TSpMq3fYueJXg9xaTkSYg177sPRGCmRLO5aneA4nJkIB6KHRXsR71C9D4fJK8Fi
|
||||
YB5n5dnBUTBhkvaI6KsxcxDzEg2zAJEcn4WNAoGBAOsHf66pI+VHWnpakINdxvqa
|
||||
dL3TCFz9K8UnFK3G7y/x9Kuz4qOuNsPLaLjua7s+wXL+ASn2MwW6pqoWekKPkxZz
|
||||
HWqVb8dvEFIKipDyzIepadsU3UxbIfbTI/PG3FnCAw3S7nUbvtrl8eN07arpsxKn
|
||||
63zr81iLPO4mkX7ezhs/AoGADi23UA8y0hO+Ip3PKeqoYei0g3cYJbysFDLbGwfE
|
||||
VTtP4ypl7aF6WrO3sWFDiXVbqW5mJpFBNjWN3gzD0rdkdek5NnYUO0jpEoD6EQD7
|
||||
QNH6ZJWFSpK+m5Kzg2AcTcGpHbO5W4H23SqCKbNGd8sPtlD3Wj1XCEhnbn9B3GgJ
|
||||
HZMCgYEAjn9BH4fcobMaM15AV0s6sCEyr/vzn3QBfoIBqqqlipMqOtPDv8oyvGO4
|
||||
5tSpMrTKf4e3YAMPA4TXRAiVLjeRYlhdj3He0LkAuZZabrHeRmWqjDruMWd1TcKZ
|
||||
3o8DLgYbSH7eGXUJ+euM4spKr5OLkBEkmH7Of6Qxss2njvjVNTE=
|
||||
-----END RSA PRIVATE KEY-----</value>
|
||||
</data>
|
||||
<data name="RSA_KEY_WITH_PASS" xml:space="preserve">
|
||||
<value>-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: DES-EDE3-CBC,B3475536EDD1B442
|
||||
|
||||
Xa6Y7FYTfz19CMzPcVbCpBHEh8x3tnA9PutKEDNMwKbR+NVUvBx5fN1QjrLpltCr
|
||||
uX7yD3vLCeyihg4oaK3nTBZBcsB/1TZx+MlLgpvMfV1JKmbKCmebBZ3lUpsypHlG
|
||||
FpCY41miFwdHmBe6tuwL9XA3vz26eJwSgJGMkVN9EBvNbiOHinEPhSW0whzBfbv+
|
||||
OfseG73gvHc4jZS6Sw8h5VDBAmlldJEfkP/s/1/iTbCXFQ22xRb4Z6NilEyKiWpB
|
||||
nQviXmaucTWCEuNF5QDA7oV7Ugwm5cAXuBqFIs9ZGaKV4/XpfX1tClOLfB3Lguh+
|
||||
bbkwjPb0ztlhKa4gkwXiMs0S/lhoueXBae4QStM0qJBXHtFhhRYIn4JeIZ8CJ0k6
|
||||
SMP7QVfPf5aJIaa8t+SlpvtIFTIkEhTViOCl+udT04670DGwmJUgrJAV0r+/Ytf7
|
||||
Mi+m3DagN7gGmCvYo+7r7EBl1G6e3hCSYm0rFxGOBesmCWriRoeRpxirWnkrns57
|
||||
D57pEC1hg90IdycCGpiwqubGDKFljuMLiVd2w0onVhudShPszP+nJAaq18wUB+rE
|
||||
mtBv+GlpqCITREB4lG2noP4r9P9lgrOTqmKvWjvUTQjfS3u0XO/1aQllKlwe97C7
|
||||
mfOxcZQWy5F7+9CiWpDpomW7Eso89ja6uyupw4Q4gsm7EUacqOOaVxHrm3MVhYjE
|
||||
Bfk9I5agKFqeHdjBUUP0DQ6X7JUEtb/Ri8ZrFnyT8sBG7JYnMTXfjPQqdR493cp2
|
||||
hWI5reZLi4CCUqt4Pcmhm2vtwJz5HXChARPYq2C3DhdJHcdhxUr97rfTGE1w8mPY
|
||||
JcwSFnNN47UBcDg6nvSfY3SJKV0gmmqz9fEw1pBoCrudJKw9U0vQrNoCEJOpEETG
|
||||
4XojbAMsTr0Ps5fI2X1VbVYWtU1uyZxqF8KaTCTN1Paapmqaq4N+qIFrrXA+PTH+
|
||||
dyaMLmYJ263Gy5eNkCZMeWLDFZ9WHX/Zx2ERMXfI6fyGImXkb6E0Dia+bB087BZP
|
||||
9C5gHAvZIjv+FosZrViFqDfrV5hDXL6bO3+V3zieemRxRCTvMtk+RXUJDd50qIOW
|
||||
gKNcSbevLPOyQH7eQbR+fU4KtJDUigbTFunSn2MZkDl2GDDlKI35wUAVr5yGsJbE
|
||||
yiIQe5DgLGZcMiEpqbhuqSfuOw0cUlFVyKeNZ/Hr701HWngLt677IY8ExyuNbBfT
|
||||
PRaes+hcjJ1QmJoRHZx9rQ3w0IpezCpRkRLRKJzzuQZOuwd95whKFXroFsdeaHxO
|
||||
hS4PqlLbuSMLiSIaPSZM6Huc4kb5lqCaxg/SBlXTCX17Z/8TFoqV/wCJz17XnkH6
|
||||
9WtKAC2TwKxiLZ2Qzwr2XV48lASugIOZkSW2qxM9ui+b1T9ICFKRGLn/UB//pOiG
|
||||
270hNJDLB/BKRExjS+RXeOpdAIJB5XsAEp8h56ub9emhhf9tCEXOn7PN7HbMCnQh
|
||||
7k8EpAG0h5StLUhY1HHvynVz2/qyMvZa/bIaaudL2565Z6nDU+iBxed7O1qrbRAH
|
||||
Vakr7Sa3K5niCyH5kxdyO1t29l1ksBqpDUrj+vViFuLkd3XIiui8IA==
|
||||
-----END RSA PRIVATE KEY-----</value>
|
||||
</data>
|
||||
<data name="USERNAME" xml:space="preserve">
|
||||
<value>tester</value>
|
||||
</data>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<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>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="DSA_KEY_WITHOUT_PASS" xml:space="preserve">
|
||||
<value>-----BEGIN DSA PRIVATE KEY-----
|
||||
MIIBvAIBAAKBgQDdQrrwGvknwD+pb9Gpv/vDxj8yqFUg0cUuC/tkjm3u+lQj86Rw
|
||||
fA8RJOV+OP4Gtvs9zOSsxiuginoB/uEiT+6jbHvyvJeJp2fsDWLx/tVRXxpi8Nwe
|
||||
bfb455R0wVVZdqnFKsAZLrQAT589EUtLgyVAFQbUP5Fz6px8H8AG0qlybQIVALn7
|
||||
UOxnbFR7fDfZkq2Pc7ZCVegpAoGBANRKf9vezuz1aGUnUGWILHO09SibHK255fkr
|
||||
u4//zvCbdawWSZOoU+vMnplLUhNaVMoSyYE/TYOZvvbG9UtPvr8wZGdNPipvIXIB
|
||||
xlpr+FH0mnSx0qlaRy3PEoDRAmw6msRCzVYV3vZ8ZTEUdt+phuru+pn0W9EugzCM
|
||||
HikVVhJMAoGASHB5nNlWhpqvungn+otYyGKoVoATkRdRfSiUo3fb0mJLTmxrEhEH
|
||||
4UOFA/UFdQ0TYXXW0wRX/amynT4iTEXAx0FjxUNK5ryxloeoXiXEH4FK7D8RtJO1
|
||||
1UsaRrN+nqWiSTVAehl6tzoMCPargGcWeFlAZZnPGN76OD9J1GiKZj8CFQCl8SkF
|
||||
GWfS+mH8xhLsxh1nI7rfJw==
|
||||
-----END DSA PRIVATE KEY-----</value>
|
||||
</data>
|
||||
<data name="DSA_KEY_WITH_PASS" xml:space="preserve">
|
||||
<value>-----BEGIN DSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: DES-EDE3-CBC,053105DCFC6132E7
|
||||
|
||||
nVjIhJr3Eeqk0aBfyYK38B6cF0g35U2acgq5t3zG8fCM5JLSnFcmkkYvohbmCLva
|
||||
swNHMfmwumoX8Ga94cxGu6vW1qf+IMvgEU4U53DtJqRoeICMwIre1yUq2cCrV+gI
|
||||
qQ6MAVMDgfMs7HrPs5999m+KoDh7oYsA1l5q+axU/rqM4g3lySr/1oT6oAQx5Qp2
|
||||
2DYkZEwnX5+NTw6aoMXl2qgIHBVxa7wZRMp9L0yAlEFk8T7fMuPrLSAEUBghcIaP
|
||||
iBY1OY+M9MgDTTU56ZjLl+DfT3XfKzsZ3fmn1+bLqTRreiuS4/WF6xIa/DQu1sQd
|
||||
nnjYgnKYcTWSvWWK9AcIVSpoiW2y6FcPkMAIw54ABrzBp4Rz0//Ykwv2Ga7AZxxm
|
||||
P+lkxKf2RWnh406FxBvBZzwB3rQeeM7QTg2IcFqGnlf005FIikp6SlyhZ/3M/Nl3
|
||||
FW235vuO37jLCL8qosGt4NOWAstXaxDujfIb/Q+IYxUpWZrdiH5tM/mUXARK0Sjf
|
||||
D8DHbFwAT2mUv1QxRXYJO1y4pENboEzT6LUqxJgE+ae/F/29g2RD9DhtwqKqWjhM
|
||||
7jB0kNVZrz3qUKnoJHIozA==
|
||||
-----END DSA PRIVATE KEY-----</value>
|
||||
</data>
|
||||
<data name="HOST" xml:space="preserve">
|
||||
<value>oleg-centos.edc.renci.org</value>
|
||||
</data>
|
||||
<data name="INVALID_KEY" xml:space="preserve">
|
||||
<value>-----BEGIN DSA PRIVATE KEY-----
|
||||
MIIBugIBAAKBgQCG3ij/JvdNp+1VUsK2zmLM5QWNN4MRRm/FCOHDknDJrWdSKheO
|
||||
h6BbCgyFOw+k5qYtwXQnt3DpQfxPi7PIjr3tQJ9gB8LzqH2DwT2hMXm9VV2ImX2P
|
||||
12aj8hZVM99WOp/ma6+ivLSFHnwET19eaqS9SRb0ftIqZXpWGE3ddW07qQIVAOfT
|
||||
1OPSsvAnOsSrYc5HG5K3xIWlAoGAAzhTmi29+v0YTIsW2W1FihsexeAnpPPjYgRO
|
||||
eT6HreyTvh20UASxDP+IJ2Ba+41G6MU0isuAijp8Z4CCC4RpoS46Ksc3JtPsZiRy
|
||||
wAjwlb7JKGRBoY8V3aT47Xyx+iTSclZfzTmv0Z0bb56NZ6KEU8WRnks2d7tsb0fq
|
||||
JTAgLkkCgYBvt5EoxhlCwEUgm8j3nD4TLSRYt1lt6LVulBYA9qlV4F68b2cJUuOi
|
||||
YTV9H2SWRF6UF+GiR5SajChveS106T9O+tepip+7V5YgFfW+ALOxwar+6V8VoUF4
|
||||
xNvNTWtaw+wK8xsgxhhYDaWVhVLVhR40QmeQhx/BQm+EYkSSa9kkCQIURGd0R+Zj
|
||||
tM7dZpB+reWl9L5e2L8=
|
||||
-----END DSA PRIVATE KEY-----</value>
|
||||
</data>
|
||||
<data name="PASSWORD" xml:space="preserve">
|
||||
<value>tester</value>
|
||||
</data>
|
||||
<data name="PORT" xml:space="preserve">
|
||||
<value>22</value>
|
||||
</data>
|
||||
<data name="PROXY_HOST" xml:space="preserve">
|
||||
<value>proxy.oleg-centos.edc.renci.org</value>
|
||||
</data>
|
||||
<data name="PROXY_PORT" xml:space="preserve">
|
||||
<value>8123</value>
|
||||
</data>
|
||||
<data name="RSA_KEY_WITHOUT_PASS" xml:space="preserve">
|
||||
<value>-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEogIBAAKCAQEA8ZsD8jgH7ySXnd4dprEFFkJ+zs1ne81E8febjR8hekiKrc+D
|
||||
9GjeEykchy0PsrsBrf2F8J3GtLNISVerkl+EnVh1E0pi9Vllc1vcpQHvBeNPG/jl
|
||||
9Dnum/DcaaMKLot+ARXjBuMX/xJVfnlgkvfpBvoq4QzQ6E27rOMbcPlvrN7KeYba
|
||||
orsTpDMUraHX5u99P1evvw7sOuNl3lc9YpIgmjHT6dWUGTqBx9T2SEKXBRVk2NNb
|
||||
d2UctQkr5BJn1gGehA+1KYS30FMiCSN8F8ZOlpYj1+K6xzs0srq1z30LailIyy7Q
|
||||
mYp739BJlOF3cVywdcFXGre35H2cJylcNV2e+QIBIwKCAQAbnK/+bM207j02nQqz
|
||||
9vlEX17zECkVdouJXiBn5kz4CEpdAcXwC/wfcmmpDHbSmQeBmVEi0DP3ZPJRhlzA
|
||||
RW493jlECIBWjd+1aZWPM2vGKJtTp2q802u6DOX9cbgFUcVB899ugFqDjREVxLqU
|
||||
dBqhtjDJQ0sTPBVy2CBkrsrvLy7AZd4LlaqxpdTdpkD/auUxg4zdThHT/XeQ0V0G
|
||||
3BS5vGehfqgkDOQpQSm7HexM+9GDJnnzMdNXjmWBPxZU49QAlxujZeZ1M2IgKwMq
|
||||
eNkWAOnZJidfsfwYluSCi8OHPN2i1s/b7pgn6ffb50S/k2mmhTHxNChDdGTlW91G
|
||||
6CFLAoGBAPlGA4qzZCG4SLBQicGhhXZlwaKKfTvWNi4xNPZeoJezC0G+yZZT7IIV
|
||||
zCj83t3dteaRRw15e+7NuIXZx3zl2hANfEpBZwnS4sOekvbS9/S7cEVzOEk53jRU
|
||||
TOtHRsvNxS2xK3RywqoaqzcPaK2Df917yzbqvEajMRudRPrsTvYdAoGBAPggB/kJ
|
||||
+VxZf13JqV2KgrFoVvykJpRlw2F5+lkH69ON9gdl976J3TNJDqAmHeWFxBUL+6Lt
|
||||
9TSpMq3fYueJXg9xaTkSYg177sPRGCmRLO5aneA4nJkIB6KHRXsR71C9D4fJK8Fi
|
||||
YB5n5dnBUTBhkvaI6KsxcxDzEg2zAJEcn4WNAoGBAOsHf66pI+VHWnpakINdxvqa
|
||||
dL3TCFz9K8UnFK3G7y/x9Kuz4qOuNsPLaLjua7s+wXL+ASn2MwW6pqoWekKPkxZz
|
||||
HWqVb8dvEFIKipDyzIepadsU3UxbIfbTI/PG3FnCAw3S7nUbvtrl8eN07arpsxKn
|
||||
63zr81iLPO4mkX7ezhs/AoGADi23UA8y0hO+Ip3PKeqoYei0g3cYJbysFDLbGwfE
|
||||
VTtP4ypl7aF6WrO3sWFDiXVbqW5mJpFBNjWN3gzD0rdkdek5NnYUO0jpEoD6EQD7
|
||||
QNH6ZJWFSpK+m5Kzg2AcTcGpHbO5W4H23SqCKbNGd8sPtlD3Wj1XCEhnbn9B3GgJ
|
||||
HZMCgYEAjn9BH4fcobMaM15AV0s6sCEyr/vzn3QBfoIBqqqlipMqOtPDv8oyvGO4
|
||||
5tSpMrTKf4e3YAMPA4TXRAiVLjeRYlhdj3He0LkAuZZabrHeRmWqjDruMWd1TcKZ
|
||||
3o8DLgYbSH7eGXUJ+euM4spKr5OLkBEkmH7Of6Qxss2njvjVNTE=
|
||||
-----END RSA PRIVATE KEY-----</value>
|
||||
</data>
|
||||
<data name="RSA_KEY_WITH_PASS" xml:space="preserve">
|
||||
<value>-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: DES-EDE3-CBC,B3475536EDD1B442
|
||||
|
||||
Xa6Y7FYTfz19CMzPcVbCpBHEh8x3tnA9PutKEDNMwKbR+NVUvBx5fN1QjrLpltCr
|
||||
uX7yD3vLCeyihg4oaK3nTBZBcsB/1TZx+MlLgpvMfV1JKmbKCmebBZ3lUpsypHlG
|
||||
FpCY41miFwdHmBe6tuwL9XA3vz26eJwSgJGMkVN9EBvNbiOHinEPhSW0whzBfbv+
|
||||
OfseG73gvHc4jZS6Sw8h5VDBAmlldJEfkP/s/1/iTbCXFQ22xRb4Z6NilEyKiWpB
|
||||
nQviXmaucTWCEuNF5QDA7oV7Ugwm5cAXuBqFIs9ZGaKV4/XpfX1tClOLfB3Lguh+
|
||||
bbkwjPb0ztlhKa4gkwXiMs0S/lhoueXBae4QStM0qJBXHtFhhRYIn4JeIZ8CJ0k6
|
||||
SMP7QVfPf5aJIaa8t+SlpvtIFTIkEhTViOCl+udT04670DGwmJUgrJAV0r+/Ytf7
|
||||
Mi+m3DagN7gGmCvYo+7r7EBl1G6e3hCSYm0rFxGOBesmCWriRoeRpxirWnkrns57
|
||||
D57pEC1hg90IdycCGpiwqubGDKFljuMLiVd2w0onVhudShPszP+nJAaq18wUB+rE
|
||||
mtBv+GlpqCITREB4lG2noP4r9P9lgrOTqmKvWjvUTQjfS3u0XO/1aQllKlwe97C7
|
||||
mfOxcZQWy5F7+9CiWpDpomW7Eso89ja6uyupw4Q4gsm7EUacqOOaVxHrm3MVhYjE
|
||||
Bfk9I5agKFqeHdjBUUP0DQ6X7JUEtb/Ri8ZrFnyT8sBG7JYnMTXfjPQqdR493cp2
|
||||
hWI5reZLi4CCUqt4Pcmhm2vtwJz5HXChARPYq2C3DhdJHcdhxUr97rfTGE1w8mPY
|
||||
JcwSFnNN47UBcDg6nvSfY3SJKV0gmmqz9fEw1pBoCrudJKw9U0vQrNoCEJOpEETG
|
||||
4XojbAMsTr0Ps5fI2X1VbVYWtU1uyZxqF8KaTCTN1Paapmqaq4N+qIFrrXA+PTH+
|
||||
dyaMLmYJ263Gy5eNkCZMeWLDFZ9WHX/Zx2ERMXfI6fyGImXkb6E0Dia+bB087BZP
|
||||
9C5gHAvZIjv+FosZrViFqDfrV5hDXL6bO3+V3zieemRxRCTvMtk+RXUJDd50qIOW
|
||||
gKNcSbevLPOyQH7eQbR+fU4KtJDUigbTFunSn2MZkDl2GDDlKI35wUAVr5yGsJbE
|
||||
yiIQe5DgLGZcMiEpqbhuqSfuOw0cUlFVyKeNZ/Hr701HWngLt677IY8ExyuNbBfT
|
||||
PRaes+hcjJ1QmJoRHZx9rQ3w0IpezCpRkRLRKJzzuQZOuwd95whKFXroFsdeaHxO
|
||||
hS4PqlLbuSMLiSIaPSZM6Huc4kb5lqCaxg/SBlXTCX17Z/8TFoqV/wCJz17XnkH6
|
||||
9WtKAC2TwKxiLZ2Qzwr2XV48lASugIOZkSW2qxM9ui+b1T9ICFKRGLn/UB//pOiG
|
||||
270hNJDLB/BKRExjS+RXeOpdAIJB5XsAEp8h56ub9emhhf9tCEXOn7PN7HbMCnQh
|
||||
7k8EpAG0h5StLUhY1HHvynVz2/qyMvZa/bIaaudL2565Z6nDU+iBxed7O1qrbRAH
|
||||
Vakr7Sa3K5niCyH5kxdyO1t29l1ksBqpDUrj+vViFuLkd3XIiui8IA==
|
||||
-----END RSA PRIVATE KEY-----</value>
|
||||
</data>
|
||||
<data name="USERNAME" xml:space="preserve">
|
||||
<value>tester</value>
|
||||
</data>
|
||||
</root>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Moq" version="4.2.1409.1722" targetFramework="net35" />
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Moq" version="4.2.1409.1722" targetFramework="net35" />
|
||||
</packages>
|
||||
+69
-69
@@ -1,69 +1,69 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Messages.Transport;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class BaseClientTest_Connected_KeepAlivesNotSentConcurrently
|
||||
{
|
||||
private Mock<IServiceFactory> _serviceFactoryMock;
|
||||
private Mock<ISession> _sessionMock;
|
||||
private BaseClient _client;
|
||||
private ConnectionInfo _connectionInfo;
|
||||
|
||||
[TestInitialize]
|
||||
public void Setup()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void Cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
protected void Arrange()
|
||||
{
|
||||
_connectionInfo = new ConnectionInfo("host", "user", new PasswordAuthenticationMethod("user", "pwd"));
|
||||
|
||||
_serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_serviceFactoryMock.Setup(p => p.CreateSession(_connectionInfo)).Returns(_sessionMock.Object);
|
||||
_sessionMock.Setup(p => p.Connect());
|
||||
_sessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
|
||||
.Returns(true)
|
||||
.Callback(() => Thread.Sleep(300));
|
||||
|
||||
_client = new MyClient(_connectionInfo, false, _serviceFactoryMock.Object)
|
||||
{
|
||||
KeepAliveInterval = TimeSpan.FromMilliseconds(50d)
|
||||
};
|
||||
_client.Connect();
|
||||
}
|
||||
|
||||
protected void Act()
|
||||
{
|
||||
// should keep-alive message be sent concurrently, then multiple keep-alive
|
||||
// message would be sent during this sleep period
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldBeInvokedOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Once);
|
||||
}
|
||||
|
||||
private class MyClient : BaseClient
|
||||
{
|
||||
public MyClient(ConnectionInfo connectionInfo, bool ownsConnectionInfo, IServiceFactory serviceFactory) : base(connectionInfo, ownsConnectionInfo, serviceFactory)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Messages.Transport;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class BaseClientTest_Connected_KeepAlivesNotSentConcurrently
|
||||
{
|
||||
private Mock<IServiceFactory> _serviceFactoryMock;
|
||||
private Mock<ISession> _sessionMock;
|
||||
private BaseClient _client;
|
||||
private ConnectionInfo _connectionInfo;
|
||||
|
||||
[TestInitialize]
|
||||
public void Setup()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void Cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
protected void Arrange()
|
||||
{
|
||||
_connectionInfo = new ConnectionInfo("host", "user", new PasswordAuthenticationMethod("user", "pwd"));
|
||||
|
||||
_serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_serviceFactoryMock.Setup(p => p.CreateSession(_connectionInfo)).Returns(_sessionMock.Object);
|
||||
_sessionMock.Setup(p => p.Connect());
|
||||
_sessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
|
||||
.Returns(true)
|
||||
.Callback(() => Thread.Sleep(300));
|
||||
|
||||
_client = new MyClient(_connectionInfo, false, _serviceFactoryMock.Object)
|
||||
{
|
||||
KeepAliveInterval = TimeSpan.FromMilliseconds(50d)
|
||||
};
|
||||
_client.Connect();
|
||||
}
|
||||
|
||||
protected void Act()
|
||||
{
|
||||
// should keep-alive message be sent concurrently, then multiple keep-alive
|
||||
// message would be sent during this sleep period
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldBeInvokedOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Once);
|
||||
}
|
||||
|
||||
private class MyClient : BaseClient
|
||||
{
|
||||
public MyClient(ConnectionInfo connectionInfo, bool ownsConnectionInfo, IServiceFactory serviceFactory) : base(connectionInfo, ownsConnectionInfo, serviceFactory)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,225 +1,225 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelDirectTcpipTestTest : TestBase
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IForwardedPort> _forwardedPortMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private string _remoteHost;
|
||||
private uint _port;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
|
||||
var random = new Random();
|
||||
|
||||
_localWindowSize = (uint) random.Next(2000, 3000);
|
||||
_localPacketSize = (uint) random.Next(1000, 2000);
|
||||
_remoteHost = random.Next().ToString(CultureInfo.InvariantCulture);
|
||||
_port = (uint) random.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort);
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(100, 200);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SocketShouldBeClosedAndBindShouldEndWhenForwardedPortSignalsClosingEvent()
|
||||
{
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
|
||||
.Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(((ChannelOpenMessage)m).LocalChannelNumber, _remoteWindowSize, _remotePacketSize, _remoteChannelNumber))));
|
||||
_sessionMock.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
|
||||
.Callback<WaitHandle>(p => p.WaitOne(Session.Infinite));
|
||||
|
||||
var localPortEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
|
||||
using (var localPortListener = new AsyncSocketListener(localPortEndPoint))
|
||||
{
|
||||
localPortListener.Start();
|
||||
|
||||
localPortListener.Connected += socket =>
|
||||
{
|
||||
var channel = new ChannelDirectTcpip(_sessionMock.Object, _localChannelNumber, _localWindowSize,
|
||||
_localPacketSize);
|
||||
channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
|
||||
|
||||
var closeForwardedPortThread =
|
||||
new Thread(() =>
|
||||
{
|
||||
// sleep for a short period to allow channel to actually start receiving from socket
|
||||
Thread.Sleep(100);
|
||||
// raise Closing event on forwarded port
|
||||
_forwardedPortMock.Raise(p => p.Closing += null, EventArgs.Empty);
|
||||
});
|
||||
closeForwardedPortThread.Start();
|
||||
|
||||
channel.Bind();
|
||||
|
||||
closeForwardedPortThread.Join();
|
||||
};
|
||||
|
||||
var client = new Socket(localPortEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||
client.Connect(localPortEndPoint);
|
||||
|
||||
// attempt to receive from socket to verify it was shut down by channel
|
||||
var buffer = new byte[16];
|
||||
var bytesReceived = client.Receive(buffer, 0, buffer.Length, SocketFlags.None);
|
||||
Assert.AreEqual(0, bytesReceived);
|
||||
Assert.IsTrue(client.Connected);
|
||||
// signal to server that we also shut down the socket at our end
|
||||
client.Shutdown(SocketShutdown.Send);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SocketShouldBeClosedAndBindShouldEndWhenOnErrorOccurredIsInvoked()
|
||||
{
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
|
||||
.Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(((ChannelOpenMessage)m).LocalChannelNumber, _remoteWindowSize, _remotePacketSize, _remoteChannelNumber))));
|
||||
_sessionMock.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
|
||||
.Callback<WaitHandle>(p => p.WaitOne(Session.Infinite));
|
||||
|
||||
var localPortEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
|
||||
using (var localPortListener = new AsyncSocketListener(localPortEndPoint))
|
||||
{
|
||||
localPortListener.Start();
|
||||
|
||||
localPortListener.Connected += socket =>
|
||||
{
|
||||
var channel = new ChannelDirectTcpip(_sessionMock.Object, _localChannelNumber, _localWindowSize,
|
||||
_localPacketSize);
|
||||
channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
|
||||
|
||||
var signalSessionErrorOccurredThread =
|
||||
new Thread(() =>
|
||||
{
|
||||
// sleep for a short period to allow channel to actually start receiving from socket
|
||||
Thread.Sleep(100);
|
||||
// raise ErrorOccured event on session
|
||||
_sessionMock.Raise(s => s.ErrorOccured += null,
|
||||
new ExceptionEventArgs(new SystemException()));
|
||||
});
|
||||
signalSessionErrorOccurredThread.Start();
|
||||
|
||||
channel.Bind();
|
||||
|
||||
signalSessionErrorOccurredThread.Join();
|
||||
};
|
||||
|
||||
var client = new Socket(localPortEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||
client.Connect(localPortEndPoint);
|
||||
|
||||
// attempt to receive from socket to verify it was shut down by channel
|
||||
var buffer = new byte[16];
|
||||
var bytesReceived = client.Receive(buffer, 0, buffer.Length, SocketFlags.None);
|
||||
Assert.AreEqual(0, bytesReceived);
|
||||
Assert.IsTrue(client.Connected);
|
||||
// signal to server that we also shut down the socket at our end
|
||||
client.Shutdown(SocketShutdown.Send);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SocketShouldBeClosedAndEofShouldBeSentToServerWhenClientShutsDownSocket()
|
||||
{
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
|
||||
.Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(((ChannelOpenMessage) m).LocalChannelNumber,
|
||||
_remoteWindowSize, _remotePacketSize, _remoteChannelNumber))));
|
||||
_sessionMock.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
|
||||
.Callback<WaitHandle>(p => p.WaitOne(Session.Infinite));
|
||||
_sessionMock.Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(60));
|
||||
_sessionMock.Setup(p => p.TrySendMessage(It.IsAny<ChannelEofMessage>()))
|
||||
.Returns(true)
|
||||
.Callback<Message>(
|
||||
m => new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(50);
|
||||
_sessionMock.Raise(s => s.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
}).Start());
|
||||
_sessionMock.Setup(p => p.TrySendMessage(It.IsAny<ChannelCloseMessage>()))
|
||||
.Returns(true)
|
||||
.Callback<Message>(
|
||||
m => new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(50);
|
||||
_sessionMock.Raise(s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}).Start());
|
||||
var channelBindFinishedWaitHandle = new ManualResetEvent(false);
|
||||
Socket handler = null;
|
||||
ChannelDirectTcpip channel = null;
|
||||
|
||||
var localPortEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
|
||||
using (var localPortListener = new AsyncSocketListener(localPortEndPoint))
|
||||
{
|
||||
localPortListener.Start();
|
||||
|
||||
localPortListener.Connected += socket =>
|
||||
{
|
||||
channel = new ChannelDirectTcpip(_sessionMock.Object, _localChannelNumber, _localWindowSize,
|
||||
_localPacketSize);
|
||||
channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
|
||||
channel.Bind();
|
||||
channel.Close();
|
||||
|
||||
handler = socket;
|
||||
|
||||
channelBindFinishedWaitHandle.Set();
|
||||
};
|
||||
|
||||
var client = new Socket(localPortEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||
client.Connect(localPortEndPoint);
|
||||
client.Shutdown(SocketShutdown.Send);
|
||||
Assert.IsFalse(client.Connected);
|
||||
|
||||
channelBindFinishedWaitHandle.WaitOne();
|
||||
|
||||
Assert.IsNotNull(handler);
|
||||
Assert.IsFalse(handler.Connected);
|
||||
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<ChannelEofMessage>()), Times.Once);
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<ChannelCloseMessage>()), Times.Once);
|
||||
|
||||
channel.Close();
|
||||
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<ChannelEofMessage>()), Times.Once);
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<ChannelCloseMessage>()), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelDirectTcpipTestTest : TestBase
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IForwardedPort> _forwardedPortMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private string _remoteHost;
|
||||
private uint _port;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
|
||||
var random = new Random();
|
||||
|
||||
_localWindowSize = (uint) random.Next(2000, 3000);
|
||||
_localPacketSize = (uint) random.Next(1000, 2000);
|
||||
_remoteHost = random.Next().ToString(CultureInfo.InvariantCulture);
|
||||
_port = (uint) random.Next(IPEndPoint.MinPort, IPEndPoint.MaxPort);
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(100, 200);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SocketShouldBeClosedAndBindShouldEndWhenForwardedPortSignalsClosingEvent()
|
||||
{
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
|
||||
.Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(((ChannelOpenMessage)m).LocalChannelNumber, _remoteWindowSize, _remotePacketSize, _remoteChannelNumber))));
|
||||
_sessionMock.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
|
||||
.Callback<WaitHandle>(p => p.WaitOne(Session.Infinite));
|
||||
|
||||
var localPortEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
|
||||
using (var localPortListener = new AsyncSocketListener(localPortEndPoint))
|
||||
{
|
||||
localPortListener.Start();
|
||||
|
||||
localPortListener.Connected += socket =>
|
||||
{
|
||||
var channel = new ChannelDirectTcpip(_sessionMock.Object, _localChannelNumber, _localWindowSize,
|
||||
_localPacketSize);
|
||||
channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
|
||||
|
||||
var closeForwardedPortThread =
|
||||
new Thread(() =>
|
||||
{
|
||||
// sleep for a short period to allow channel to actually start receiving from socket
|
||||
Thread.Sleep(100);
|
||||
// raise Closing event on forwarded port
|
||||
_forwardedPortMock.Raise(p => p.Closing += null, EventArgs.Empty);
|
||||
});
|
||||
closeForwardedPortThread.Start();
|
||||
|
||||
channel.Bind();
|
||||
|
||||
closeForwardedPortThread.Join();
|
||||
};
|
||||
|
||||
var client = new Socket(localPortEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||
client.Connect(localPortEndPoint);
|
||||
|
||||
// attempt to receive from socket to verify it was shut down by channel
|
||||
var buffer = new byte[16];
|
||||
var bytesReceived = client.Receive(buffer, 0, buffer.Length, SocketFlags.None);
|
||||
Assert.AreEqual(0, bytesReceived);
|
||||
Assert.IsTrue(client.Connected);
|
||||
// signal to server that we also shut down the socket at our end
|
||||
client.Shutdown(SocketShutdown.Send);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SocketShouldBeClosedAndBindShouldEndWhenOnErrorOccurredIsInvoked()
|
||||
{
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
|
||||
.Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(((ChannelOpenMessage)m).LocalChannelNumber, _remoteWindowSize, _remotePacketSize, _remoteChannelNumber))));
|
||||
_sessionMock.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
|
||||
.Callback<WaitHandle>(p => p.WaitOne(Session.Infinite));
|
||||
|
||||
var localPortEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
|
||||
using (var localPortListener = new AsyncSocketListener(localPortEndPoint))
|
||||
{
|
||||
localPortListener.Start();
|
||||
|
||||
localPortListener.Connected += socket =>
|
||||
{
|
||||
var channel = new ChannelDirectTcpip(_sessionMock.Object, _localChannelNumber, _localWindowSize,
|
||||
_localPacketSize);
|
||||
channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
|
||||
|
||||
var signalSessionErrorOccurredThread =
|
||||
new Thread(() =>
|
||||
{
|
||||
// sleep for a short period to allow channel to actually start receiving from socket
|
||||
Thread.Sleep(100);
|
||||
// raise ErrorOccured event on session
|
||||
_sessionMock.Raise(s => s.ErrorOccured += null,
|
||||
new ExceptionEventArgs(new SystemException()));
|
||||
});
|
||||
signalSessionErrorOccurredThread.Start();
|
||||
|
||||
channel.Bind();
|
||||
|
||||
signalSessionErrorOccurredThread.Join();
|
||||
};
|
||||
|
||||
var client = new Socket(localPortEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||
client.Connect(localPortEndPoint);
|
||||
|
||||
// attempt to receive from socket to verify it was shut down by channel
|
||||
var buffer = new byte[16];
|
||||
var bytesReceived = client.Receive(buffer, 0, buffer.Length, SocketFlags.None);
|
||||
Assert.AreEqual(0, bytesReceived);
|
||||
Assert.IsTrue(client.Connected);
|
||||
// signal to server that we also shut down the socket at our end
|
||||
client.Shutdown(SocketShutdown.Send);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SocketShouldBeClosedAndEofShouldBeSentToServerWhenClientShutsDownSocket()
|
||||
{
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
|
||||
.Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(((ChannelOpenMessage) m).LocalChannelNumber,
|
||||
_remoteWindowSize, _remotePacketSize, _remoteChannelNumber))));
|
||||
_sessionMock.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
|
||||
.Callback<WaitHandle>(p => p.WaitOne(Session.Infinite));
|
||||
_sessionMock.Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.Setup(p => p.Timeout).Returns(TimeSpan.FromSeconds(60));
|
||||
_sessionMock.Setup(p => p.TrySendMessage(It.IsAny<ChannelEofMessage>()))
|
||||
.Returns(true)
|
||||
.Callback<Message>(
|
||||
m => new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(50);
|
||||
_sessionMock.Raise(s => s.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
}).Start());
|
||||
_sessionMock.Setup(p => p.TrySendMessage(It.IsAny<ChannelCloseMessage>()))
|
||||
.Returns(true)
|
||||
.Callback<Message>(
|
||||
m => new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(50);
|
||||
_sessionMock.Raise(s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}).Start());
|
||||
var channelBindFinishedWaitHandle = new ManualResetEvent(false);
|
||||
Socket handler = null;
|
||||
ChannelDirectTcpip channel = null;
|
||||
|
||||
var localPortEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
|
||||
using (var localPortListener = new AsyncSocketListener(localPortEndPoint))
|
||||
{
|
||||
localPortListener.Start();
|
||||
|
||||
localPortListener.Connected += socket =>
|
||||
{
|
||||
channel = new ChannelDirectTcpip(_sessionMock.Object, _localChannelNumber, _localWindowSize,
|
||||
_localPacketSize);
|
||||
channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
|
||||
channel.Bind();
|
||||
channel.Close();
|
||||
|
||||
handler = socket;
|
||||
|
||||
channelBindFinishedWaitHandle.Set();
|
||||
};
|
||||
|
||||
var client = new Socket(localPortEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||
client.Connect(localPortEndPoint);
|
||||
client.Shutdown(SocketShutdown.Send);
|
||||
Assert.IsFalse(client.Connected);
|
||||
|
||||
channelBindFinishedWaitHandle.WaitOne();
|
||||
|
||||
Assert.IsNotNull(handler);
|
||||
Assert.IsFalse(handler.Connected);
|
||||
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<ChannelEofMessage>()), Times.Once);
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<ChannelCloseMessage>()), Times.Once);
|
||||
|
||||
channel.Close();
|
||||
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<ChannelEofMessage>()), Times.Once);
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<ChannelCloseMessage>()), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+195
-195
@@ -1,196 +1,196 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelForwardedTcpipTest_Close_SessionIsConnectedAndChannelIsOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IForwardedPort> _forwardedPortMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelForwardedTcpip _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private IPEndPoint _remoteEndpoint;
|
||||
private AsyncSocketListener _remoteListener;
|
||||
private EventWaitHandle _channelBindFinishedWaitHandle;
|
||||
private Exception _channelException;
|
||||
private IList<Socket> _connectedRegister;
|
||||
private IList<Socket> _disconnectedRegister;
|
||||
private Thread _channelThread;
|
||||
private TimeSpan _connectionInfoTimeout;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void CleanUp()
|
||||
{
|
||||
if (_remoteListener != null)
|
||||
{
|
||||
_remoteListener.Stop();
|
||||
_remoteListener = null;
|
||||
}
|
||||
|
||||
if (_channelThread != null)
|
||||
{
|
||||
if (_channelThread.IsAlive)
|
||||
_channelThread.Abort();
|
||||
_channelThread = null;
|
||||
}
|
||||
if (_channel != null)
|
||||
{
|
||||
_channel.Dispose();
|
||||
_channel = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(2000, 3000);
|
||||
_localPacketSize = (uint) random.Next(1000, 2000);
|
||||
_remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint) random.Next(100, 200);
|
||||
_channelBindFinishedWaitHandle = new ManualResetEvent(false);
|
||||
_channelException = null;
|
||||
_connectedRegister = new List<Socket>();
|
||||
_disconnectedRegister = new List<Socket>();
|
||||
_connectionInfoTimeout = TimeSpan.FromSeconds(5);
|
||||
|
||||
_remoteEndpoint = new IPEndPoint(IPAddress.Loopback, 8122);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
_forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.Timeout).Returns(_connectionInfoTimeout);
|
||||
_sessionMock.InSequence(sequence).Setup(
|
||||
p => p.SendMessage(
|
||||
It.Is<ChannelOpenConfirmationMessage>(
|
||||
m => m.LocalChannelNumber == _remoteChannelNumber
|
||||
&&
|
||||
m.InitialWindowSize == _localWindowSize
|
||||
&&
|
||||
m.MaximumPacketSize == _localPacketSize
|
||||
&&
|
||||
m.RemoteChannelNumber == _localChannelNumber)
|
||||
));
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
|
||||
_remoteListener = new AsyncSocketListener(_remoteEndpoint);
|
||||
_remoteListener.Connected += socket => _connectedRegister.Add(socket);
|
||||
_remoteListener.Disconnected += socket => _disconnectedRegister.Add(socket);
|
||||
_remoteListener.Start();
|
||||
|
||||
_channel = new ChannelForwardedTcpip(
|
||||
_sessionMock.Object,
|
||||
_localChannelNumber,
|
||||
_localWindowSize,
|
||||
_localPacketSize,
|
||||
_remoteChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize);
|
||||
|
||||
_channelThread = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_channel.Bind(_remoteEndpoint, _forwardedPortMock.Object);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_channelException = ex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_channelBindFinishedWaitHandle.Set();
|
||||
}
|
||||
});
|
||||
_channelThread.Start();
|
||||
|
||||
// give channel time to bind to remote endpoint
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelShouldShutdownSocketToRemoteListener()
|
||||
{
|
||||
Assert.AreEqual(1, _connectedRegister.Count);
|
||||
Assert.AreEqual(1, _disconnectedRegister.Count);
|
||||
Assert.AreSame(_connectedRegister[0], _disconnectedRegister[0]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void BindShouldHaveFinishedWithoutException()
|
||||
{
|
||||
Assert.IsTrue(_channelBindFinishedWaitHandle.WaitOne(0));
|
||||
Assert.IsNull(_channelException, _channelException != null ? _channelException.ToString() : null);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelEofMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelCloseMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelForwardedTcpipTest_Close_SessionIsConnectedAndChannelIsOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IForwardedPort> _forwardedPortMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelForwardedTcpip _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private IPEndPoint _remoteEndpoint;
|
||||
private AsyncSocketListener _remoteListener;
|
||||
private EventWaitHandle _channelBindFinishedWaitHandle;
|
||||
private Exception _channelException;
|
||||
private IList<Socket> _connectedRegister;
|
||||
private IList<Socket> _disconnectedRegister;
|
||||
private Thread _channelThread;
|
||||
private TimeSpan _connectionInfoTimeout;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void CleanUp()
|
||||
{
|
||||
if (_remoteListener != null)
|
||||
{
|
||||
_remoteListener.Stop();
|
||||
_remoteListener = null;
|
||||
}
|
||||
|
||||
if (_channelThread != null)
|
||||
{
|
||||
if (_channelThread.IsAlive)
|
||||
_channelThread.Abort();
|
||||
_channelThread = null;
|
||||
}
|
||||
if (_channel != null)
|
||||
{
|
||||
_channel.Dispose();
|
||||
_channel = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(2000, 3000);
|
||||
_localPacketSize = (uint) random.Next(1000, 2000);
|
||||
_remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint) random.Next(100, 200);
|
||||
_channelBindFinishedWaitHandle = new ManualResetEvent(false);
|
||||
_channelException = null;
|
||||
_connectedRegister = new List<Socket>();
|
||||
_disconnectedRegister = new List<Socket>();
|
||||
_connectionInfoTimeout = TimeSpan.FromSeconds(5);
|
||||
|
||||
_remoteEndpoint = new IPEndPoint(IPAddress.Loopback, 8122);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
_forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.Timeout).Returns(_connectionInfoTimeout);
|
||||
_sessionMock.InSequence(sequence).Setup(
|
||||
p => p.SendMessage(
|
||||
It.Is<ChannelOpenConfirmationMessage>(
|
||||
m => m.LocalChannelNumber == _remoteChannelNumber
|
||||
&&
|
||||
m.InitialWindowSize == _localWindowSize
|
||||
&&
|
||||
m.MaximumPacketSize == _localPacketSize
|
||||
&&
|
||||
m.RemoteChannelNumber == _localChannelNumber)
|
||||
));
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
|
||||
_remoteListener = new AsyncSocketListener(_remoteEndpoint);
|
||||
_remoteListener.Connected += socket => _connectedRegister.Add(socket);
|
||||
_remoteListener.Disconnected += socket => _disconnectedRegister.Add(socket);
|
||||
_remoteListener.Start();
|
||||
|
||||
_channel = new ChannelForwardedTcpip(
|
||||
_sessionMock.Object,
|
||||
_localChannelNumber,
|
||||
_localWindowSize,
|
||||
_localPacketSize,
|
||||
_remoteChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize);
|
||||
|
||||
_channelThread = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_channel.Bind(_remoteEndpoint, _forwardedPortMock.Object);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_channelException = ex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_channelBindFinishedWaitHandle.Set();
|
||||
}
|
||||
});
|
||||
_channelThread.Start();
|
||||
|
||||
// give channel time to bind to remote endpoint
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelShouldShutdownSocketToRemoteListener()
|
||||
{
|
||||
Assert.AreEqual(1, _connectedRegister.Count);
|
||||
Assert.AreEqual(1, _disconnectedRegister.Count);
|
||||
Assert.AreSame(_connectedRegister[0], _disconnectedRegister[0]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void BindShouldHaveFinishedWithoutException()
|
||||
{
|
||||
Assert.IsTrue(_channelBindFinishedWaitHandle.WaitOne(0));
|
||||
Assert.IsNull(_channelException, _channelException != null ? _channelException.ToString() : null);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelEofMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelCloseMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,144 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_Closed
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelSession _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(2000, 3000);
|
||||
_localPacketSize = (uint)random.Next(1000, 2000);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(100, 200);
|
||||
_sessionSemaphore = new SemaphoreLight(1);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
protected virtual void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
internal ChannelSession Channel
|
||||
{
|
||||
get { return _channel; }
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelEofMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelCloseMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_Closed
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelSession _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(2000, 3000);
|
||||
_localPacketSize = (uint)random.Next(1000, 2000);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(100, 200);
|
||||
_sessionSemaphore = new SemaphoreLight(1);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
protected virtual void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
internal ChannelSession Channel
|
||||
{
|
||||
get { return _channel; }
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelEofMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelCloseMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
+131
-131
@@ -1,131 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelCloseAndChannelEofReceived_SendChannelCloseMessageFailure
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(false);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelCloseAndChannelEofReceived_SendChannelCloseMessageFailure
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(false);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+131
-131
@@ -1,131 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelCloseAndChannelEofReceived_SendChannelCloseMessageSuccess
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelCloseAndChannelEofReceived_SendChannelCloseMessageSuccess
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+128
-128
@@ -1,128 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelCloseReceived_SendChannelCloseMessageFailure
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(false);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelCloseReceived_SendChannelCloseMessageFailure
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(false);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+128
-128
@@ -1,128 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelCloseReceived_SendChannelCloseMessageSuccess
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelCloseReceived_SendChannelCloseMessageSuccess
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+127
-127
@@ -1,127 +1,127 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelEofReceived_SendChannelCloseMessageFailure
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(false);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelEofReceived_SendChannelCloseMessageFailure
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(false);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+138
-138
@@ -1,138 +1,138 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelEofReceived_SendChannelCloseMessageSuccess
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_ChannelEofReceived_SendChannelCloseMessageSuccess
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+141
-141
@@ -1,142 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_NoChannelCloseOrChannelEofReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelSession _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(2000, 3000);
|
||||
_localPacketSize = (uint)random.Next(1000, 2000);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(100, 200);
|
||||
_sessionSemaphore = new SemaphoreLight(1);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelEofMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelCloseMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_NoChannelCloseOrChannelEofReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelSession _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(2000, 3000);
|
||||
_localPacketSize = (uint)random.Next(1000, 2000);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(100, 200);
|
||||
_sessionSemaphore = new SemaphoreLight(1);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelEofMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelCloseMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
+141
-141
@@ -1,142 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_NoChannelCloseOrChannelEofReceived_SendChannelEofMessageFailure
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelSession _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(2000, 3000);
|
||||
_localPacketSize = (uint)random.Next(1000, 2000);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(100, 200);
|
||||
_sessionSemaphore = new SemaphoreLight(1);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(false);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelEofMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelCloseMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsConnectedAndChannelIsOpen_NoChannelCloseOrChannelEofReceived_SendChannelEofMessageFailure
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelSession _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(2000, 3000);
|
||||
_localPacketSize = (uint)random.Next(1000, 2000);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(100, 200);
|
||||
_sessionSemaphore = new SemaphoreLight(1);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(false);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelEofMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ChannelCloseMessageShouldBeSentOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
+127
-127
@@ -1,127 +1,127 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsNotConnectedAndChannelIsOpen_ChannelCloseAndChannelEofReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(false);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsNotConnectedAndChannelIsOpen_ChannelCloseAndChannelEofReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(false);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+124
-124
@@ -1,124 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsNotConnectedAndChannelIsOpen_ChannelCloseReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(false);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsNotConnectedAndChannelIsOpen_ChannelCloseReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(false);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+119
-119
@@ -1,119 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsNotConnectedAndChannelIsOpen_NoChannelCloseOrChannelEofReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(false);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNotHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Close_SessionIsNotConnectedAndChannelIsOpen_NoChannelCloseOrChannelEofReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(false);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNotHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Disposed_Closed : ChannelSessionTest_Close_Closed
|
||||
{
|
||||
protected override void Act()
|
||||
{
|
||||
Channel.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Disposed_Closed : ChannelSessionTest_Close_Closed
|
||||
{
|
||||
protected override void Act()
|
||||
{
|
||||
Channel.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+126
-126
@@ -1,126 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelSession _channel;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private MockSequence _sequence;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
_sequence = new MockSequence();
|
||||
_sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(_sequence)
|
||||
.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.Open();
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+113
-113
@@ -1,114 +1,114 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Open_ExceptionWaitingOnOpenConfirmation
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelSession _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
private Exception _waitOnConfirmationException;
|
||||
private SystemException _actualException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(2000, 3000);
|
||||
_localPacketSize = (uint)random.Next(1000, 2000);
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_waitOnConfirmationException = new SystemException();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(2);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Throws(_waitOnConfirmationException);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
try
|
||||
{
|
||||
_channel.Open();
|
||||
}
|
||||
catch (SystemException ex)
|
||||
{
|
||||
_actualException = ex;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OpenShouldHaveRethrownExceptionThrownByWaitOnHandle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Open_ExceptionWaitingOnOpenConfirmation
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelSession _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
private Exception _waitOnConfirmationException;
|
||||
private SystemException _actualException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(2000, 3000);
|
||||
_localPacketSize = (uint)random.Next(1000, 2000);
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_waitOnConfirmationException = new SystemException();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(2);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Throws(_waitOnConfirmationException);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
try
|
||||
{
|
||||
_channel.Open();
|
||||
}
|
||||
catch (SystemException ex)
|
||||
{
|
||||
_actualException = ex;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OpenShouldHaveRethrownExceptionThrownByWaitOnHandle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
+138
-138
@@ -1,139 +1,139 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Open_OnOpenFailureReceived_NoRetriesAvailable
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelSession _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
private uint _failureReasonCode;
|
||||
private string _failureDescription;
|
||||
private string _failureLanguage;
|
||||
private SshException _actualException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(2000, 3000);
|
||||
_localPacketSize = (uint) random.Next(1000, 2000);
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_actualException = null;
|
||||
|
||||
_failureReasonCode = (uint)random.Next(0, int.MaxValue);
|
||||
_failureDescription = random.Next().ToString(CultureInfo.InvariantCulture);
|
||||
_failureLanguage = random.Next().ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenFailureReceived += null,
|
||||
new MessageEventArgs<ChannelOpenFailureMessage>(
|
||||
new ChannelOpenFailureMessage(
|
||||
_localChannelNumber,
|
||||
_failureDescription,
|
||||
_failureReasonCode,
|
||||
_failureLanguage
|
||||
)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
try
|
||||
{
|
||||
_channel.Open();
|
||||
}
|
||||
catch (SshException ex)
|
||||
{
|
||||
_actualException = ex;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OpenShouldHaveThrownSshException()
|
||||
{
|
||||
Assert.IsNotNull(_actualException);
|
||||
Assert.AreEqual(typeof (SshException), _actualException.GetType());
|
||||
Assert.IsNull(_actualException.InnerException);
|
||||
Assert.AreEqual("Failed to open a channel after 1 attempts.", _actualException.Message);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Open_OnOpenFailureReceived_NoRetriesAvailable
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelSession _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
private uint _failureReasonCode;
|
||||
private string _failureDescription;
|
||||
private string _failureLanguage;
|
||||
private SshException _actualException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(2000, 3000);
|
||||
_localPacketSize = (uint) random.Next(1000, 2000);
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_actualException = null;
|
||||
|
||||
_failureReasonCode = (uint)random.Next(0, int.MaxValue);
|
||||
_failureDescription = random.Next().ToString(CultureInfo.InvariantCulture);
|
||||
_failureLanguage = random.Next().ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenFailureReceived += null,
|
||||
new MessageEventArgs<ChannelOpenFailureMessage>(
|
||||
new ChannelOpenFailureMessage(
|
||||
_localChannelNumber,
|
||||
_failureDescription,
|
||||
_failureReasonCode,
|
||||
_failureLanguage
|
||||
)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(1);
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
try
|
||||
{
|
||||
_channel.Open();
|
||||
}
|
||||
catch (SshException ex)
|
||||
{
|
||||
_actualException = ex;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OpenShouldHaveThrownSshException()
|
||||
{
|
||||
Assert.IsNotNull(_actualException);
|
||||
Assert.AreEqual(typeof (SshException), _actualException.GetType());
|
||||
Assert.IsNull(_actualException.InnerException);
|
||||
Assert.AreEqual("Failed to open a channel after 1 attempts.", _actualException.Message);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
+151
-151
@@ -1,152 +1,152 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Open_OnOpenFailureReceived_RetriesAvalable
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelSession _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
private uint _failureReasonCode;
|
||||
private string _failureDescription;
|
||||
private string _failureLanguage;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(2000, 3000);
|
||||
_localPacketSize = (uint)random.Next(1000, 2000);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_failureReasonCode = (uint)random.Next(0, int.MaxValue);
|
||||
_failureDescription = random.Next().ToString(CultureInfo.InvariantCulture);
|
||||
_failureLanguage = random.Next().ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(2);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenFailureReceived += null,
|
||||
new MessageEventArgs<ChannelOpenFailureMessage>(
|
||||
new ChannelOpenFailureMessage(
|
||||
_localChannelNumber,
|
||||
_failureDescription,
|
||||
_failureReasonCode,
|
||||
_failureLanguage
|
||||
)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(2);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Open();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeOneLessThanToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount - 1, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnTrue()
|
||||
{
|
||||
Assert.IsTrue(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelSessionTest_Open_OnOpenFailureReceived_RetriesAvalable
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private Mock<IConnectionInfo> _connectionInfoMock;
|
||||
private ChannelSession _channel;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private List<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private SemaphoreLight _sessionSemaphore;
|
||||
private int _initialSessionSemaphoreCount;
|
||||
private uint _failureReasonCode;
|
||||
private string _failureDescription;
|
||||
private string _failureLanguage;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(2000, 3000);
|
||||
_localPacketSize = (uint)random.Next(1000, 2000);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_initialSessionSemaphoreCount = random.Next(10, 20);
|
||||
_sessionSemaphore = new SemaphoreLight(_initialSessionSemaphoreCount);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_failureReasonCode = (uint)random.Next(0, int.MaxValue);
|
||||
_failureDescription = random.Next().ToString(CultureInfo.InvariantCulture);
|
||||
_failureLanguage = random.Next().ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_connectionInfoMock = new Mock<IConnectionInfo>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(2);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenFailureReceived += null,
|
||||
new MessageEventArgs<ChannelOpenFailureMessage>(
|
||||
new ChannelOpenFailureMessage(
|
||||
_localChannelNumber,
|
||||
_failureDescription,
|
||||
_failureReasonCode,
|
||||
_failureLanguage
|
||||
)));
|
||||
w.WaitOne();
|
||||
});
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
|
||||
_connectionInfoMock.InSequence(sequence).Setup(p => p.RetryAttempts).Returns(2);
|
||||
_sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(
|
||||
p =>
|
||||
p.SendMessage(
|
||||
It.Is<ChannelOpenMessage>(
|
||||
m =>
|
||||
m.LocalChannelNumber == _localChannelNumber &&
|
||||
m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
|
||||
m.Info is SessionChannelOpenInfo)));
|
||||
_sessionMock.InSequence(sequence)
|
||||
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
|
||||
.Callback<WaitHandle>(
|
||||
w =>
|
||||
{
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(
|
||||
_localChannelNumber,
|
||||
_remoteWindowSize,
|
||||
_remotePacketSize,
|
||||
_remoteChannelNumber)));
|
||||
w.WaitOne();
|
||||
});
|
||||
|
||||
_channel = new ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Open();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CurrentCountOfSessionSemaphoreShouldBeOneLessThanToInitialCount()
|
||||
{
|
||||
Assert.AreEqual(_initialSessionSemaphoreCount - 1, _sessionSemaphore.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnTrue()
|
||||
{
|
||||
Assert.IsTrue(_channel.IsOpen);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,140 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
internal class ChannelStub : Channel
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="ChannelStub"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="session">The session.</param>
|
||||
/// <param name="localChannelNumber">The local channel number.</param>
|
||||
/// <param name="localWindowSize">Size of the window.</param>
|
||||
/// <param name="localPacketSize">Size of the packet.</param>
|
||||
public ChannelStub(ISession session, uint localChannelNumber, uint localWindowSize, uint localPacketSize)
|
||||
: base(session, localChannelNumber, localWindowSize, localPacketSize)
|
||||
{
|
||||
OnErrorOccurredInvocations = new List<Exception>();
|
||||
}
|
||||
|
||||
public override ChannelTypes ChannelType
|
||||
{
|
||||
get { return ChannelTypes.X11; }
|
||||
}
|
||||
|
||||
public IList<Exception> OnErrorOccurredInvocations { get; private set; }
|
||||
|
||||
public Exception OnCloseException { get; set; }
|
||||
|
||||
public Exception OnDataException { get; set; }
|
||||
|
||||
public Exception OnDisconnectedException { get; set; }
|
||||
|
||||
public Exception OnEofException{ get; set; }
|
||||
|
||||
public Exception OnErrorOccurredException { get; set; }
|
||||
|
||||
public Exception OnExtendedDataException { get; set; }
|
||||
|
||||
public Exception OnFailureException { get; set; }
|
||||
|
||||
public Exception OnRequestException { get; set; }
|
||||
|
||||
public Exception OnSuccessException { get; set; }
|
||||
|
||||
public Exception OnWindowAdjustException { get; set; }
|
||||
|
||||
public void SetIsOpen(bool value)
|
||||
{
|
||||
IsOpen = value;
|
||||
}
|
||||
|
||||
public void InitializeRemoteChannelInfo(uint remoteChannelNumber, uint remoteWindowSize, uint remotePacketSize)
|
||||
{
|
||||
base.InitializeRemoteInfo(remoteChannelNumber, remoteWindowSize, remotePacketSize);
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
|
||||
if (OnCloseException != null)
|
||||
throw OnCloseException;
|
||||
}
|
||||
|
||||
protected override void OnData(byte[] data)
|
||||
{
|
||||
base.OnData(data);
|
||||
|
||||
if (OnDataException != null)
|
||||
throw OnDataException;
|
||||
}
|
||||
|
||||
protected override void OnDisconnected()
|
||||
{
|
||||
base.OnDisconnected();
|
||||
|
||||
if (OnDisconnectedException != null)
|
||||
throw OnDisconnectedException;
|
||||
}
|
||||
|
||||
protected override void OnEof()
|
||||
{
|
||||
base.OnEof();
|
||||
|
||||
if (OnEofException != null)
|
||||
throw OnEofException;
|
||||
}
|
||||
|
||||
protected override void OnExtendedData(byte[] data, uint dataTypeCode)
|
||||
{
|
||||
base.OnExtendedData(data, dataTypeCode);
|
||||
|
||||
if (OnExtendedDataException != null)
|
||||
throw OnExtendedDataException;
|
||||
}
|
||||
|
||||
protected override void OnErrorOccured(Exception exp)
|
||||
{
|
||||
OnErrorOccurredInvocations.Add(exp);
|
||||
|
||||
if (OnErrorOccurredException != null)
|
||||
throw OnErrorOccurredException;
|
||||
}
|
||||
|
||||
protected override void OnFailure()
|
||||
{
|
||||
base.OnFailure();
|
||||
|
||||
if (OnFailureException != null)
|
||||
throw OnFailureException;
|
||||
}
|
||||
|
||||
protected override void OnRequest(RequestInfo info)
|
||||
{
|
||||
base.OnRequest(info);
|
||||
|
||||
if (OnRequestException != null)
|
||||
throw OnRequestException;
|
||||
}
|
||||
|
||||
protected override void OnSuccess()
|
||||
{
|
||||
base.OnSuccess();
|
||||
|
||||
if (OnSuccessException != null)
|
||||
throw OnSuccessException;
|
||||
}
|
||||
|
||||
protected override void OnWindowAdjust(uint bytesToAdd)
|
||||
{
|
||||
base.OnWindowAdjust(bytesToAdd);
|
||||
|
||||
if (OnWindowAdjustException != null)
|
||||
throw OnWindowAdjustException;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
internal class ChannelStub : Channel
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="ChannelStub"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="session">The session.</param>
|
||||
/// <param name="localChannelNumber">The local channel number.</param>
|
||||
/// <param name="localWindowSize">Size of the window.</param>
|
||||
/// <param name="localPacketSize">Size of the packet.</param>
|
||||
public ChannelStub(ISession session, uint localChannelNumber, uint localWindowSize, uint localPacketSize)
|
||||
: base(session, localChannelNumber, localWindowSize, localPacketSize)
|
||||
{
|
||||
OnErrorOccurredInvocations = new List<Exception>();
|
||||
}
|
||||
|
||||
public override ChannelTypes ChannelType
|
||||
{
|
||||
get { return ChannelTypes.X11; }
|
||||
}
|
||||
|
||||
public IList<Exception> OnErrorOccurredInvocations { get; private set; }
|
||||
|
||||
public Exception OnCloseException { get; set; }
|
||||
|
||||
public Exception OnDataException { get; set; }
|
||||
|
||||
public Exception OnDisconnectedException { get; set; }
|
||||
|
||||
public Exception OnEofException{ get; set; }
|
||||
|
||||
public Exception OnErrorOccurredException { get; set; }
|
||||
|
||||
public Exception OnExtendedDataException { get; set; }
|
||||
|
||||
public Exception OnFailureException { get; set; }
|
||||
|
||||
public Exception OnRequestException { get; set; }
|
||||
|
||||
public Exception OnSuccessException { get; set; }
|
||||
|
||||
public Exception OnWindowAdjustException { get; set; }
|
||||
|
||||
public void SetIsOpen(bool value)
|
||||
{
|
||||
IsOpen = value;
|
||||
}
|
||||
|
||||
public void InitializeRemoteChannelInfo(uint remoteChannelNumber, uint remoteWindowSize, uint remotePacketSize)
|
||||
{
|
||||
base.InitializeRemoteInfo(remoteChannelNumber, remoteWindowSize, remotePacketSize);
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
|
||||
if (OnCloseException != null)
|
||||
throw OnCloseException;
|
||||
}
|
||||
|
||||
protected override void OnData(byte[] data)
|
||||
{
|
||||
base.OnData(data);
|
||||
|
||||
if (OnDataException != null)
|
||||
throw OnDataException;
|
||||
}
|
||||
|
||||
protected override void OnDisconnected()
|
||||
{
|
||||
base.OnDisconnected();
|
||||
|
||||
if (OnDisconnectedException != null)
|
||||
throw OnDisconnectedException;
|
||||
}
|
||||
|
||||
protected override void OnEof()
|
||||
{
|
||||
base.OnEof();
|
||||
|
||||
if (OnEofException != null)
|
||||
throw OnEofException;
|
||||
}
|
||||
|
||||
protected override void OnExtendedData(byte[] data, uint dataTypeCode)
|
||||
{
|
||||
base.OnExtendedData(data, dataTypeCode);
|
||||
|
||||
if (OnExtendedDataException != null)
|
||||
throw OnExtendedDataException;
|
||||
}
|
||||
|
||||
protected override void OnErrorOccured(Exception exp)
|
||||
{
|
||||
OnErrorOccurredInvocations.Add(exp);
|
||||
|
||||
if (OnErrorOccurredException != null)
|
||||
throw OnErrorOccurredException;
|
||||
}
|
||||
|
||||
protected override void OnFailure()
|
||||
{
|
||||
base.OnFailure();
|
||||
|
||||
if (OnFailureException != null)
|
||||
throw OnFailureException;
|
||||
}
|
||||
|
||||
protected override void OnRequest(RequestInfo info)
|
||||
{
|
||||
base.OnRequest(info);
|
||||
|
||||
if (OnRequestException != null)
|
||||
throw OnRequestException;
|
||||
}
|
||||
|
||||
protected override void OnSuccess()
|
||||
{
|
||||
base.OnSuccess();
|
||||
|
||||
if (OnSuccessException != null)
|
||||
throw OnSuccessException;
|
||||
}
|
||||
|
||||
protected override void OnWindowAdjust(uint bytesToAdd)
|
||||
{
|
||||
base.OnWindowAdjust(bytesToAdd);
|
||||
|
||||
if (OnWindowAdjustException != null)
|
||||
throw OnWindowAdjustException;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+76
-76
@@ -1,76 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_Close_SessionIsConnectedAndChannelIsNotOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private Channel _channel;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldNeverBeInvoked()
|
||||
{
|
||||
_sessionMock.Verify(p => p.SendMessage(It.IsAny<Message>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_Close_SessionIsConnectedAndChannelIsNotOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private Channel _channel;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldNeverBeInvoked()
|
||||
{
|
||||
_sessionMock.Verify(p => p.SendMessage(It.IsAny<Message>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+137
-137
@@ -1,137 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_Close_SessionIsConnectedAndChannelIsOpen_EofNotReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private Stopwatch _closeTimer;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_closeTimer = new Stopwatch();
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
|
||||
.Callback<WaitHandle>(w =>
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
// raise ChannelCloseReceived event to set waithandle for receiving
|
||||
// SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
|
||||
// sending the SSH_MSG_CHANNEL_CLOSE message to the server
|
||||
_sessionMock.Raise(s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(
|
||||
new ChannelCloseMessage(_localChannelNumber)));
|
||||
}).Start();
|
||||
_closeTimer.Start();
|
||||
try
|
||||
{
|
||||
w.WaitOne();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_closeTimer.Stop();
|
||||
}
|
||||
});
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldBeInvokedOnceForChannelCloseMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldBeInvokedOnceForChannelEofMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldBeInvokedOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldWaitForChannelCloseMessageToBeReceived()
|
||||
{
|
||||
Assert.IsTrue(_closeTimer.ElapsedMilliseconds >= 100, "Elapsed milliseconds=" + _closeTimer.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_Close_SessionIsConnectedAndChannelIsOpen_EofNotReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private Stopwatch _closeTimer;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_closeTimer = new Stopwatch();
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
|
||||
.Callback<WaitHandle>(w =>
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
// raise ChannelCloseReceived event to set waithandle for receiving
|
||||
// SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
|
||||
// sending the SSH_MSG_CHANNEL_CLOSE message to the server
|
||||
_sessionMock.Raise(s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(
|
||||
new ChannelCloseMessage(_localChannelNumber)));
|
||||
}).Start();
|
||||
_closeTimer.Start();
|
||||
try
|
||||
{
|
||||
w.WaitOne();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_closeTimer.Stop();
|
||||
}
|
||||
});
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldBeInvokedOnceForChannelCloseMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldBeInvokedOnceForChannelEofMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldBeInvokedOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldWaitForChannelCloseMessageToBeReceived()
|
||||
{
|
||||
Assert.IsTrue(_closeTimer.ElapsedMilliseconds >= 100, "Elapsed milliseconds=" + _closeTimer.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+137
-137
@@ -1,137 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_Close_SessionIsConnectedAndChannelIsOpen_EofNotReceived_SendEofInvoked
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private Stopwatch _closeTimer;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_closeTimer = new Stopwatch();
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.SendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)));
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
|
||||
.Callback<WaitHandle>(w =>
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
// raise ChannelCloseReceived event to set waithandle for receiving
|
||||
// SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
|
||||
// sending the SSH_MSG_CHANNEL_CLOSE message to the server
|
||||
_sessionMock.Raise(s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(
|
||||
new ChannelCloseMessage(_localChannelNumber)));
|
||||
}).Start();
|
||||
_closeTimer.Start();
|
||||
try
|
||||
{
|
||||
w.WaitOne();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_closeTimer.Stop();
|
||||
}
|
||||
});
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
_channel.SendEof();
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldBeInvokedOnceForChannelCloseMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldBeInvokedOnceForChannelEofMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.SendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldBeInvokedOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldWaitForChannelCloseMessageToBeReceived()
|
||||
{
|
||||
Assert.IsTrue(_closeTimer.ElapsedMilliseconds >= 100, "Elapsed milliseconds=" + _closeTimer.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_Close_SessionIsConnectedAndChannelIsOpen_EofNotReceived_SendEofInvoked
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private Stopwatch _closeTimer;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_closeTimer = new Stopwatch();
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.SendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)));
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
|
||||
.Callback<WaitHandle>(w =>
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
// raise ChannelCloseReceived event to set waithandle for receiving
|
||||
// SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
|
||||
// sending the SSH_MSG_CHANNEL_CLOSE message to the server
|
||||
_sessionMock.Raise(s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(
|
||||
new ChannelCloseMessage(_localChannelNumber)));
|
||||
}).Start();
|
||||
_closeTimer.Start();
|
||||
try
|
||||
{
|
||||
w.WaitOne();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_closeTimer.Stop();
|
||||
}
|
||||
});
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
_channel.SendEof();
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldBeInvokedOnceForChannelCloseMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldBeInvokedOnceForChannelEofMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.SendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldBeInvokedOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldWaitForChannelCloseMessageToBeReceived()
|
||||
{
|
||||
Assert.IsTrue(_closeTimer.ElapsedMilliseconds >= 100, "Elapsed milliseconds=" + _closeTimer.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+139
-139
@@ -1,139 +1,139 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_Close_SessionIsConnectedAndChannelIsOpen_EofReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private Stopwatch _closeTimer;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_closeTimer = new Stopwatch();
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
|
||||
.Callback<WaitHandle>(w =>
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
// raise ChannelCloseReceived event to set waithandle for receiving
|
||||
// SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
|
||||
// sending the SSH_MSG_CHANNEL_CLOSE message to the server
|
||||
_sessionMock.Raise(s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(
|
||||
new ChannelCloseMessage(_localChannelNumber)));
|
||||
}).Start();
|
||||
_closeTimer.Start();
|
||||
try
|
||||
{
|
||||
w.WaitOne();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_closeTimer.Stop();
|
||||
}
|
||||
});
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldBeInvokedOnceForChannelCloseMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldNeverBeInvokedForChannelEofMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldBeInvokedOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldWaitForChannelCloseMessageToBeReceived()
|
||||
{
|
||||
Assert.IsTrue(_closeTimer.ElapsedMilliseconds >= 100, "Elapsed milliseconds=" + _closeTimer.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_Close_SessionIsConnectedAndChannelIsOpen_EofReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private Stopwatch _closeTimer;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_closeTimer = new Stopwatch();
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
var sequence = new MockSequence();
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
_sessionMock.InSequence(sequence).Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
|
||||
.Callback<WaitHandle>(w =>
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
// raise ChannelCloseReceived event to set waithandle for receiving
|
||||
// SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
|
||||
// sending the SSH_MSG_CHANNEL_CLOSE message to the server
|
||||
_sessionMock.Raise(s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(
|
||||
new ChannelCloseMessage(_localChannelNumber)));
|
||||
}).Start();
|
||||
_closeTimer.Start();
|
||||
try
|
||||
{
|
||||
w.WaitOne();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_closeTimer.Stop();
|
||||
}
|
||||
});
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
|
||||
_sessionMock.Raise(
|
||||
s => s.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldBeInvokedOnceForChannelCloseMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldNeverBeInvokedForChannelEofMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldBeInvokedOnce()
|
||||
{
|
||||
_sessionMock.Verify(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldWaitForChannelCloseMessageToBeReceived()
|
||||
{
|
||||
Assert.IsTrue(_closeTimer.ElapsedMilliseconds >= 100, "Elapsed milliseconds=" + _closeTimer.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+76
-76
@@ -1,76 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_Close_SessionIsNotConnectedAndChannelIsNotOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private Channel _channel;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(false);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldNeverBeInvoked()
|
||||
{
|
||||
_sessionMock.Verify(p => p.SendMessage(It.IsAny<Message>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_Close_SessionIsNotConnectedAndChannelIsNotOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private Channel _channel;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint) random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(false);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldNeverBeInvoked()
|
||||
{
|
||||
_sessionMock.Verify(p => p.SendMessage(It.IsAny<Message>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+76
-76
@@ -1,76 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_Close_SessionIsNotConnectedAndChannelIsOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(false);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.SetIsOpen(true);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldNeverBeInvoked()
|
||||
{
|
||||
_sessionMock.Verify(p => p.SendMessage(It.IsAny<Message>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_Close_SessionIsNotConnectedAndChannelIsOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(false);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.SetIsOpen(true);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.Close();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldNeverBeInvoked()
|
||||
{
|
||||
_sessionMock.Verify(p => p.SendMessage(It.IsAny<Message>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+64
-64
@@ -1,64 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelCloseReceived_OnClose_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onCloseException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onCloseException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnCloseException = _onCloseException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onCloseException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onCloseException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelCloseReceived_OnClose_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onCloseException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onCloseException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnCloseException = _onCloseException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onCloseException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onCloseException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+103
-103
@@ -1,103 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen_EofNotReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelStub _channel;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldBeInvokedOnceForChannelCloseMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldNeverBeInvokedForChannelEofMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldNeverBeInvoked()
|
||||
{
|
||||
_sessionMock.Verify(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen_EofNotReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelStub _channel;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldBeInvokedOnceForChannelCloseMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldNeverBeInvokedForChannelEofMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldNeverBeInvoked()
|
||||
{
|
||||
_sessionMock.Verify(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+108
-108
@@ -1,108 +1,108 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen_EofReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelStub _channel;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
|
||||
_sessionMock.Raise(p => p.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldBeInvokedOnceForChannelCloseMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldNeverBeInvokedForChannelEofMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldNeverBeInvoked()
|
||||
{
|
||||
_sessionMock.Verify(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelCloseReceived_SessionIsConnectedAndChannelIsOpen_EofReceived
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private IList<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private ChannelStub _channel;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
_sessionMock.Setup(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
|
||||
.Returns(true);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
|
||||
_sessionMock.Raise(p => p.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(p => p.ChannelCloseReceived += null,
|
||||
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TrySendMessageOnSessionShouldBeInvokedOnceForChannelCloseMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldNeverBeInvokedForChannelEofMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.TrySendMessage(It.Is<ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitOnHandleOnSessionShouldNeverBeInvoked()
|
||||
{
|
||||
_sessionMock.Verify(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelClosedRegister.Count);
|
||||
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+64
-64
@@ -1,64 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelDataReceived_OnData_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onDataException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onDataException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnDataException = _onDataException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelDataReceived += null,
|
||||
new MessageEventArgs<ChannelDataMessage>(new ChannelDataMessage(_localChannelNumber, new byte[0])));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onDataException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onDataException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelDataReceived_OnData_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onDataException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onDataException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnDataException = _onDataException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelDataReceived += null,
|
||||
new MessageEventArgs<ChannelDataMessage>(new ChannelDataMessage(_localChannelNumber, new byte[0])));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onDataException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onDataException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+72
-72
@@ -1,72 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelEofReceived_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onEofException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(0, 1000);
|
||||
_localPacketSize = (uint)random.Next(1001, int.MaxValue);
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_onEofException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
_channel.OnEofException = _onEofException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onEofException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onEofException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelEofReceived_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onEofException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(0, 1000);
|
||||
_localPacketSize = (uint)random.Next(1001, int.MaxValue);
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_onEofException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
_channel.OnEofException = _onEofException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelEofReceived += null,
|
||||
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onEofException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onEofException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+64
-64
@@ -1,64 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelExtendedDataReceived_OnExtendedData_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onExtendedDataException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onExtendedDataException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnExtendedDataException = _onExtendedDataException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelExtendedDataReceived += null,
|
||||
new MessageEventArgs<ChannelExtendedDataMessage>(new ChannelExtendedDataMessage(_localChannelNumber, 5, new byte[0])));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onExtendedDataException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onExtendedDataException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelExtendedDataReceived_OnExtendedData_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onExtendedDataException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onExtendedDataException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnExtendedDataException = _onExtendedDataException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelExtendedDataReceived += null,
|
||||
new MessageEventArgs<ChannelExtendedDataMessage>(new ChannelExtendedDataMessage(_localChannelNumber, 5, new byte[0])));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onExtendedDataException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onExtendedDataException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+64
-64
@@ -1,64 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelFailureReceived_OnFailure_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onFailureException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(0, 1000);
|
||||
_localPacketSize = (uint)random.Next(1001, int.MaxValue);
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onFailureException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnFailureException = _onFailureException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelFailureReceived += null,
|
||||
new MessageEventArgs<ChannelFailureMessage>(new ChannelFailureMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onFailureException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onFailureException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelFailureReceived_OnFailure_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onFailureException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(0, 1000);
|
||||
_localPacketSize = (uint)random.Next(1001, int.MaxValue);
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onFailureException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnFailureException = _onFailureException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelFailureReceived += null,
|
||||
new MessageEventArgs<ChannelFailureMessage>(new ChannelFailureMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onFailureException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onFailureException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+68
-68
@@ -1,68 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelRequestReceived_OnRequest_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onRequestException;
|
||||
private SignalRequestInfo _requestInfo;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onRequestException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_requestInfo = new SignalRequestInfo("ABC");
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_sessionMock.Setup(p => p.ConnectionInfo)
|
||||
.Returns(new ConnectionInfo("host", "user", new PasswordAuthenticationMethod("user", "password")));
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnRequestException = _onRequestException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelRequestReceived += null,
|
||||
new MessageEventArgs<ChannelRequestMessage>(new ChannelRequestMessage(_localChannelNumber, _requestInfo)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onRequestException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onRequestException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelRequestReceived_OnRequest_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onRequestException;
|
||||
private SignalRequestInfo _requestInfo;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onRequestException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_requestInfo = new SignalRequestInfo("ABC");
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
_sessionMock.Setup(p => p.ConnectionInfo)
|
||||
.Returns(new ConnectionInfo("host", "user", new PasswordAuthenticationMethod("user", "password")));
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnRequestException = _onRequestException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelRequestReceived += null,
|
||||
new MessageEventArgs<ChannelRequestMessage>(new ChannelRequestMessage(_localChannelNumber, _requestInfo)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onRequestException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onRequestException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+64
-64
@@ -1,64 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelSuccessReceived_OnSuccess_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onSuccessException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, 1000);
|
||||
_localPacketSize = (uint)random.Next(1001, int.MaxValue);
|
||||
_onSuccessException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnSuccessException = _onSuccessException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelSuccessReceived += null,
|
||||
new MessageEventArgs<ChannelSuccessMessage>(new ChannelSuccessMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onSuccessException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onSuccessException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelSuccessReceived_OnSuccess_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onSuccessException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, 1000);
|
||||
_localPacketSize = (uint)random.Next(1001, int.MaxValue);
|
||||
_onSuccessException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnSuccessException = _onSuccessException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelSuccessReceived += null,
|
||||
new MessageEventArgs<ChannelSuccessMessage>(new ChannelSuccessMessage(_localChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onSuccessException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onSuccessException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+73
-73
@@ -1,73 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelWindowAdjustReceived_OnWindowAdjust_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onWindowAdjustException;
|
||||
private uint _bytesToAdd;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_remotePacketSize = _localWindowSize - 1;
|
||||
_bytesToAdd = (uint)random.Next(0, int.MaxValue);
|
||||
_onWindowAdjustException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnWindowAdjustException = _onWindowAdjustException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelWindowAdjustReceived += null,
|
||||
new MessageEventArgs<ChannelWindowAdjustMessage>(new ChannelWindowAdjustMessage(_localChannelNumber, _bytesToAdd)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onWindowAdjustException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onWindowAdjustException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionChannelWindowAdjustReceived_OnWindowAdjust_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onWindowAdjustException;
|
||||
private uint _bytesToAdd;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_remotePacketSize = _localWindowSize - 1;
|
||||
_bytesToAdd = (uint)random.Next(0, int.MaxValue);
|
||||
_onWindowAdjustException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnWindowAdjustException = _onWindowAdjustException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelWindowAdjustReceived += null,
|
||||
new MessageEventArgs<ChannelWindowAdjustMessage>(new ChannelWindowAdjustMessage(_localChannelNumber, _bytesToAdd)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onWindowAdjustException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onWindowAdjustException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+62
-62
@@ -1,62 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionDisconnected_OnDisconnected_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onDisconnectedException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onDisconnectedException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnDisconnectedException = _onDisconnectedException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.Disconnected += null, EventArgs.Empty);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onDisconnectedException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onDisconnectedException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionDisconnected_OnDisconnected_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onDisconnectedException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onDisconnectedException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnDisconnectedException = _onDisconnectedException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.Disconnected += null, EventArgs.Empty);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onDisconnectedException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onDisconnectedException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+76
-76
@@ -1,76 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionDisconnected_SessionIsConnectedAndChannelIsOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.Disconnected += null, EventArgs.Empty);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionDisconnected_SessionIsConnectedAndChannelIsOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.IsConnected).Returns(true);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.Disconnected += null, EventArgs.Empty);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+64
-64
@@ -1,64 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionErrorOccurred_OnErrorOccurred_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onErrorOccurredException;
|
||||
private Exception _errorOccurredException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onErrorOccurredException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_errorOccurredException = new SystemException();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnErrorOccurredException = _onErrorOccurredException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ErrorOccured += null, new ExceptionEventArgs(_errorOccurredException));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onErrorOccurredException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_errorOccurredException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_OnSessionErrorOccurred_OnErrorOccurred_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onErrorOccurredException;
|
||||
private Exception _errorOccurredException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_onErrorOccurredException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_errorOccurredException = new SystemException();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnErrorOccurredException = _onErrorOccurredException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ErrorOccured += null, new ExceptionEventArgs(_errorOccurredException));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onErrorOccurredException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_errorOccurredException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_SendEof_ChannelIsNotOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private InvalidOperationException _actualException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_actualException = null;
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
try
|
||||
{
|
||||
_channel.SendEof();
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_actualException = ex;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendEofShouldHaveThrownInvalidOperationException()
|
||||
{
|
||||
Assert.IsNotNull(_actualException);
|
||||
Assert.IsNull(_actualException.InnerException);
|
||||
Assert.AreEqual("The channel is closed.", _actualException.Message);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldNeverBeInvoked()
|
||||
{
|
||||
_sessionMock.Verify(p => p.SendMessage(It.IsAny<Message>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_SendEof_ChannelIsNotOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _localChannelNumber;
|
||||
private ChannelStub _channel;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private InvalidOperationException _actualException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
_actualException = null;
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
try
|
||||
{
|
||||
_channel.SendEof();
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_actualException = ex;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnFalse()
|
||||
{
|
||||
Assert.IsFalse(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendEofShouldHaveThrownInvalidOperationException()
|
||||
{
|
||||
Assert.IsNotNull(_actualException);
|
||||
Assert.IsNull(_actualException.InnerException);
|
||||
Assert.AreEqual("The channel is closed.", _actualException.Message);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldNeverBeInvoked()
|
||||
{
|
||||
_sessionMock.Verify(p => p.SendMessage(It.IsAny<Message>()), Times.Never);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,85 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_SendEof_ChannelIsOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.SendMessage(It.Is<ChannelEofMessage>(e => e.LocalChannelNumber == _remoteChannelNumber)));
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.SendEof();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnTrue()
|
||||
{
|
||||
Assert.IsTrue(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldBeInvokedOnceWithChannelEofMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.SendMessage(It.Is<ChannelEofMessage>(e => e.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ChannelTest_SendEof_ChannelIsOpen
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private uint _remoteWindowSize;
|
||||
private uint _remotePacketSize;
|
||||
private ChannelStub _channel;
|
||||
private List<ChannelEventArgs> _channelClosedRegister;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_localPacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_remoteWindowSize = (uint)random.Next(0, int.MaxValue);
|
||||
_remotePacketSize = (uint)random.Next(0, int.MaxValue);
|
||||
_channelClosedRegister = new List<ChannelEventArgs>();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_sessionMock.Setup(p => p.SendMessage(It.Is<ChannelEofMessage>(e => e.LocalChannelNumber == _remoteChannelNumber)));
|
||||
|
||||
_channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
|
||||
_channel.SetIsOpen(true);
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_channel.SendEof();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsOpenShouldReturnTrue()
|
||||
{
|
||||
Assert.IsTrue(_channel.IsOpen);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessageOnSessionShouldBeInvokedOnceWithChannelEofMessage()
|
||||
{
|
||||
_sessionMock.Verify(
|
||||
p => p.SendMessage(It.Is<ChannelEofMessage>(e => e.LocalChannelNumber == _remoteChannelNumber)),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ClosedEventShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelClosedRegister.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionShouldNeverHaveFired()
|
||||
{
|
||||
Assert.AreEqual(0, _channelExceptionRegister.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,160 +1,160 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
internal class ClientChannelStub : ClientChannel
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="ClientChannelStub"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="session">The session.</param>
|
||||
/// <param name="localChannelNumber">The local channel number.</param>
|
||||
/// <param name="localWindowSize">Size of the window.</param>
|
||||
/// <param name="localPacketSize">Size of the packet.</param>
|
||||
public ClientChannelStub(ISession session, uint localChannelNumber, uint localWindowSize, uint localPacketSize)
|
||||
: base(session, localChannelNumber, localWindowSize, localPacketSize)
|
||||
{
|
||||
OnErrorOccurredInvocations = new List<Exception>();
|
||||
}
|
||||
|
||||
public override ChannelTypes ChannelType
|
||||
{
|
||||
get { return ChannelTypes.X11; }
|
||||
}
|
||||
|
||||
public IList<Exception> OnErrorOccurredInvocations { get; private set; }
|
||||
|
||||
public Exception OnCloseException { get; set; }
|
||||
|
||||
public Exception OnDataException { get; set; }
|
||||
|
||||
public Exception OnDisconnectedException { get; set; }
|
||||
|
||||
public Exception OnEofException{ get; set; }
|
||||
|
||||
public Exception OnErrorOccurredException { get; set; }
|
||||
|
||||
public Exception OnExtendedDataException { get; set; }
|
||||
|
||||
public Exception OnFailureException { get; set; }
|
||||
|
||||
public Exception OnRequestException { get; set; }
|
||||
|
||||
public Exception OnSuccessException { get; set; }
|
||||
|
||||
public Exception OnWindowAdjustException { get; set; }
|
||||
|
||||
public Exception OnOpenConfirmationException { get; set; }
|
||||
|
||||
public Exception OnOpenFailureException { get; set; }
|
||||
|
||||
public void SetIsOpen(bool value)
|
||||
{
|
||||
IsOpen = value;
|
||||
}
|
||||
|
||||
public void InitializeRemoteChannelInfo(uint remoteChannelNumber, uint remoteWindowSize, uint remotePacketSize)
|
||||
{
|
||||
base.InitializeRemoteInfo(remoteChannelNumber, remoteWindowSize, remotePacketSize);
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
|
||||
if (OnCloseException != null)
|
||||
throw OnCloseException;
|
||||
}
|
||||
|
||||
protected override void OnData(byte[] data)
|
||||
{
|
||||
base.OnData(data);
|
||||
|
||||
if (OnDataException != null)
|
||||
throw OnDataException;
|
||||
}
|
||||
|
||||
protected override void OnDisconnected()
|
||||
{
|
||||
base.OnDisconnected();
|
||||
|
||||
if (OnDisconnectedException != null)
|
||||
throw OnDisconnectedException;
|
||||
}
|
||||
|
||||
protected override void OnEof()
|
||||
{
|
||||
base.OnEof();
|
||||
|
||||
if (OnEofException != null)
|
||||
throw OnEofException;
|
||||
}
|
||||
|
||||
protected override void OnExtendedData(byte[] data, uint dataTypeCode)
|
||||
{
|
||||
base.OnExtendedData(data, dataTypeCode);
|
||||
|
||||
if (OnExtendedDataException != null)
|
||||
throw OnExtendedDataException;
|
||||
}
|
||||
|
||||
protected override void OnErrorOccured(Exception exp)
|
||||
{
|
||||
OnErrorOccurredInvocations.Add(exp);
|
||||
|
||||
if (OnErrorOccurredException != null)
|
||||
throw OnErrorOccurredException;
|
||||
}
|
||||
|
||||
protected override void OnFailure()
|
||||
{
|
||||
base.OnFailure();
|
||||
|
||||
if (OnFailureException != null)
|
||||
throw OnFailureException;
|
||||
}
|
||||
|
||||
protected override void OnRequest(RequestInfo info)
|
||||
{
|
||||
base.OnRequest(info);
|
||||
|
||||
if (OnRequestException != null)
|
||||
throw OnRequestException;
|
||||
}
|
||||
|
||||
protected override void OnSuccess()
|
||||
{
|
||||
base.OnSuccess();
|
||||
|
||||
if (OnSuccessException != null)
|
||||
throw OnSuccessException;
|
||||
}
|
||||
|
||||
protected override void OnWindowAdjust(uint bytesToAdd)
|
||||
{
|
||||
base.OnWindowAdjust(bytesToAdd);
|
||||
|
||||
if (OnWindowAdjustException != null)
|
||||
throw OnWindowAdjustException;
|
||||
}
|
||||
|
||||
protected override void OnOpenConfirmation(uint remoteChannelNumber, uint initialWindowSize, uint maximumPacketSize)
|
||||
{
|
||||
base.OnOpenConfirmation(remoteChannelNumber, initialWindowSize, maximumPacketSize);
|
||||
|
||||
if (OnOpenConfirmationException != null)
|
||||
throw OnOpenConfirmationException;
|
||||
}
|
||||
|
||||
protected override void OnOpenFailure(uint reasonCode, string description, string language)
|
||||
{
|
||||
base.OnOpenFailure(reasonCode, description, language);
|
||||
|
||||
if (OnOpenFailureException != null)
|
||||
throw OnOpenFailureException;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Renci.SshNet.Channels;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
internal class ClientChannelStub : ClientChannel
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="ClientChannelStub"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="session">The session.</param>
|
||||
/// <param name="localChannelNumber">The local channel number.</param>
|
||||
/// <param name="localWindowSize">Size of the window.</param>
|
||||
/// <param name="localPacketSize">Size of the packet.</param>
|
||||
public ClientChannelStub(ISession session, uint localChannelNumber, uint localWindowSize, uint localPacketSize)
|
||||
: base(session, localChannelNumber, localWindowSize, localPacketSize)
|
||||
{
|
||||
OnErrorOccurredInvocations = new List<Exception>();
|
||||
}
|
||||
|
||||
public override ChannelTypes ChannelType
|
||||
{
|
||||
get { return ChannelTypes.X11; }
|
||||
}
|
||||
|
||||
public IList<Exception> OnErrorOccurredInvocations { get; private set; }
|
||||
|
||||
public Exception OnCloseException { get; set; }
|
||||
|
||||
public Exception OnDataException { get; set; }
|
||||
|
||||
public Exception OnDisconnectedException { get; set; }
|
||||
|
||||
public Exception OnEofException{ get; set; }
|
||||
|
||||
public Exception OnErrorOccurredException { get; set; }
|
||||
|
||||
public Exception OnExtendedDataException { get; set; }
|
||||
|
||||
public Exception OnFailureException { get; set; }
|
||||
|
||||
public Exception OnRequestException { get; set; }
|
||||
|
||||
public Exception OnSuccessException { get; set; }
|
||||
|
||||
public Exception OnWindowAdjustException { get; set; }
|
||||
|
||||
public Exception OnOpenConfirmationException { get; set; }
|
||||
|
||||
public Exception OnOpenFailureException { get; set; }
|
||||
|
||||
public void SetIsOpen(bool value)
|
||||
{
|
||||
IsOpen = value;
|
||||
}
|
||||
|
||||
public void InitializeRemoteChannelInfo(uint remoteChannelNumber, uint remoteWindowSize, uint remotePacketSize)
|
||||
{
|
||||
base.InitializeRemoteInfo(remoteChannelNumber, remoteWindowSize, remotePacketSize);
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
|
||||
if (OnCloseException != null)
|
||||
throw OnCloseException;
|
||||
}
|
||||
|
||||
protected override void OnData(byte[] data)
|
||||
{
|
||||
base.OnData(data);
|
||||
|
||||
if (OnDataException != null)
|
||||
throw OnDataException;
|
||||
}
|
||||
|
||||
protected override void OnDisconnected()
|
||||
{
|
||||
base.OnDisconnected();
|
||||
|
||||
if (OnDisconnectedException != null)
|
||||
throw OnDisconnectedException;
|
||||
}
|
||||
|
||||
protected override void OnEof()
|
||||
{
|
||||
base.OnEof();
|
||||
|
||||
if (OnEofException != null)
|
||||
throw OnEofException;
|
||||
}
|
||||
|
||||
protected override void OnExtendedData(byte[] data, uint dataTypeCode)
|
||||
{
|
||||
base.OnExtendedData(data, dataTypeCode);
|
||||
|
||||
if (OnExtendedDataException != null)
|
||||
throw OnExtendedDataException;
|
||||
}
|
||||
|
||||
protected override void OnErrorOccured(Exception exp)
|
||||
{
|
||||
OnErrorOccurredInvocations.Add(exp);
|
||||
|
||||
if (OnErrorOccurredException != null)
|
||||
throw OnErrorOccurredException;
|
||||
}
|
||||
|
||||
protected override void OnFailure()
|
||||
{
|
||||
base.OnFailure();
|
||||
|
||||
if (OnFailureException != null)
|
||||
throw OnFailureException;
|
||||
}
|
||||
|
||||
protected override void OnRequest(RequestInfo info)
|
||||
{
|
||||
base.OnRequest(info);
|
||||
|
||||
if (OnRequestException != null)
|
||||
throw OnRequestException;
|
||||
}
|
||||
|
||||
protected override void OnSuccess()
|
||||
{
|
||||
base.OnSuccess();
|
||||
|
||||
if (OnSuccessException != null)
|
||||
throw OnSuccessException;
|
||||
}
|
||||
|
||||
protected override void OnWindowAdjust(uint bytesToAdd)
|
||||
{
|
||||
base.OnWindowAdjust(bytesToAdd);
|
||||
|
||||
if (OnWindowAdjustException != null)
|
||||
throw OnWindowAdjustException;
|
||||
}
|
||||
|
||||
protected override void OnOpenConfirmation(uint remoteChannelNumber, uint initialWindowSize, uint maximumPacketSize)
|
||||
{
|
||||
base.OnOpenConfirmation(remoteChannelNumber, initialWindowSize, maximumPacketSize);
|
||||
|
||||
if (OnOpenConfirmationException != null)
|
||||
throw OnOpenConfirmationException;
|
||||
}
|
||||
|
||||
protected override void OnOpenFailure(uint reasonCode, string description, string language)
|
||||
{
|
||||
base.OnOpenFailure(reasonCode, description, language);
|
||||
|
||||
if (OnOpenFailureException != null)
|
||||
throw OnOpenFailureException;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+68
-68
@@ -1,68 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientChannelTest_OnSessionChannelOpenConfirmationReceived_OnOpenConfirmation_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private ClientChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onOpenConfirmationException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_onOpenConfirmationException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ClientChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnOpenConfirmationException = _onOpenConfirmationException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(_localChannelNumber, _localWindowSize, _localPacketSize,
|
||||
_remoteChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onOpenConfirmationException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onOpenConfirmationException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientChannelTest_OnSessionChannelOpenConfirmationReceived_OnOpenConfirmation_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private uint _remoteChannelNumber;
|
||||
private ClientChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onOpenConfirmationException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint) random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_remoteChannelNumber = (uint) random.Next(0, int.MaxValue);
|
||||
_onOpenConfirmationException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ClientChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnOpenConfirmationException = _onOpenConfirmationException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelOpenConfirmationReceived += null,
|
||||
new MessageEventArgs<ChannelOpenConfirmationMessage>(
|
||||
new ChannelOpenConfirmationMessage(_localChannelNumber, _localWindowSize, _localPacketSize,
|
||||
_remoteChannelNumber)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onOpenConfirmationException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onOpenConfirmationException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+65
-65
@@ -1,65 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientChannelTest_OnSessionChannelOpenFailureReceived_OnOpenFailure_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private ClientChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onOpenFailureException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_onOpenFailureException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ClientChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnOpenFailureException = _onOpenFailureException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelOpenFailureReceived += null,
|
||||
new MessageEventArgs<ChannelOpenFailureMessage>(
|
||||
new ChannelOpenFailureMessage(_localChannelNumber, "", ChannelOpenFailureMessage.ConnectFailed)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onOpenFailureException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onOpenFailureException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Messages.Connection;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Channels
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientChannelTest_OnSessionChannelOpenFailureReceived_OnOpenFailure_Exception
|
||||
{
|
||||
private Mock<ISession> _sessionMock;
|
||||
private uint _localChannelNumber;
|
||||
private uint _localWindowSize;
|
||||
private uint _localPacketSize;
|
||||
private ClientChannelStub _channel;
|
||||
private IList<ExceptionEventArgs> _channelExceptionRegister;
|
||||
private Exception _onOpenFailureException;
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Arrange();
|
||||
Act();
|
||||
}
|
||||
|
||||
private void Arrange()
|
||||
{
|
||||
var random = new Random();
|
||||
_localChannelNumber = (uint)random.Next(0, int.MaxValue);
|
||||
_localWindowSize = (uint)random.Next(1000, int.MaxValue);
|
||||
_localPacketSize = _localWindowSize - 1;
|
||||
_onOpenFailureException = new SystemException();
|
||||
_channelExceptionRegister = new List<ExceptionEventArgs>();
|
||||
|
||||
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
|
||||
_channel = new ClientChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
|
||||
_channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
|
||||
_channel.OnOpenFailureException = _onOpenFailureException;
|
||||
}
|
||||
|
||||
private void Act()
|
||||
{
|
||||
_sessionMock.Raise(s => s.ChannelOpenFailureReceived += null,
|
||||
new MessageEventArgs<ChannelOpenFailureMessage>(
|
||||
new ChannelOpenFailureMessage(_localChannelNumber, "", ChannelOpenFailureMessage.ConnectFailed)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ExceptionEventShouldHaveFiredOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channelExceptionRegister.Count);
|
||||
Assert.AreSame(_onOpenFailureException, _channelExceptionRegister[0].Exception);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OnErrorOccuredShouldBeInvokedOnce()
|
||||
{
|
||||
Assert.AreEqual(1, _channel.OnErrorOccurredInvocations.Count);
|
||||
Assert.AreSame(_onOpenFailureException, _channel.OnErrorOccurredInvocations[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Security.Cryptography;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
using System;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds information about key size and cipher to use
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class CipherInfoTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for CipherInfo Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CipherInfoConstructorTest()
|
||||
{
|
||||
int keySize = 0; // TODO: Initialize to an appropriate value
|
||||
Func<byte[], byte[], Cipher> cipher = null; // TODO: Initialize to an appropriate value
|
||||
CipherInfo target = new CipherInfo(keySize, cipher);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Security.Cryptography;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
using System;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds information about key size and cipher to use
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class CipherInfoTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for CipherInfo Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CipherInfoConstructorTest()
|
||||
{
|
||||
int keySize = 0; // TODO: Initialize to an appropriate value
|
||||
Func<byte[], byte[], Cipher> cipher = null; // TODO: Initialize to an appropriate value
|
||||
CipherInfo target = new CipherInfo(keySize, cipher);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +1,54 @@
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest
|
||||
{
|
||||
private ClientAuthentication _clientAuthentication;
|
||||
|
||||
[TestInitialize]
|
||||
public void Init()
|
||||
{
|
||||
_clientAuthentication = new ClientAuthentication();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AuthenticateShouldThrowArgumentNullExceptionWhenConnectionInfoIsNull()
|
||||
{
|
||||
IConnectionInfoInternal connectionInfo = null;
|
||||
var session = new Mock<ISession>(MockBehavior.Strict).Object;
|
||||
|
||||
try
|
||||
{
|
||||
_clientAuthentication.Authenticate(connectionInfo, session);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
Assert.IsNull(ex.InnerException);
|
||||
Assert.AreEqual("connectionInfo", ex.ParamName);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AuthenticateShouldThrowArgumentNullExceptionWhenSessionIsNull()
|
||||
{
|
||||
var connectionInfo = new Mock<IConnectionInfoInternal>(MockBehavior.Strict).Object;
|
||||
ISession session = null;
|
||||
|
||||
try
|
||||
{
|
||||
_clientAuthentication.Authenticate(connectionInfo, session);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
Assert.IsNull(ex.InnerException);
|
||||
Assert.AreEqual("session", ex.ParamName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest
|
||||
{
|
||||
private ClientAuthentication _clientAuthentication;
|
||||
|
||||
[TestInitialize]
|
||||
public void Init()
|
||||
{
|
||||
_clientAuthentication = new ClientAuthentication();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AuthenticateShouldThrowArgumentNullExceptionWhenConnectionInfoIsNull()
|
||||
{
|
||||
IConnectionInfoInternal connectionInfo = null;
|
||||
var session = new Mock<ISession>(MockBehavior.Strict).Object;
|
||||
|
||||
try
|
||||
{
|
||||
_clientAuthentication.Authenticate(connectionInfo, session);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
Assert.IsNull(ex.InnerException);
|
||||
Assert.AreEqual("connectionInfo", ex.ParamName);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AuthenticateShouldThrowArgumentNullExceptionWhenSessionIsNull()
|
||||
{
|
||||
var connectionInfo = new Mock<IConnectionInfoInternal>(MockBehavior.Strict).Object;
|
||||
ISession session = null;
|
||||
|
||||
try
|
||||
{
|
||||
_clientAuthentication.Authenticate(connectionInfo, session);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
Assert.IsNull(ex.InnerException);
|
||||
Assert.AreEqual("session", ex.ParamName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,81 +1,81 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public abstract class ClientAuthenticationTestBase : TestBase
|
||||
{
|
||||
internal Mock<IConnectionInfoInternal> ConnectionInfoMock { get; private set; }
|
||||
internal Mock<ISession> SessionMock { get; private set; }
|
||||
internal Mock<IAuthenticationMethod> NoneAuthenticationMethodMock { get; private set; }
|
||||
internal Mock<IAuthenticationMethod> PasswordAuthenticationMethodMock { get; private set; }
|
||||
internal Mock<IAuthenticationMethod> PublicKeyAuthenticationMethodMock { get; private set; }
|
||||
internal Mock<IAuthenticationMethod> KeyboardInteractiveAuthenticationMethodMock { get; private set; }
|
||||
internal ClientAuthentication ClientAuthentication { get; private set; }
|
||||
|
||||
protected void CreateMocks()
|
||||
{
|
||||
ConnectionInfoMock = new Mock<IConnectionInfoInternal>(MockBehavior.Strict);
|
||||
SessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
NoneAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
|
||||
PasswordAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
|
||||
PublicKeyAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
|
||||
KeyboardInteractiveAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
|
||||
}
|
||||
|
||||
protected abstract void SetupMocks();
|
||||
|
||||
protected abstract void Act();
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
|
||||
// Arrange
|
||||
CreateMocks();
|
||||
SetupMocks();
|
||||
ClientAuthentication = new ClientAuthentication();
|
||||
|
||||
// Act
|
||||
Act();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RegisterMessageWithUserAuthFailureShouldBeInvokedOnce()
|
||||
{
|
||||
SessionMock.Verify(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RegisterMessageWithUserAuthSuccessShouldBeInvokedOnce()
|
||||
{
|
||||
SessionMock.Verify(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RegisterMessageWithUserAuthBannerShouldBeInvokedOnce()
|
||||
{
|
||||
SessionMock.Verify(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnRegisterMessageWithUserAuthFailureShouldBeInvokedOnce()
|
||||
{
|
||||
SessionMock.Verify(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnRegisterMessageWithUserAuthSuccessShouldBeInvokedOnce()
|
||||
{
|
||||
SessionMock.Verify(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnRegisterMessageWithUserAuthBannerShouldBeInvokedOnce()
|
||||
{
|
||||
SessionMock.Verify(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public abstract class ClientAuthenticationTestBase : TestBase
|
||||
{
|
||||
internal Mock<IConnectionInfoInternal> ConnectionInfoMock { get; private set; }
|
||||
internal Mock<ISession> SessionMock { get; private set; }
|
||||
internal Mock<IAuthenticationMethod> NoneAuthenticationMethodMock { get; private set; }
|
||||
internal Mock<IAuthenticationMethod> PasswordAuthenticationMethodMock { get; private set; }
|
||||
internal Mock<IAuthenticationMethod> PublicKeyAuthenticationMethodMock { get; private set; }
|
||||
internal Mock<IAuthenticationMethod> KeyboardInteractiveAuthenticationMethodMock { get; private set; }
|
||||
internal ClientAuthentication ClientAuthentication { get; private set; }
|
||||
|
||||
protected void CreateMocks()
|
||||
{
|
||||
ConnectionInfoMock = new Mock<IConnectionInfoInternal>(MockBehavior.Strict);
|
||||
SessionMock = new Mock<ISession>(MockBehavior.Strict);
|
||||
NoneAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
|
||||
PasswordAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
|
||||
PublicKeyAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
|
||||
KeyboardInteractiveAuthenticationMethodMock = new Mock<IAuthenticationMethod>(MockBehavior.Strict);
|
||||
}
|
||||
|
||||
protected abstract void SetupMocks();
|
||||
|
||||
protected abstract void Act();
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
|
||||
// Arrange
|
||||
CreateMocks();
|
||||
SetupMocks();
|
||||
ClientAuthentication = new ClientAuthentication();
|
||||
|
||||
// Act
|
||||
Act();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RegisterMessageWithUserAuthFailureShouldBeInvokedOnce()
|
||||
{
|
||||
SessionMock.Verify(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RegisterMessageWithUserAuthSuccessShouldBeInvokedOnce()
|
||||
{
|
||||
SessionMock.Verify(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RegisterMessageWithUserAuthBannerShouldBeInvokedOnce()
|
||||
{
|
||||
SessionMock.Verify(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnRegisterMessageWithUserAuthFailureShouldBeInvokedOnce()
|
||||
{
|
||||
SessionMock.Verify(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnRegisterMessageWithUserAuthSuccessShouldBeInvokedOnce()
|
||||
{
|
||||
SessionMock.Verify(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"), Times.Once);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnRegisterMessageWithUserAuthBannerShouldBeInvokedOnce()
|
||||
{
|
||||
SessionMock.Verify(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+70
-70
@@ -1,70 +1,70 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Failure_SingleList_AuthenticationMethodFailed : ClientAuthenticationTestBase
|
||||
{
|
||||
private SshAuthenticationException _actualException;
|
||||
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
PublicKeyAuthenticationMethodMock.Object,
|
||||
PasswordAuthenticationMethodMock.Object
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq)
|
||||
.Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "password" });
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
// obtain name for inclusion in SshAuthenticationException
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
try
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (SshAuthenticationException ex)
|
||||
{
|
||||
_actualException = ex;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AuthenticateShouldThrowSshAuthenticationException()
|
||||
{
|
||||
Assert.IsNotNull(_actualException);
|
||||
Assert.IsNull(_actualException.InnerException);
|
||||
Assert.AreEqual("Permission denied (password).", _actualException.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Failure_SingleList_AuthenticationMethodFailed : ClientAuthenticationTestBase
|
||||
{
|
||||
private SshAuthenticationException _actualException;
|
||||
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
PublicKeyAuthenticationMethodMock.Object,
|
||||
PasswordAuthenticationMethodMock.Object
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq)
|
||||
.Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "password" });
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
// obtain name for inclusion in SshAuthenticationException
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
try
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (SshAuthenticationException ex)
|
||||
{
|
||||
_actualException = ex;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AuthenticateShouldThrowSshAuthenticationException()
|
||||
{
|
||||
Assert.IsNotNull(_actualException);
|
||||
Assert.IsNull(_actualException.InnerException);
|
||||
Assert.AreEqual("Permission denied (password).", _actualException.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+63
-63
@@ -1,63 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Failure_SingleList_AuthenticationMethodNotSupported : ClientAuthenticationTestBase
|
||||
{
|
||||
private SshAuthenticationException _actualException;
|
||||
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
PublicKeyAuthenticationMethodMock.Object
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq)
|
||||
.Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "password" });
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
try
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (SshAuthenticationException ex)
|
||||
{
|
||||
_actualException = ex;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AuthenticateShouldThrowSshAuthenticationException()
|
||||
{
|
||||
Assert.IsNotNull(_actualException);
|
||||
Assert.IsNull(_actualException.InnerException);
|
||||
Assert.AreEqual("No suitable authentication method found to complete authentication (password).", _actualException.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using Renci.SshNet.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Failure_SingleList_AuthenticationMethodNotSupported : ClientAuthenticationTestBase
|
||||
{
|
||||
private SshAuthenticationException _actualException;
|
||||
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
PublicKeyAuthenticationMethodMock.Object
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq)
|
||||
.Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "password" });
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
try
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (SshAuthenticationException ex)
|
||||
{
|
||||
_actualException = ex;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AuthenticateShouldThrowSshAuthenticationException()
|
||||
{
|
||||
Assert.IsNotNull(_actualException);
|
||||
Assert.IsNull(_actualException.InnerException);
|
||||
Assert.AreEqual("No suitable authentication method found to complete authentication (password).", _actualException.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+55
-55
@@ -1,55 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Success_MultiList_DifferentAllowedAuthenticationsAfterPartialSuccess : ClientAuthenticationTestBase
|
||||
{
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
PasswordAuthenticationMethodMock.Object,
|
||||
PublicKeyAuthenticationMethodMock.Object,
|
||||
KeyboardInteractiveAuthenticationMethodMock.Object,
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications).Returns(new[] { "publickey", "password" });
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.PartialSuccess);
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "keyboard-interactive", "publickey" });
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object)).Returns(AuthenticationResult.Success);
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Success_MultiList_DifferentAllowedAuthenticationsAfterPartialSuccess : ClientAuthenticationTestBase
|
||||
{
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
PasswordAuthenticationMethodMock.Object,
|
||||
PublicKeyAuthenticationMethodMock.Object,
|
||||
KeyboardInteractiveAuthenticationMethodMock.Object,
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications).Returns(new[] { "publickey", "password" });
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.PartialSuccess);
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "keyboard-interactive", "publickey" });
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object)).Returns(AuthenticationResult.Success);
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+57
-57
@@ -1,57 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Success_MultiList_PostponePartialAccessAuthenticationMethod : ClientAuthenticationTestBase
|
||||
{
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
KeyboardInteractiveAuthenticationMethodMock.Object,
|
||||
PasswordAuthenticationMethodMock.Object,
|
||||
PublicKeyAuthenticationMethodMock.Object
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications).Returns(new[] { "password" });
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.PartialSuccess);
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "password", "publickey" });
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object)).Returns(AuthenticationResult.Failure);
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object)).Returns(AuthenticationResult.Success);
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Success_MultiList_PostponePartialAccessAuthenticationMethod : ClientAuthenticationTestBase
|
||||
{
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
KeyboardInteractiveAuthenticationMethodMock.Object,
|
||||
PasswordAuthenticationMethodMock.Object,
|
||||
PublicKeyAuthenticationMethodMock.Object
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications).Returns(new[] { "password" });
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.PartialSuccess);
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "password", "publickey" });
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object)).Returns(AuthenticationResult.Failure);
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object)).Returns(AuthenticationResult.Success);
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+61
-61
@@ -1,61 +1,61 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Success_MultiList_SameAllowedAuthenticationsAfterPartialSuccess : ClientAuthenticationTestBase
|
||||
{
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
PasswordAuthenticationMethodMock.Object,
|
||||
PublicKeyAuthenticationMethodMock.Object,
|
||||
KeyboardInteractiveAuthenticationMethodMock.Object,
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications).Returns(new[] { "password", "publickey" });
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.PartialSuccess);
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] {"password", "publickey"});
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object)).Returns(AuthenticationResult.PartialSuccess);
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "password", "publickey", "keyboard-interactive" });
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Success);
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Success_MultiList_SameAllowedAuthenticationsAfterPartialSuccess : ClientAuthenticationTestBase
|
||||
{
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
PasswordAuthenticationMethodMock.Object,
|
||||
PublicKeyAuthenticationMethodMock.Object,
|
||||
KeyboardInteractiveAuthenticationMethodMock.Object,
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications).Returns(new[] { "password", "publickey" });
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.PartialSuccess);
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] {"password", "publickey"});
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object)).Returns(AuthenticationResult.PartialSuccess);
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "password", "publickey", "keyboard-interactive" });
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
|
||||
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Success);
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+55
-55
@@ -1,55 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Success_MultiList_SkipFailedAuthenticationMethod : ClientAuthenticationTestBase
|
||||
{
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
PasswordAuthenticationMethodMock.Object,
|
||||
PublicKeyAuthenticationMethodMock.Object,
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq)
|
||||
.Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "publickey", "password" });
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
// obtain name for inclusion in SshAuthenticationException
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq)
|
||||
.Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Success);
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Success_MultiList_SkipFailedAuthenticationMethod : ClientAuthenticationTestBase
|
||||
{
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
PasswordAuthenticationMethodMock.Object,
|
||||
PublicKeyAuthenticationMethodMock.Object,
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq)
|
||||
.Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "publickey", "password" });
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
// obtain name for inclusion in SshAuthenticationException
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq)
|
||||
.Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Success);
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+53
-53
@@ -1,53 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Success_SingleList_SameAllowedAuthenticationAfterPartialSuccess : ClientAuthenticationTestBase
|
||||
{
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
PublicKeyAuthenticationMethodMock.Object,
|
||||
PasswordAuthenticationMethodMock.Object
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications).Returns(new[] { "password" });
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.PartialSuccess);
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "password" });
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object)).Returns(AuthenticationResult.Success);
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientAuthenticationTest_Success_SingleList_SameAllowedAuthenticationAfterPartialSuccess : ClientAuthenticationTestBase
|
||||
{
|
||||
protected override void SetupMocks()
|
||||
{
|
||||
var seq = new MockSequence();
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
|
||||
.Returns(NoneAuthenticationMethodMock.Object);
|
||||
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.Failure);
|
||||
ConnectionInfoMock.InSequence(seq).Setup(p => p.AuthenticationMethods)
|
||||
.Returns(new List<IAuthenticationMethod>
|
||||
{
|
||||
PublicKeyAuthenticationMethodMock.Object,
|
||||
PasswordAuthenticationMethodMock.Object
|
||||
});
|
||||
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications).Returns(new[] { "password" });
|
||||
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object))
|
||||
.Returns(AuthenticationResult.PartialSuccess);
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications)
|
||||
.Returns(new[] { "password" });
|
||||
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
|
||||
|
||||
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Authenticate(SessionMock.Object)).Returns(AuthenticationResult.Success);
|
||||
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
|
||||
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
|
||||
}
|
||||
|
||||
protected override void Act()
|
||||
{
|
||||
ClientAuthentication.Authenticate(ConnectionInfoMock.Object, SessionMock.Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass()]
|
||||
public class CommandAsyncResultTest : TestBase
|
||||
{
|
||||
[TestMethod()]
|
||||
public void BytesSentTest()
|
||||
{
|
||||
var target = new CommandAsyncResult();
|
||||
int expected = new Random().Next();
|
||||
|
||||
target.BytesSent = expected;
|
||||
|
||||
Assert.AreEqual(expected, target.BytesSent);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void BytesReceivedTest()
|
||||
{
|
||||
var target = new CommandAsyncResult();
|
||||
var expected = new Random().Next();
|
||||
|
||||
target.BytesReceived = expected;
|
||||
|
||||
Assert.AreEqual(expected, target.BytesReceived);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass()]
|
||||
public class CommandAsyncResultTest : TestBase
|
||||
{
|
||||
[TestMethod()]
|
||||
public void BytesSentTest()
|
||||
{
|
||||
var target = new CommandAsyncResult();
|
||||
int expected = new Random().Next();
|
||||
|
||||
target.BytesSent = expected;
|
||||
|
||||
Assert.AreEqual(expected, target.BytesSent);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void BytesReceivedTest()
|
||||
{
|
||||
var target = new CommandAsyncResult();
|
||||
var expected = new Random().Next();
|
||||
|
||||
target.BytesReceived = expected;
|
||||
|
||||
Assert.AreEqual(expected, target.BytesReceived);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,237 +1,237 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
[TestClass]
|
||||
public class ASCIIEncodingTest : TestBase
|
||||
{
|
||||
private Random _random;
|
||||
private Encoding _ascii;
|
||||
|
||||
[TestInitialize]
|
||||
public void SetUp()
|
||||
{
|
||||
_random = new Random();
|
||||
_ascii = SshData.Ascii;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetByteCount_Chars()
|
||||
{
|
||||
var chars = new[] { 'B', 'e', 'l', 'g', 'i', 'u', 'm' };
|
||||
|
||||
var actual = _ascii.GetByteCount(chars);
|
||||
|
||||
Assert.AreEqual(chars.Length, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetBytes_CharArray()
|
||||
{
|
||||
var chars = new[] {'B', 'e', 'l', 'g', 'i', 'u', 'm'};
|
||||
|
||||
var actual = _ascii.GetBytes(chars);
|
||||
|
||||
Assert.IsNotNull(actual);
|
||||
Assert.AreEqual(7, actual.Length);
|
||||
Assert.AreEqual(0x42, actual[0]);
|
||||
Assert.AreEqual(0x65, actual[1]);
|
||||
Assert.AreEqual(0x6c, actual[2]);
|
||||
Assert.AreEqual(0x67, actual[3]);
|
||||
Assert.AreEqual(0x69, actual[4]);
|
||||
Assert.AreEqual(0x75, actual[5]);
|
||||
Assert.AreEqual(0x6d ,actual[6]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetCharCount_Bytes()
|
||||
{
|
||||
var bytes = new byte[] { 0x42, 0x65, 0x6c, 0x67, 0x69, 0x75, 0x6d };
|
||||
|
||||
var actual = _ascii.GetCharCount(bytes);
|
||||
|
||||
Assert.AreEqual(bytes.Length, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetChars_Bytes()
|
||||
{
|
||||
var bytes = new byte[] {0x42, 0x65, 0x6c, 0x67, 0x69, 0x75, 0x6d};
|
||||
|
||||
var actual = _ascii.GetChars(bytes);
|
||||
|
||||
Assert.AreEqual("Belgium", new string(actual));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetChars_Bytes_DefaultFallback()
|
||||
{
|
||||
var bytes = new byte[] { 0x42, 0x65, 0x6c, 0x80, 0x69, 0x75, 0x6d };
|
||||
|
||||
var actual = _ascii.GetChars(bytes);
|
||||
|
||||
Assert.AreEqual("Bel?ium", new string(actual));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetMaxByteCount_ShouldReturnCharCountPlusOneWhenCharCountIsNonNegative()
|
||||
{
|
||||
var charCount = _random.Next(0, 20000);
|
||||
|
||||
var actual = _ascii.GetMaxByteCount(charCount);
|
||||
|
||||
Assert.AreEqual(++charCount, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetMaxByteCount_ShouldThrowArgumentOutOfRangeExceptionWhenCharCountIsNegative()
|
||||
{
|
||||
var charCount = _random.Next(-5000, -1);
|
||||
|
||||
try
|
||||
{
|
||||
var actual = _ascii.GetMaxByteCount(charCount);
|
||||
Assert.Fail(actual.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
catch (ArgumentOutOfRangeException ex)
|
||||
{
|
||||
Assert.IsNull(ex.InnerException);
|
||||
Assert.AreEqual("charCount", ex.ParamName);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetMaxCharCount_ShouldReturnByteCountWhenByteCountIsNonNegative()
|
||||
{
|
||||
var byteCount = _random.Next(0, 20000);
|
||||
|
||||
var actual = _ascii.GetMaxCharCount(byteCount);
|
||||
|
||||
Assert.AreEqual(byteCount, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetMaxCharCount_ShouldThrowArgumentOutOfRangeExceptionWhenByteCountIsNegative()
|
||||
{
|
||||
var byteCount = _random.Next(-5000, -1);
|
||||
|
||||
try
|
||||
{
|
||||
var actual = _ascii.GetMaxCharCount(byteCount);
|
||||
Assert.Fail(actual.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
catch (ArgumentOutOfRangeException ex)
|
||||
{
|
||||
Assert.IsNull(ex.InnerException);
|
||||
Assert.AreEqual("byteCount", ex.ParamName);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetPreamble()
|
||||
{
|
||||
var actual = _ascii.GetPreamble();
|
||||
|
||||
Assert.AreEqual(0, actual.Length);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsSingleByte()
|
||||
{
|
||||
Assert.IsTrue(_ascii.IsSingleByte);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetBytes_Performance()
|
||||
{
|
||||
const string input = "eererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqs";
|
||||
const int loopCount = 10000000;
|
||||
var result = new byte[input.Length];
|
||||
|
||||
var corefxAscii = new System.Text.ASCIIEncoding();
|
||||
var sshAscii = _ascii;
|
||||
|
||||
var stopWatch = new Stopwatch();
|
||||
|
||||
GC.Collect();
|
||||
GC.WaitForFullGCComplete();
|
||||
|
||||
stopWatch.Start();
|
||||
|
||||
for (var i = 0; i < loopCount; i++)
|
||||
{
|
||||
corefxAscii.GetBytes(input, 0, input.Length, result, 0);
|
||||
}
|
||||
|
||||
stopWatch.Stop();
|
||||
|
||||
Console.WriteLine(stopWatch.ElapsedMilliseconds);
|
||||
|
||||
stopWatch.Reset();
|
||||
|
||||
GC.Collect();
|
||||
GC.WaitForFullGCComplete();
|
||||
|
||||
stopWatch.Start();
|
||||
|
||||
for (var i = 0; i < loopCount; i++)
|
||||
{
|
||||
sshAscii.GetBytes(input, 0, input.Length, result, 0);
|
||||
}
|
||||
|
||||
stopWatch.Stop();
|
||||
|
||||
Console.WriteLine(stopWatch.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetChars_Performance()
|
||||
{
|
||||
var input = new byte[2000];
|
||||
new Random().NextBytes(input);
|
||||
const int loopCount = 100000;
|
||||
|
||||
var corefxAscii = new System.Text.ASCIIEncoding();
|
||||
var sshAscii = _ascii;
|
||||
|
||||
var stopWatch = new Stopwatch();
|
||||
|
||||
GC.Collect();
|
||||
GC.WaitForFullGCComplete();
|
||||
|
||||
stopWatch.Start();
|
||||
|
||||
for (var i = 0; i < loopCount; i++)
|
||||
{
|
||||
var actual = corefxAscii.GetChars(input);
|
||||
}
|
||||
|
||||
stopWatch.Stop();
|
||||
|
||||
Console.WriteLine(stopWatch.ElapsedMilliseconds);
|
||||
|
||||
stopWatch.Reset();
|
||||
|
||||
GC.Collect();
|
||||
GC.WaitForFullGCComplete();
|
||||
|
||||
stopWatch.Start();
|
||||
|
||||
for (var i = 0; i < loopCount; i++)
|
||||
{
|
||||
var actual = sshAscii.GetChars(input);
|
||||
}
|
||||
|
||||
stopWatch.Stop();
|
||||
|
||||
Console.WriteLine(stopWatch.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
}
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
[TestClass]
|
||||
public class ASCIIEncodingTest : TestBase
|
||||
{
|
||||
private Random _random;
|
||||
private Encoding _ascii;
|
||||
|
||||
[TestInitialize]
|
||||
public void SetUp()
|
||||
{
|
||||
_random = new Random();
|
||||
_ascii = SshData.Ascii;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetByteCount_Chars()
|
||||
{
|
||||
var chars = new[] { 'B', 'e', 'l', 'g', 'i', 'u', 'm' };
|
||||
|
||||
var actual = _ascii.GetByteCount(chars);
|
||||
|
||||
Assert.AreEqual(chars.Length, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetBytes_CharArray()
|
||||
{
|
||||
var chars = new[] {'B', 'e', 'l', 'g', 'i', 'u', 'm'};
|
||||
|
||||
var actual = _ascii.GetBytes(chars);
|
||||
|
||||
Assert.IsNotNull(actual);
|
||||
Assert.AreEqual(7, actual.Length);
|
||||
Assert.AreEqual(0x42, actual[0]);
|
||||
Assert.AreEqual(0x65, actual[1]);
|
||||
Assert.AreEqual(0x6c, actual[2]);
|
||||
Assert.AreEqual(0x67, actual[3]);
|
||||
Assert.AreEqual(0x69, actual[4]);
|
||||
Assert.AreEqual(0x75, actual[5]);
|
||||
Assert.AreEqual(0x6d ,actual[6]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetCharCount_Bytes()
|
||||
{
|
||||
var bytes = new byte[] { 0x42, 0x65, 0x6c, 0x67, 0x69, 0x75, 0x6d };
|
||||
|
||||
var actual = _ascii.GetCharCount(bytes);
|
||||
|
||||
Assert.AreEqual(bytes.Length, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetChars_Bytes()
|
||||
{
|
||||
var bytes = new byte[] {0x42, 0x65, 0x6c, 0x67, 0x69, 0x75, 0x6d};
|
||||
|
||||
var actual = _ascii.GetChars(bytes);
|
||||
|
||||
Assert.AreEqual("Belgium", new string(actual));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetChars_Bytes_DefaultFallback()
|
||||
{
|
||||
var bytes = new byte[] { 0x42, 0x65, 0x6c, 0x80, 0x69, 0x75, 0x6d };
|
||||
|
||||
var actual = _ascii.GetChars(bytes);
|
||||
|
||||
Assert.AreEqual("Bel?ium", new string(actual));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetMaxByteCount_ShouldReturnCharCountPlusOneWhenCharCountIsNonNegative()
|
||||
{
|
||||
var charCount = _random.Next(0, 20000);
|
||||
|
||||
var actual = _ascii.GetMaxByteCount(charCount);
|
||||
|
||||
Assert.AreEqual(++charCount, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetMaxByteCount_ShouldThrowArgumentOutOfRangeExceptionWhenCharCountIsNegative()
|
||||
{
|
||||
var charCount = _random.Next(-5000, -1);
|
||||
|
||||
try
|
||||
{
|
||||
var actual = _ascii.GetMaxByteCount(charCount);
|
||||
Assert.Fail(actual.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
catch (ArgumentOutOfRangeException ex)
|
||||
{
|
||||
Assert.IsNull(ex.InnerException);
|
||||
Assert.AreEqual("charCount", ex.ParamName);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetMaxCharCount_ShouldReturnByteCountWhenByteCountIsNonNegative()
|
||||
{
|
||||
var byteCount = _random.Next(0, 20000);
|
||||
|
||||
var actual = _ascii.GetMaxCharCount(byteCount);
|
||||
|
||||
Assert.AreEqual(byteCount, actual);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetMaxCharCount_ShouldThrowArgumentOutOfRangeExceptionWhenByteCountIsNegative()
|
||||
{
|
||||
var byteCount = _random.Next(-5000, -1);
|
||||
|
||||
try
|
||||
{
|
||||
var actual = _ascii.GetMaxCharCount(byteCount);
|
||||
Assert.Fail(actual.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
catch (ArgumentOutOfRangeException ex)
|
||||
{
|
||||
Assert.IsNull(ex.InnerException);
|
||||
Assert.AreEqual("byteCount", ex.ParamName);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetPreamble()
|
||||
{
|
||||
var actual = _ascii.GetPreamble();
|
||||
|
||||
Assert.AreEqual(0, actual.Length);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void IsSingleByte()
|
||||
{
|
||||
Assert.IsTrue(_ascii.IsSingleByte);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetBytes_Performance()
|
||||
{
|
||||
const string input = "eererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqseererzfdfdsfsfsfsqdqs";
|
||||
const int loopCount = 10000000;
|
||||
var result = new byte[input.Length];
|
||||
|
||||
var corefxAscii = new System.Text.ASCIIEncoding();
|
||||
var sshAscii = _ascii;
|
||||
|
||||
var stopWatch = new Stopwatch();
|
||||
|
||||
GC.Collect();
|
||||
GC.WaitForFullGCComplete();
|
||||
|
||||
stopWatch.Start();
|
||||
|
||||
for (var i = 0; i < loopCount; i++)
|
||||
{
|
||||
corefxAscii.GetBytes(input, 0, input.Length, result, 0);
|
||||
}
|
||||
|
||||
stopWatch.Stop();
|
||||
|
||||
Console.WriteLine(stopWatch.ElapsedMilliseconds);
|
||||
|
||||
stopWatch.Reset();
|
||||
|
||||
GC.Collect();
|
||||
GC.WaitForFullGCComplete();
|
||||
|
||||
stopWatch.Start();
|
||||
|
||||
for (var i = 0; i < loopCount; i++)
|
||||
{
|
||||
sshAscii.GetBytes(input, 0, input.Length, result, 0);
|
||||
}
|
||||
|
||||
stopWatch.Stop();
|
||||
|
||||
Console.WriteLine(stopWatch.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetChars_Performance()
|
||||
{
|
||||
var input = new byte[2000];
|
||||
new Random().NextBytes(input);
|
||||
const int loopCount = 100000;
|
||||
|
||||
var corefxAscii = new System.Text.ASCIIEncoding();
|
||||
var sshAscii = _ascii;
|
||||
|
||||
var stopWatch = new Stopwatch();
|
||||
|
||||
GC.Collect();
|
||||
GC.WaitForFullGCComplete();
|
||||
|
||||
stopWatch.Start();
|
||||
|
||||
for (var i = 0; i < loopCount; i++)
|
||||
{
|
||||
var actual = corefxAscii.GetChars(input);
|
||||
}
|
||||
|
||||
stopWatch.Stop();
|
||||
|
||||
Console.WriteLine(stopWatch.ElapsedMilliseconds);
|
||||
|
||||
stopWatch.Reset();
|
||||
|
||||
GC.Collect();
|
||||
GC.WaitForFullGCComplete();
|
||||
|
||||
stopWatch.Start();
|
||||
|
||||
for (var i = 0; i < loopCount; i++)
|
||||
{
|
||||
var actual = sshAscii.GetChars(input);
|
||||
}
|
||||
|
||||
stopWatch.Stop();
|
||||
|
||||
Console.WriteLine(stopWatch.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,140 +1,140 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for AsyncResultTest and is intended
|
||||
///to contain all AsyncResultTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass]
|
||||
[Ignore] // placeholder for actual test
|
||||
public class AsyncResultTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for EndInvoke
|
||||
///</summary>
|
||||
public void EndInvokeTest1Helper<TResult>()
|
||||
{
|
||||
AsyncResult<TResult> target = CreateAsyncResult<TResult>(); // TODO: Initialize to an appropriate value
|
||||
TResult expected = default(TResult); // TODO: Initialize to an appropriate value
|
||||
TResult actual;
|
||||
actual = target.EndInvoke();
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
internal virtual AsyncResult<TResult> CreateAsyncResult<TResult>()
|
||||
{
|
||||
// TODO: Instantiate an appropriate concrete class.
|
||||
AsyncResult<TResult> target = null;
|
||||
return target;
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void EndInvokeTest1()
|
||||
{
|
||||
EndInvokeTest1Helper<GenericParameterHelper>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for SetAsCompleted
|
||||
///</summary>
|
||||
public void SetAsCompletedTest1Helper<TResult>()
|
||||
{
|
||||
AsyncResult<TResult> target = CreateAsyncResult<TResult>(); // TODO: Initialize to an appropriate value
|
||||
TResult result = default(TResult); // TODO: Initialize to an appropriate value
|
||||
bool completedSynchronously = false; // TODO: Initialize to an appropriate value
|
||||
target.SetAsCompleted(result, completedSynchronously);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void SetAsCompletedTest1()
|
||||
{
|
||||
SetAsCompletedTest1Helper<GenericParameterHelper>();
|
||||
}
|
||||
|
||||
internal virtual AsyncResult CreateAsyncResult()
|
||||
{
|
||||
// TODO: Instantiate an appropriate concrete class.
|
||||
AsyncResult target = null;
|
||||
return target;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for EndInvoke
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void EndInvokeTest()
|
||||
{
|
||||
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
|
||||
target.EndInvoke();
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for SetAsCompleted
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void SetAsCompletedTest()
|
||||
{
|
||||
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
|
||||
Exception exception = null; // TODO: Initialize to an appropriate value
|
||||
bool completedSynchronously = false; // TODO: Initialize to an appropriate value
|
||||
target.SetAsCompleted(exception, completedSynchronously);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for AsyncState
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void AsyncStateTest()
|
||||
{
|
||||
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
|
||||
object actual;
|
||||
actual = target.AsyncState;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for AsyncWaitHandle
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void AsyncWaitHandleTest()
|
||||
{
|
||||
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
|
||||
WaitHandle actual;
|
||||
actual = target.AsyncWaitHandle;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for CompletedSynchronously
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CompletedSynchronouslyTest()
|
||||
{
|
||||
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
actual = target.CompletedSynchronously;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for IsCompleted
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void IsCompletedTest()
|
||||
{
|
||||
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
actual = target.IsCompleted;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for AsyncResultTest and is intended
|
||||
///to contain all AsyncResultTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass]
|
||||
[Ignore] // placeholder for actual test
|
||||
public class AsyncResultTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for EndInvoke
|
||||
///</summary>
|
||||
public void EndInvokeTest1Helper<TResult>()
|
||||
{
|
||||
AsyncResult<TResult> target = CreateAsyncResult<TResult>(); // TODO: Initialize to an appropriate value
|
||||
TResult expected = default(TResult); // TODO: Initialize to an appropriate value
|
||||
TResult actual;
|
||||
actual = target.EndInvoke();
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
internal virtual AsyncResult<TResult> CreateAsyncResult<TResult>()
|
||||
{
|
||||
// TODO: Instantiate an appropriate concrete class.
|
||||
AsyncResult<TResult> target = null;
|
||||
return target;
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void EndInvokeTest1()
|
||||
{
|
||||
EndInvokeTest1Helper<GenericParameterHelper>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for SetAsCompleted
|
||||
///</summary>
|
||||
public void SetAsCompletedTest1Helper<TResult>()
|
||||
{
|
||||
AsyncResult<TResult> target = CreateAsyncResult<TResult>(); // TODO: Initialize to an appropriate value
|
||||
TResult result = default(TResult); // TODO: Initialize to an appropriate value
|
||||
bool completedSynchronously = false; // TODO: Initialize to an appropriate value
|
||||
target.SetAsCompleted(result, completedSynchronously);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void SetAsCompletedTest1()
|
||||
{
|
||||
SetAsCompletedTest1Helper<GenericParameterHelper>();
|
||||
}
|
||||
|
||||
internal virtual AsyncResult CreateAsyncResult()
|
||||
{
|
||||
// TODO: Instantiate an appropriate concrete class.
|
||||
AsyncResult target = null;
|
||||
return target;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for EndInvoke
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void EndInvokeTest()
|
||||
{
|
||||
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
|
||||
target.EndInvoke();
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for SetAsCompleted
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void SetAsCompletedTest()
|
||||
{
|
||||
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
|
||||
Exception exception = null; // TODO: Initialize to an appropriate value
|
||||
bool completedSynchronously = false; // TODO: Initialize to an appropriate value
|
||||
target.SetAsCompleted(exception, completedSynchronously);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for AsyncState
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void AsyncStateTest()
|
||||
{
|
||||
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
|
||||
object actual;
|
||||
actual = target.AsyncState;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for AsyncWaitHandle
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void AsyncWaitHandleTest()
|
||||
{
|
||||
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
|
||||
WaitHandle actual;
|
||||
actual = target.AsyncWaitHandle;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for CompletedSynchronously
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CompletedSynchronouslyTest()
|
||||
{
|
||||
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
actual = target.CompletedSynchronously;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for IsCompleted
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void IsCompletedTest()
|
||||
{
|
||||
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
actual = target.IsCompleted;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///This is a test class for AuthenticationBannerEventArgsTest and is intended
|
||||
///to contain all AuthenticationBannerEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class AuthenticationBannerEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for AuthenticationBannerEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void AuthenticationBannerEventArgsConstructorTest()
|
||||
{
|
||||
string username = string.Empty; // TODO: Initialize to an appropriate value
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
string language = string.Empty; // TODO: Initialize to an appropriate value
|
||||
AuthenticationBannerEventArgs target = new AuthenticationBannerEventArgs(username, message, language);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///This is a test class for AuthenticationBannerEventArgsTest and is intended
|
||||
///to contain all AuthenticationBannerEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class AuthenticationBannerEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for AuthenticationBannerEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void AuthenticationBannerEventArgsConstructorTest()
|
||||
{
|
||||
string username = string.Empty; // TODO: Initialize to an appropriate value
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
string language = string.Empty; // TODO: Initialize to an appropriate value
|
||||
AuthenticationBannerEventArgs target = new AuthenticationBannerEventArgs(username, message, language);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+44
-44
@@ -1,44 +1,44 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///This is a test class for AuthenticationPasswordChangeEventArgsTest and is intended
|
||||
///to contain all AuthenticationPasswordChangeEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class AuthenticationPasswordChangeEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for AuthenticationPasswordChangeEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void AuthenticationPasswordChangeEventArgsConstructorTest()
|
||||
{
|
||||
string username = string.Empty; // TODO: Initialize to an appropriate value
|
||||
AuthenticationPasswordChangeEventArgs target = new AuthenticationPasswordChangeEventArgs(username);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for NewPassword
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void NewPasswordTest()
|
||||
{
|
||||
string username = string.Empty; // TODO: Initialize to an appropriate value
|
||||
AuthenticationPasswordChangeEventArgs target = new AuthenticationPasswordChangeEventArgs(username); // TODO: Initialize to an appropriate value
|
||||
byte[] expected = null; // TODO: Initialize to an appropriate value
|
||||
byte[] actual;
|
||||
target.NewPassword = expected;
|
||||
actual = target.NewPassword;
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///This is a test class for AuthenticationPasswordChangeEventArgsTest and is intended
|
||||
///to contain all AuthenticationPasswordChangeEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class AuthenticationPasswordChangeEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for AuthenticationPasswordChangeEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void AuthenticationPasswordChangeEventArgsConstructorTest()
|
||||
{
|
||||
string username = string.Empty; // TODO: Initialize to an appropriate value
|
||||
AuthenticationPasswordChangeEventArgs target = new AuthenticationPasswordChangeEventArgs(username);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for NewPassword
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void NewPasswordTest()
|
||||
{
|
||||
string username = string.Empty; // TODO: Initialize to an appropriate value
|
||||
AuthenticationPasswordChangeEventArgs target = new AuthenticationPasswordChangeEventArgs(username); // TODO: Initialize to an appropriate value
|
||||
byte[] expected = null; // TODO: Initialize to an appropriate value
|
||||
byte[] actual;
|
||||
target.NewPassword = expected;
|
||||
actual = target.NewPassword;
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///This is a test class for AuthenticationPromptEventArgsTest and is intended
|
||||
///to contain all AuthenticationPromptEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class AuthenticationPromptEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for AuthenticationPromptEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void AuthenticationPromptEventArgsConstructorTest()
|
||||
{
|
||||
string username = string.Empty; // TODO: Initialize to an appropriate value
|
||||
string instruction = string.Empty; // TODO: Initialize to an appropriate value
|
||||
string language = string.Empty; // TODO: Initialize to an appropriate value
|
||||
IEnumerable<AuthenticationPrompt> prompts = null; // TODO: Initialize to an appropriate value
|
||||
AuthenticationPromptEventArgs target = new AuthenticationPromptEventArgs(username, instruction, language, prompts);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///This is a test class for AuthenticationPromptEventArgsTest and is intended
|
||||
///to contain all AuthenticationPromptEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class AuthenticationPromptEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for AuthenticationPromptEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void AuthenticationPromptEventArgsConstructorTest()
|
||||
{
|
||||
string username = string.Empty; // TODO: Initialize to an appropriate value
|
||||
string instruction = string.Empty; // TODO: Initialize to an appropriate value
|
||||
string language = string.Empty; // TODO: Initialize to an appropriate value
|
||||
IEnumerable<AuthenticationPrompt> prompts = null; // TODO: Initialize to an appropriate value
|
||||
AuthenticationPromptEventArgs target = new AuthenticationPromptEventArgs(username, instruction, language, prompts);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for AuthenticationPromptTest and is intended
|
||||
///to contain all AuthenticationPromptTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class AuthenticationPromptTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for AuthenticationPrompt Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void AuthenticationPromptConstructorTest()
|
||||
{
|
||||
int id = 0; // TODO: Initialize to an appropriate value
|
||||
bool isEchoed = false; // TODO: Initialize to an appropriate value
|
||||
string request = string.Empty; // TODO: Initialize to an appropriate value
|
||||
AuthenticationPrompt target = new AuthenticationPrompt(id, isEchoed, request);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Response
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ResponseTest()
|
||||
{
|
||||
int id = 0; // TODO: Initialize to an appropriate value
|
||||
bool isEchoed = false; // TODO: Initialize to an appropriate value
|
||||
string request = string.Empty; // TODO: Initialize to an appropriate value
|
||||
AuthenticationPrompt target = new AuthenticationPrompt(id, isEchoed, request); // TODO: Initialize to an appropriate value
|
||||
string expected = string.Empty; // TODO: Initialize to an appropriate value
|
||||
string actual;
|
||||
target.Response = expected;
|
||||
actual = target.Response;
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for AuthenticationPromptTest and is intended
|
||||
///to contain all AuthenticationPromptTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class AuthenticationPromptTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for AuthenticationPrompt Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void AuthenticationPromptConstructorTest()
|
||||
{
|
||||
int id = 0; // TODO: Initialize to an appropriate value
|
||||
bool isEchoed = false; // TODO: Initialize to an appropriate value
|
||||
string request = string.Empty; // TODO: Initialize to an appropriate value
|
||||
AuthenticationPrompt target = new AuthenticationPrompt(id, isEchoed, request);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Response
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ResponseTest()
|
||||
{
|
||||
int id = 0; // TODO: Initialize to an appropriate value
|
||||
bool isEchoed = false; // TODO: Initialize to an appropriate value
|
||||
string request = string.Empty; // TODO: Initialize to an appropriate value
|
||||
AuthenticationPrompt target = new AuthenticationPrompt(id, isEchoed, request); // TODO: Initialize to an appropriate value
|
||||
string expected = string.Empty; // TODO: Initialize to an appropriate value
|
||||
string actual;
|
||||
target.Response = expected;
|
||||
actual = target.Response;
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,13 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for <see cref="Renci.SshNet.Channels.Channel.DataReceived"/> event and <see cref="Renci.SshNet.Channels.Channel.ExtendedDataReceived"/> events.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ChannelDataEventArgsTest : TestBase
|
||||
{
|
||||
}
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for <see cref="Renci.SshNet.Channels.Channel.DataReceived"/> event and <see cref="Renci.SshNet.Channels.Channel.ExtendedDataReceived"/> events.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ChannelDataEventArgsTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class forTest : TestBaseall channel related events.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ChannelEventArgsTest : TestBase
|
||||
{
|
||||
}
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class forTest : TestBaseall channel related events.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ChannelEventArgsTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for <see cref="Renci.SshNet.Channels.Channel.OpenFailed"/> event.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ChannelOpenFailedEventArgsTest : TestBase
|
||||
{
|
||||
}
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for <see cref="Renci.SshNet.Channels.Channel.OpenFailed"/> event.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ChannelOpenFailedEventArgsTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for <see cref="Renci.SshNet.Channels.Channel.RequestReceived"/> event.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ChannelRequestEventArgsTest : TestBase
|
||||
{
|
||||
}
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for <see cref="Renci.SshNet.Channels.Channel.RequestReceived"/> event.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ChannelRequestEventArgsTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,174 +1,174 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for DerDataTest and is intended
|
||||
///to contain all DerDataTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
[Ignore] // placeholder for actual test
|
||||
public class DerDataTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for DerData Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void DerDataConstructorTest()
|
||||
{
|
||||
DerData target = new DerData();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for DerData Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void DerDataConstructorTest1()
|
||||
{
|
||||
byte[] data = null; // TODO: Initialize to an appropriate value
|
||||
DerData target = new DerData(data);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Encode
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void EncodeTest()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
byte[] expected = null; // TODO: Initialize to an appropriate value
|
||||
byte[] actual;
|
||||
actual = target.Encode();
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ReadBigInteger
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ReadBigIntegerTest()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
BigInteger expected = new BigInteger(); // TODO: Initialize to an appropriate value
|
||||
BigInteger actual;
|
||||
actual = target.ReadBigInteger();
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ReadInteger
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ReadIntegerTest()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
int expected = 0; // TODO: Initialize to an appropriate value
|
||||
int actual;
|
||||
actual = target.ReadInteger();
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Write
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteTest()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
bool data = false; // TODO: Initialize to an appropriate value
|
||||
target.Write(data);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Write
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteTest1()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
uint data = 0; // TODO: Initialize to an appropriate value
|
||||
target.Write(data);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Write
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteTest2()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
BigInteger data = new BigInteger(); // TODO: Initialize to an appropriate value
|
||||
target.Write(data);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Write
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteTest3()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
byte[] data = null; // TODO: Initialize to an appropriate value
|
||||
target.Write(data);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Write
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteTest4()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
ObjectIdentifier identifier = new ObjectIdentifier(); // TODO: Initialize to an appropriate value
|
||||
target.Write(identifier);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Write
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteTest5()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
DerData data = null; // TODO: Initialize to an appropriate value
|
||||
target.Write(data);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for WriteNull
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteNullTest()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
target.WriteNull();
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for IsEndOfData
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void IsEndOfDataTest()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
actual = target.IsEndOfData;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for DerDataTest and is intended
|
||||
///to contain all DerDataTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
[Ignore] // placeholder for actual test
|
||||
public class DerDataTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for DerData Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void DerDataConstructorTest()
|
||||
{
|
||||
DerData target = new DerData();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for DerData Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void DerDataConstructorTest1()
|
||||
{
|
||||
byte[] data = null; // TODO: Initialize to an appropriate value
|
||||
DerData target = new DerData(data);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Encode
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void EncodeTest()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
byte[] expected = null; // TODO: Initialize to an appropriate value
|
||||
byte[] actual;
|
||||
actual = target.Encode();
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ReadBigInteger
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ReadBigIntegerTest()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
BigInteger expected = new BigInteger(); // TODO: Initialize to an appropriate value
|
||||
BigInteger actual;
|
||||
actual = target.ReadBigInteger();
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ReadInteger
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ReadIntegerTest()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
int expected = 0; // TODO: Initialize to an appropriate value
|
||||
int actual;
|
||||
actual = target.ReadInteger();
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Write
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteTest()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
bool data = false; // TODO: Initialize to an appropriate value
|
||||
target.Write(data);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Write
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteTest1()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
uint data = 0; // TODO: Initialize to an appropriate value
|
||||
target.Write(data);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Write
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteTest2()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
BigInteger data = new BigInteger(); // TODO: Initialize to an appropriate value
|
||||
target.Write(data);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Write
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteTest3()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
byte[] data = null; // TODO: Initialize to an appropriate value
|
||||
target.Write(data);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Write
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteTest4()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
ObjectIdentifier identifier = new ObjectIdentifier(); // TODO: Initialize to an appropriate value
|
||||
target.Write(identifier);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Write
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteTest5()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
DerData data = null; // TODO: Initialize to an appropriate value
|
||||
target.Write(data);
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for WriteNull
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WriteNullTest()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
target.WriteNull();
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for IsEndOfData
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void IsEndOfDataTest()
|
||||
{
|
||||
DerData target = new DerData(); // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
actual = target.IsEndOfData;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for ExceptionEventArgsTest and is intended
|
||||
///to contain all ExceptionEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class ExceptionEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for ExceptionEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ExceptionEventArgsConstructorTest()
|
||||
{
|
||||
Exception exception = null; // TODO: Initialize to an appropriate value
|
||||
ExceptionEventArgs target = new ExceptionEventArgs(exception);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for ExceptionEventArgsTest and is intended
|
||||
///to contain all ExceptionEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class ExceptionEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for ExceptionEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ExceptionEventArgsConstructorTest()
|
||||
{
|
||||
Exception exception = null; // TODO: Initialize to an appropriate value
|
||||
ExceptionEventArgs target = new ExceptionEventArgs(exception);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Security;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for HostKeyEventArgsTest and is intended
|
||||
///to contain all HostKeyEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
[Ignore] // placeholder for actual test
|
||||
public class HostKeyEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for HostKeyEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void HostKeyEventArgsConstructorTest()
|
||||
{
|
||||
KeyHostAlgorithm host = null; // TODO: Initialize to an appropriate value
|
||||
HostKeyEventArgs target = new HostKeyEventArgs(host);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for CanTrust
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CanTrustTest()
|
||||
{
|
||||
KeyHostAlgorithm host = null; // TODO: Initialize to an appropriate value
|
||||
HostKeyEventArgs target = new HostKeyEventArgs(host); // TODO: Initialize to an appropriate value
|
||||
bool expected = false; // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
target.CanTrust = expected;
|
||||
actual = target.CanTrust;
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Security;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for HostKeyEventArgsTest and is intended
|
||||
///to contain all HostKeyEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
[Ignore] // placeholder for actual test
|
||||
public class HostKeyEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for HostKeyEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void HostKeyEventArgsConstructorTest()
|
||||
{
|
||||
KeyHostAlgorithm host = null; // TODO: Initialize to an appropriate value
|
||||
HostKeyEventArgs target = new HostKeyEventArgs(host);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for CanTrust
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void CanTrustTest()
|
||||
{
|
||||
KeyHostAlgorithm host = null; // TODO: Initialize to an appropriate value
|
||||
HostKeyEventArgs target = new HostKeyEventArgs(host); // TODO: Initialize to an appropriate value
|
||||
bool expected = false; // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
target.CanTrust = expected;
|
||||
actual = target.CanTrust;
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for NetConfServerExceptionTest and is intended
|
||||
///to contain all NetConfServerExceptionTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class NetConfServerExceptionTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for NetConfServerException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void NetConfServerExceptionConstructorTest()
|
||||
{
|
||||
NetConfServerException target = new NetConfServerException();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for NetConfServerException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void NetConfServerExceptionConstructorTest1()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
NetConfServerException target = new NetConfServerException(message);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for NetConfServerException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void NetConfServerExceptionConstructorTest2()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
Exception innerException = null; // TODO: Initialize to an appropriate value
|
||||
NetConfServerException target = new NetConfServerException(message, innerException);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for NetConfServerExceptionTest and is intended
|
||||
///to contain all NetConfServerExceptionTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class NetConfServerExceptionTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for NetConfServerException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void NetConfServerExceptionConstructorTest()
|
||||
{
|
||||
NetConfServerException target = new NetConfServerException();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for NetConfServerException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void NetConfServerExceptionConstructorTest1()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
NetConfServerException target = new NetConfServerException(message);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for NetConfServerException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void NetConfServerExceptionConstructorTest2()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
Exception innerException = null; // TODO: Initialize to an appropriate value
|
||||
NetConfServerException target = new NetConfServerException(message, innerException);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for ObjectIdentifierTest and is intended
|
||||
///to contain all ObjectIdentifierTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
[Ignore] // placeholder for actual test
|
||||
public class ObjectIdentifierTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for ObjectIdentifier Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ObjectIdentifierConstructorTest()
|
||||
{
|
||||
ulong[] identifiers = null; // TODO: Initialize to an appropriate value
|
||||
ObjectIdentifier target = new ObjectIdentifier(identifiers);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for ObjectIdentifierTest and is intended
|
||||
///to contain all ObjectIdentifierTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
[Ignore] // placeholder for actual test
|
||||
public class ObjectIdentifierTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for ObjectIdentifier Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ObjectIdentifierConstructorTest()
|
||||
{
|
||||
ulong[] identifiers = null; // TODO: Initialize to an appropriate value
|
||||
ObjectIdentifier target = new ObjectIdentifier(identifiers);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,256 +1,256 @@
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
[TestClass]
|
||||
public class PipeStreamTest : TestBase
|
||||
{
|
||||
[TestMethod]
|
||||
[TestCategory("PipeStream")]
|
||||
public void Test_PipeStream_Write_Read_Buffer()
|
||||
{
|
||||
var testBuffer = new byte[1024];
|
||||
new Random().NextBytes(testBuffer);
|
||||
|
||||
var outputBuffer = new byte[1024];
|
||||
|
||||
using (var stream = new PipeStream())
|
||||
{
|
||||
stream.Write(testBuffer, 0, testBuffer.Length);
|
||||
|
||||
Assert.AreEqual(stream.Length, testBuffer.Length);
|
||||
|
||||
stream.Read(outputBuffer, 0, outputBuffer.Length);
|
||||
|
||||
Assert.AreEqual(stream.Length, 0);
|
||||
|
||||
Assert.IsTrue(testBuffer.IsEqualTo(outputBuffer));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("PipeStream")]
|
||||
public void Test_PipeStream_Write_Read_Byte()
|
||||
{
|
||||
var testBuffer = new byte[1024];
|
||||
new Random().NextBytes(testBuffer);
|
||||
|
||||
var outputBuffer = new byte[1024];
|
||||
|
||||
using (var stream = new PipeStream())
|
||||
{
|
||||
stream.Write(testBuffer, 0, testBuffer.Length);
|
||||
|
||||
Assert.AreEqual(stream.Length, testBuffer.Length);
|
||||
|
||||
stream.ReadByte();
|
||||
|
||||
Assert.AreEqual(stream.Length, testBuffer.Length - 1);
|
||||
|
||||
stream.ReadByte();
|
||||
|
||||
Assert.AreEqual(stream.Length, testBuffer.Length - 2);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///A test for PipeStream Constructor
|
||||
///</summary>
|
||||
[TestMethod]
|
||||
public void PipeStreamConstructorTest()
|
||||
{
|
||||
PipeStream target = new PipeStream();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Flush
|
||||
///</summary>
|
||||
[TestMethod]
|
||||
public void FlushTest()
|
||||
{
|
||||
PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
|
||||
target.Flush();
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Read()
|
||||
{
|
||||
const int sleepTime = 100;
|
||||
|
||||
var target = new PipeStream();
|
||||
target.WriteByte(0x0a);
|
||||
target.WriteByte(0x0d);
|
||||
target.WriteByte(0x09);
|
||||
|
||||
var readBuffer = new byte[2];
|
||||
var bytesRead = target.Read(readBuffer, 0, readBuffer.Length);
|
||||
Assert.AreEqual(2, bytesRead);
|
||||
Assert.AreEqual(0x0a, readBuffer[0]);
|
||||
Assert.AreEqual(0x0d, readBuffer[1]);
|
||||
|
||||
var writeToStreamThread = new Thread(
|
||||
() =>
|
||||
{
|
||||
Thread.Sleep(sleepTime);
|
||||
var writeBuffer = new byte[] {0x05, 0x03};
|
||||
target.Write(writeBuffer, 0, writeBuffer.Length);
|
||||
});
|
||||
writeToStreamThread.Start();
|
||||
|
||||
readBuffer = new byte[2];
|
||||
bytesRead = target.Read(readBuffer, 0, readBuffer.Length);
|
||||
Assert.AreEqual(2, bytesRead);
|
||||
Assert.AreEqual(0x09, readBuffer[0]);
|
||||
Assert.AreEqual(0x05, readBuffer[1]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SeekShouldThrowNotSupportedException()
|
||||
{
|
||||
const long offset = 0;
|
||||
const SeekOrigin origin = new SeekOrigin();
|
||||
var target = new PipeStream();
|
||||
|
||||
try
|
||||
{
|
||||
target.Seek(offset, origin);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SetLengthShouldThrowNotSupportedException()
|
||||
{
|
||||
var target = new PipeStream();
|
||||
|
||||
try
|
||||
{
|
||||
target.SetLength(1);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WriteTest()
|
||||
{
|
||||
var target = new PipeStream();
|
||||
|
||||
var writeBuffer = new byte[] {0x0a, 0x05, 0x0d};
|
||||
target.Write(writeBuffer, 0, 2);
|
||||
|
||||
writeBuffer = new byte[] { 0x02, 0x04, 0x03, 0x06, 0x09 };
|
||||
target.Write(writeBuffer, 1, 2);
|
||||
|
||||
var readBuffer = new byte[6];
|
||||
var bytesRead = target.Read(readBuffer, 0, 4);
|
||||
|
||||
Assert.AreEqual(4, bytesRead);
|
||||
Assert.AreEqual(0x0a, readBuffer[0]);
|
||||
Assert.AreEqual(0x05, readBuffer[1]);
|
||||
Assert.AreEqual(0x04, readBuffer[2]);
|
||||
Assert.AreEqual(0x03, readBuffer[3]);
|
||||
Assert.AreEqual(0x00, readBuffer[4]);
|
||||
Assert.AreEqual(0x00, readBuffer[5]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for BlockLastReadBuffer
|
||||
///</summary>
|
||||
[TestMethod]
|
||||
public void BlockLastReadBufferTest()
|
||||
{
|
||||
PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
|
||||
bool expected = false; // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
target.BlockLastReadBuffer = expected;
|
||||
actual = target.BlockLastReadBuffer;
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CanReadTest()
|
||||
{
|
||||
var target = new PipeStream();
|
||||
Assert.IsTrue(target.CanRead);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CanSeekTest()
|
||||
{
|
||||
var target = new PipeStream(); // TODO: Initialize to an appropriate value
|
||||
Assert.IsFalse(target.CanSeek);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CanWriteTest()
|
||||
{
|
||||
var target = new PipeStream();
|
||||
Assert.IsTrue(target.CanWrite);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LengthTest()
|
||||
{
|
||||
PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
|
||||
long actual;
|
||||
actual = target.Length;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for MaxBufferLength
|
||||
///</summary>
|
||||
[TestMethod]
|
||||
public void MaxBufferLengthTest()
|
||||
{
|
||||
PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
|
||||
long expected = 0; // TODO: Initialize to an appropriate value
|
||||
long actual;
|
||||
target.MaxBufferLength = expected;
|
||||
actual = target.MaxBufferLength;
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Position_GetterAlwaysReturnsZero()
|
||||
{
|
||||
var target = new PipeStream();
|
||||
|
||||
Assert.AreEqual(0, target.Position);
|
||||
target.WriteByte(0x0a);
|
||||
Assert.AreEqual(0, target.Position);
|
||||
target.ReadByte();
|
||||
Assert.AreEqual(0, target.Position);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Position_SetterAlwaysThrowsNotSupportedException()
|
||||
{
|
||||
var target = new PipeStream();
|
||||
|
||||
try
|
||||
{
|
||||
target.Position = 0;
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
[TestClass]
|
||||
public class PipeStreamTest : TestBase
|
||||
{
|
||||
[TestMethod]
|
||||
[TestCategory("PipeStream")]
|
||||
public void Test_PipeStream_Write_Read_Buffer()
|
||||
{
|
||||
var testBuffer = new byte[1024];
|
||||
new Random().NextBytes(testBuffer);
|
||||
|
||||
var outputBuffer = new byte[1024];
|
||||
|
||||
using (var stream = new PipeStream())
|
||||
{
|
||||
stream.Write(testBuffer, 0, testBuffer.Length);
|
||||
|
||||
Assert.AreEqual(stream.Length, testBuffer.Length);
|
||||
|
||||
stream.Read(outputBuffer, 0, outputBuffer.Length);
|
||||
|
||||
Assert.AreEqual(stream.Length, 0);
|
||||
|
||||
Assert.IsTrue(testBuffer.IsEqualTo(outputBuffer));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("PipeStream")]
|
||||
public void Test_PipeStream_Write_Read_Byte()
|
||||
{
|
||||
var testBuffer = new byte[1024];
|
||||
new Random().NextBytes(testBuffer);
|
||||
|
||||
var outputBuffer = new byte[1024];
|
||||
|
||||
using (var stream = new PipeStream())
|
||||
{
|
||||
stream.Write(testBuffer, 0, testBuffer.Length);
|
||||
|
||||
Assert.AreEqual(stream.Length, testBuffer.Length);
|
||||
|
||||
stream.ReadByte();
|
||||
|
||||
Assert.AreEqual(stream.Length, testBuffer.Length - 1);
|
||||
|
||||
stream.ReadByte();
|
||||
|
||||
Assert.AreEqual(stream.Length, testBuffer.Length - 2);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///A test for PipeStream Constructor
|
||||
///</summary>
|
||||
[TestMethod]
|
||||
public void PipeStreamConstructorTest()
|
||||
{
|
||||
PipeStream target = new PipeStream();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Flush
|
||||
///</summary>
|
||||
[TestMethod]
|
||||
public void FlushTest()
|
||||
{
|
||||
PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
|
||||
target.Flush();
|
||||
Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Read()
|
||||
{
|
||||
const int sleepTime = 100;
|
||||
|
||||
var target = new PipeStream();
|
||||
target.WriteByte(0x0a);
|
||||
target.WriteByte(0x0d);
|
||||
target.WriteByte(0x09);
|
||||
|
||||
var readBuffer = new byte[2];
|
||||
var bytesRead = target.Read(readBuffer, 0, readBuffer.Length);
|
||||
Assert.AreEqual(2, bytesRead);
|
||||
Assert.AreEqual(0x0a, readBuffer[0]);
|
||||
Assert.AreEqual(0x0d, readBuffer[1]);
|
||||
|
||||
var writeToStreamThread = new Thread(
|
||||
() =>
|
||||
{
|
||||
Thread.Sleep(sleepTime);
|
||||
var writeBuffer = new byte[] {0x05, 0x03};
|
||||
target.Write(writeBuffer, 0, writeBuffer.Length);
|
||||
});
|
||||
writeToStreamThread.Start();
|
||||
|
||||
readBuffer = new byte[2];
|
||||
bytesRead = target.Read(readBuffer, 0, readBuffer.Length);
|
||||
Assert.AreEqual(2, bytesRead);
|
||||
Assert.AreEqual(0x09, readBuffer[0]);
|
||||
Assert.AreEqual(0x05, readBuffer[1]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SeekShouldThrowNotSupportedException()
|
||||
{
|
||||
const long offset = 0;
|
||||
const SeekOrigin origin = new SeekOrigin();
|
||||
var target = new PipeStream();
|
||||
|
||||
try
|
||||
{
|
||||
target.Seek(offset, origin);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SetLengthShouldThrowNotSupportedException()
|
||||
{
|
||||
var target = new PipeStream();
|
||||
|
||||
try
|
||||
{
|
||||
target.SetLength(1);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WriteTest()
|
||||
{
|
||||
var target = new PipeStream();
|
||||
|
||||
var writeBuffer = new byte[] {0x0a, 0x05, 0x0d};
|
||||
target.Write(writeBuffer, 0, 2);
|
||||
|
||||
writeBuffer = new byte[] { 0x02, 0x04, 0x03, 0x06, 0x09 };
|
||||
target.Write(writeBuffer, 1, 2);
|
||||
|
||||
var readBuffer = new byte[6];
|
||||
var bytesRead = target.Read(readBuffer, 0, 4);
|
||||
|
||||
Assert.AreEqual(4, bytesRead);
|
||||
Assert.AreEqual(0x0a, readBuffer[0]);
|
||||
Assert.AreEqual(0x05, readBuffer[1]);
|
||||
Assert.AreEqual(0x04, readBuffer[2]);
|
||||
Assert.AreEqual(0x03, readBuffer[3]);
|
||||
Assert.AreEqual(0x00, readBuffer[4]);
|
||||
Assert.AreEqual(0x00, readBuffer[5]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for BlockLastReadBuffer
|
||||
///</summary>
|
||||
[TestMethod]
|
||||
public void BlockLastReadBufferTest()
|
||||
{
|
||||
PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
|
||||
bool expected = false; // TODO: Initialize to an appropriate value
|
||||
bool actual;
|
||||
target.BlockLastReadBuffer = expected;
|
||||
actual = target.BlockLastReadBuffer;
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CanReadTest()
|
||||
{
|
||||
var target = new PipeStream();
|
||||
Assert.IsTrue(target.CanRead);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CanSeekTest()
|
||||
{
|
||||
var target = new PipeStream(); // TODO: Initialize to an appropriate value
|
||||
Assert.IsFalse(target.CanSeek);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CanWriteTest()
|
||||
{
|
||||
var target = new PipeStream();
|
||||
Assert.IsTrue(target.CanWrite);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LengthTest()
|
||||
{
|
||||
PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
|
||||
long actual;
|
||||
actual = target.Length;
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for MaxBufferLength
|
||||
///</summary>
|
||||
[TestMethod]
|
||||
public void MaxBufferLengthTest()
|
||||
{
|
||||
PipeStream target = new PipeStream(); // TODO: Initialize to an appropriate value
|
||||
long expected = 0; // TODO: Initialize to an appropriate value
|
||||
long actual;
|
||||
target.MaxBufferLength = expected;
|
||||
actual = target.MaxBufferLength;
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Position_GetterAlwaysReturnsZero()
|
||||
{
|
||||
var target = new PipeStream();
|
||||
|
||||
Assert.AreEqual(0, target.Position);
|
||||
target.WriteByte(0x0a);
|
||||
Assert.AreEqual(0, target.Position);
|
||||
target.ReadByte();
|
||||
Assert.AreEqual(0, target.Position);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Position_SetterAlwaysThrowsNotSupportedException()
|
||||
{
|
||||
var target = new PipeStream();
|
||||
|
||||
try
|
||||
{
|
||||
target.Position = 0;
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +1,67 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
using System;
|
||||
using System.Net;
|
||||
using Renci.SshNet.Tests.Properties;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for <see cref="Renci.SshNet.ForwardedPort.RequestReceived"/> event.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class PortForwardEventArgsTest : TestBase
|
||||
{
|
||||
[TestMethod]
|
||||
public void ConstructorShouldThrowArgumentNullExceptionWhenHostIsNull()
|
||||
{
|
||||
try
|
||||
{
|
||||
new PortForwardEventArgs(null, 80);
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
Assert.IsNull(ex.InnerException);
|
||||
Assert.AreEqual("host", ex.ParamName);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ConstructorShouldNotThrowExceptionWhenHostIsEmpty()
|
||||
{
|
||||
var host = string.Empty;
|
||||
|
||||
var eventArgs = new PortForwardEventArgs(host, 80);
|
||||
|
||||
Assert.AreSame(host, eventArgs.OriginatorHost);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ConstructorShouldNotThrowExceptionWhenHostIsInvalidDnsName()
|
||||
{
|
||||
const string host = "in_valid_host.";
|
||||
|
||||
var eventArgs = new PortForwardEventArgs(host, 80);
|
||||
|
||||
Assert.AreSame(host, eventArgs.OriginatorHost);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ConstructorShouldThrowArgumentOutOfRangeExceptionWhenPortIsGreaterThanMaximumValue()
|
||||
{
|
||||
const int port = IPEndPoint.MaxPort + 1;
|
||||
|
||||
try
|
||||
{
|
||||
new PortForwardEventArgs(Resources.HOST, port);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (ArgumentOutOfRangeException ex)
|
||||
{
|
||||
Assert.IsNull(ex.InnerException);
|
||||
Assert.AreEqual("port", ex.ParamName);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
using System;
|
||||
using System.Net;
|
||||
using Renci.SshNet.Tests.Properties;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for <see cref="Renci.SshNet.ForwardedPort.RequestReceived"/> event.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class PortForwardEventArgsTest : TestBase
|
||||
{
|
||||
[TestMethod]
|
||||
public void ConstructorShouldThrowArgumentNullExceptionWhenHostIsNull()
|
||||
{
|
||||
try
|
||||
{
|
||||
new PortForwardEventArgs(null, 80);
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
Assert.IsNull(ex.InnerException);
|
||||
Assert.AreEqual("host", ex.ParamName);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ConstructorShouldNotThrowExceptionWhenHostIsEmpty()
|
||||
{
|
||||
var host = string.Empty;
|
||||
|
||||
var eventArgs = new PortForwardEventArgs(host, 80);
|
||||
|
||||
Assert.AreSame(host, eventArgs.OriginatorHost);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ConstructorShouldNotThrowExceptionWhenHostIsInvalidDnsName()
|
||||
{
|
||||
const string host = "in_valid_host.";
|
||||
|
||||
var eventArgs = new PortForwardEventArgs(host, 80);
|
||||
|
||||
Assert.AreSame(host, eventArgs.OriginatorHost);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ConstructorShouldThrowArgumentOutOfRangeExceptionWhenPortIsGreaterThanMaximumValue()
|
||||
{
|
||||
const int port = IPEndPoint.MaxPort + 1;
|
||||
|
||||
try
|
||||
{
|
||||
new PortForwardEventArgs(Resources.HOST, port);
|
||||
Assert.Fail();
|
||||
}
|
||||
catch (ArgumentOutOfRangeException ex)
|
||||
{
|
||||
Assert.IsNull(ex.InnerException);
|
||||
Assert.AreEqual("port", ex.ParamName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
public partial class ProxyExceptionTest : TestBase
|
||||
{
|
||||
}
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
public partial class ProxyExceptionTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,48 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for ProxyExceptionTest and is intended
|
||||
///to contain all ProxyExceptionTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class ProxyExceptionTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for ProxyException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ProxyExceptionConstructorTest()
|
||||
{
|
||||
ProxyException target = new ProxyException();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ProxyException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ProxyExceptionConstructorTest1()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
ProxyException target = new ProxyException(message);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ProxyException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ProxyExceptionConstructorTest2()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
Exception innerException = null; // TODO: Initialize to an appropriate value
|
||||
ProxyException target = new ProxyException(message, innerException);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for ProxyExceptionTest and is intended
|
||||
///to contain all ProxyExceptionTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class ProxyExceptionTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for ProxyException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ProxyExceptionConstructorTest()
|
||||
{
|
||||
ProxyException target = new ProxyException();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ProxyException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ProxyExceptionConstructorTest1()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
ProxyException target = new ProxyException(message);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ProxyException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ProxyExceptionConstructorTest2()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
Exception innerException = null; // TODO: Initialize to an appropriate value
|
||||
ProxyException target = new ProxyException(message, innerException);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for ScpDownloadEventArgsTest and is intended
|
||||
///to contain all ScpDownloadEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class ScpDownloadEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for ScpDownloadEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ScpDownloadEventArgsConstructorTest()
|
||||
{
|
||||
string filename = string.Empty; // TODO: Initialize to an appropriate value
|
||||
long size = 0; // TODO: Initialize to an appropriate value
|
||||
long downloaded = 0; // TODO: Initialize to an appropriate value
|
||||
ScpDownloadEventArgs target = new ScpDownloadEventArgs(filename, size, downloaded);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for ScpDownloadEventArgsTest and is intended
|
||||
///to contain all ScpDownloadEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class ScpDownloadEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for ScpDownloadEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ScpDownloadEventArgsConstructorTest()
|
||||
{
|
||||
string filename = string.Empty; // TODO: Initialize to an appropriate value
|
||||
long size = 0; // TODO: Initialize to an appropriate value
|
||||
long downloaded = 0; // TODO: Initialize to an appropriate value
|
||||
ScpDownloadEventArgs target = new ScpDownloadEventArgs(filename, size, downloaded);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for ScpExceptionTest and is intended
|
||||
///to contain all ScpExceptionTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class ScpExceptionTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for ScpException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ScpExceptionConstructorTest()
|
||||
{
|
||||
ScpException target = new ScpException();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ScpException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ScpExceptionConstructorTest1()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
ScpException target = new ScpException(message);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ScpException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ScpExceptionConstructorTest2()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
Exception innerException = null; // TODO: Initialize to an appropriate value
|
||||
ScpException target = new ScpException(message, innerException);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for ScpExceptionTest and is intended
|
||||
///to contain all ScpExceptionTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class ScpExceptionTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for ScpException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ScpExceptionConstructorTest()
|
||||
{
|
||||
ScpException target = new ScpException();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ScpException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ScpExceptionConstructorTest1()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
ScpException target = new ScpException(message);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for ScpException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ScpExceptionConstructorTest2()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
Exception innerException = null; // TODO: Initialize to an appropriate value
|
||||
ScpException target = new ScpException(message, innerException);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for ScpUploadEventArgsTest and is intended
|
||||
///to contain all ScpUploadEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class ScpUploadEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for ScpUploadEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ScpUploadEventArgsConstructorTest()
|
||||
{
|
||||
string filename = string.Empty; // TODO: Initialize to an appropriate value
|
||||
long size = 0; // TODO: Initialize to an appropriate value
|
||||
long uploaded = 0; // TODO: Initialize to an appropriate value
|
||||
ScpUploadEventArgs target = new ScpUploadEventArgs(filename, size, uploaded);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for ScpUploadEventArgsTest and is intended
|
||||
///to contain all ScpUploadEventArgsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class ScpUploadEventArgsTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for ScpUploadEventArgs Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void ScpUploadEventArgsConstructorTest()
|
||||
{
|
||||
string filename = string.Empty; // TODO: Initialize to an appropriate value
|
||||
long size = 0; // TODO: Initialize to an appropriate value
|
||||
long uploaded = 0; // TODO: Initialize to an appropriate value
|
||||
ScpUploadEventArgs target = new ScpUploadEventArgs(filename, size, uploaded);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,94 +1,94 @@
|
||||
using System.Threading;
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
[TestClass()]
|
||||
public class SemaphoreLightTest : TestBase
|
||||
{
|
||||
[TestMethod()]
|
||||
public void SemaphoreLightConstructorTest()
|
||||
{
|
||||
var initialCount = new Random().Next(1, 10);
|
||||
var target = new SemaphoreLight(initialCount);
|
||||
Assert.AreEqual(initialCount, target.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void Release()
|
||||
{
|
||||
var initialCount = new Random().Next(1, 10);
|
||||
var target = new SemaphoreLight(initialCount);
|
||||
|
||||
Assert.AreEqual(initialCount, target.Release());
|
||||
Assert.AreEqual(initialCount + 1, target.CurrentCount);
|
||||
|
||||
Assert.AreEqual(initialCount + 1, target.Release());
|
||||
Assert.AreEqual(initialCount + 2, target.CurrentCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Release
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void Release_ReleaseCount()
|
||||
{
|
||||
var initialCount = new Random().Next(1, 10);
|
||||
var target = new SemaphoreLight(initialCount);
|
||||
|
||||
var releaseCount1 = new Random().Next(1, 10);
|
||||
Assert.AreEqual(initialCount, target.Release(releaseCount1));
|
||||
Assert.AreEqual(initialCount + releaseCount1, target.CurrentCount);
|
||||
|
||||
var releaseCount2 = new Random().Next(1, 10);
|
||||
Assert.AreEqual(initialCount + releaseCount1, target.Release(releaseCount2));
|
||||
Assert.AreEqual(initialCount + releaseCount1 + releaseCount2, target.CurrentCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Wait
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WaitTest()
|
||||
{
|
||||
const int sleepTime = 200;
|
||||
const int initialCount = 2;
|
||||
var target = new SemaphoreLight(initialCount);
|
||||
|
||||
var start = DateTime.Now;
|
||||
|
||||
target.Wait();
|
||||
target.Wait();
|
||||
|
||||
Assert.IsTrue((DateTime.Now - start).TotalMilliseconds < 50);
|
||||
|
||||
var releaseThread = new Thread(
|
||||
() =>
|
||||
{
|
||||
Thread.Sleep(sleepTime);
|
||||
target.Release();
|
||||
});
|
||||
releaseThread.Start();
|
||||
|
||||
target.Wait();
|
||||
|
||||
var end = DateTime.Now;
|
||||
var elapsed = end - start;
|
||||
|
||||
Assert.IsTrue(elapsed.TotalMilliseconds > 200);
|
||||
Assert.IsTrue(elapsed.TotalMilliseconds < 250);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void CurrentCountTest()
|
||||
{
|
||||
var initialCount = new Random().Next(1, 20);
|
||||
var target = new SemaphoreLight(initialCount);
|
||||
|
||||
Assert.AreEqual(initialCount, target.CurrentCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Threading;
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
[TestClass()]
|
||||
public class SemaphoreLightTest : TestBase
|
||||
{
|
||||
[TestMethod()]
|
||||
public void SemaphoreLightConstructorTest()
|
||||
{
|
||||
var initialCount = new Random().Next(1, 10);
|
||||
var target = new SemaphoreLight(initialCount);
|
||||
Assert.AreEqual(initialCount, target.CurrentCount);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void Release()
|
||||
{
|
||||
var initialCount = new Random().Next(1, 10);
|
||||
var target = new SemaphoreLight(initialCount);
|
||||
|
||||
Assert.AreEqual(initialCount, target.Release());
|
||||
Assert.AreEqual(initialCount + 1, target.CurrentCount);
|
||||
|
||||
Assert.AreEqual(initialCount + 1, target.Release());
|
||||
Assert.AreEqual(initialCount + 2, target.CurrentCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Release
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void Release_ReleaseCount()
|
||||
{
|
||||
var initialCount = new Random().Next(1, 10);
|
||||
var target = new SemaphoreLight(initialCount);
|
||||
|
||||
var releaseCount1 = new Random().Next(1, 10);
|
||||
Assert.AreEqual(initialCount, target.Release(releaseCount1));
|
||||
Assert.AreEqual(initialCount + releaseCount1, target.CurrentCount);
|
||||
|
||||
var releaseCount2 = new Random().Next(1, 10);
|
||||
Assert.AreEqual(initialCount + releaseCount1, target.Release(releaseCount2));
|
||||
Assert.AreEqual(initialCount + releaseCount1 + releaseCount2, target.CurrentCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for Wait
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void WaitTest()
|
||||
{
|
||||
const int sleepTime = 200;
|
||||
const int initialCount = 2;
|
||||
var target = new SemaphoreLight(initialCount);
|
||||
|
||||
var start = DateTime.Now;
|
||||
|
||||
target.Wait();
|
||||
target.Wait();
|
||||
|
||||
Assert.IsTrue((DateTime.Now - start).TotalMilliseconds < 50);
|
||||
|
||||
var releaseThread = new Thread(
|
||||
() =>
|
||||
{
|
||||
Thread.Sleep(sleepTime);
|
||||
target.Release();
|
||||
});
|
||||
releaseThread.Start();
|
||||
|
||||
target.Wait();
|
||||
|
||||
var end = DateTime.Now;
|
||||
var elapsed = end - start;
|
||||
|
||||
Assert.IsTrue(elapsed.TotalMilliseconds > 200);
|
||||
Assert.IsTrue(elapsed.TotalMilliseconds < 250);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void CurrentCountTest()
|
||||
{
|
||||
var initialCount = new Random().Next(1, 20);
|
||||
var target = new SemaphoreLight(initialCount);
|
||||
|
||||
Assert.AreEqual(initialCount, target.CurrentCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for SftpPathNotFoundExceptionTest and is intended
|
||||
///to contain all SftpPathNotFoundExceptionTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class SftpPathNotFoundExceptionTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for SftpPathNotFoundException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void SftpPathNotFoundExceptionConstructorTest()
|
||||
{
|
||||
SftpPathNotFoundException target = new SftpPathNotFoundException();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for SftpPathNotFoundException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void SftpPathNotFoundExceptionConstructorTest1()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
SftpPathNotFoundException target = new SftpPathNotFoundException(message);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for SftpPathNotFoundException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void SftpPathNotFoundExceptionConstructorTest2()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
Exception innerException = null; // TODO: Initialize to an appropriate value
|
||||
SftpPathNotFoundException target = new SftpPathNotFoundException(message, innerException);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
using Renci.SshNet.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for SftpPathNotFoundExceptionTest and is intended
|
||||
///to contain all SftpPathNotFoundExceptionTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class SftpPathNotFoundExceptionTest : TestBase
|
||||
{
|
||||
/// <summary>
|
||||
///A test for SftpPathNotFoundException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void SftpPathNotFoundExceptionConstructorTest()
|
||||
{
|
||||
SftpPathNotFoundException target = new SftpPathNotFoundException();
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for SftpPathNotFoundException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void SftpPathNotFoundExceptionConstructorTest1()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
SftpPathNotFoundException target = new SftpPathNotFoundException(message);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///A test for SftpPathNotFoundException Constructor
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void SftpPathNotFoundExceptionConstructorTest2()
|
||||
{
|
||||
string message = string.Empty; // TODO: Initialize to an appropriate value
|
||||
Exception innerException = null; // TODO: Initialize to an appropriate value
|
||||
SftpPathNotFoundException target = new SftpPathNotFoundException(message, innerException);
|
||||
Assert.Inconclusive("TODO: Implement code to verify target");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user