Files
mus65 c0a353a4de Cleanup formatting and style and enforce it in CI (#1380)
* Preparation to enforce formatting and style in CI

- enabled IDE0055 to enforce formatting on build
- disabled SA1137 and SA1025 because they are already
  covered by IDE0055
- disabled SA1021 because it conflicts with csharp_space_after_cast

* Cleanup formatting and style on codebase

This commit has no manual changes, it is the result
of running "dotnet format whitespace" and "dotnet format style"

* new formatting fixes after merge

* appveyor: set git autocrlf

as suggested by sharwell to hopefully fix Windows CI.

* use autocrlf input

to hopefully fix Linux tests

* fix formatting

* use autocrlf input for Linux only

* set csharp_space_after_cast to false

* Revert SA1021 suppression

---------

Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
2024-05-17 22:34:27 +02:00

70 lines
1.9 KiB
C#

using System;
using System.Net;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
using Renci.SshNet.Tests.Properties;
namespace Renci.SshNet.Tests.Classes.Common
{
/// <summary>
/// Provides data for <see cref="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);
}
}
}
}