Files
dependabot[bot] 16d84d0395 Bump test dependencies (#1583)
* Bump coverlet.collector from 6.0.2 to 6.0.4

Bumps [coverlet.collector](https://github.com/coverlet-coverage/coverlet) from 6.0.2 to 6.0.4.
- [Release notes](https://github.com/coverlet-coverage/coverlet/releases)
- [Commits](https://github.com/coverlet-coverage/coverlet/compare/v6.0.2...v6.0.4)

---
updated-dependencies:
- dependency-name: coverlet.collector
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* update test deps

* update test deps

* some fixes

* group dependencies

* analyzer fixes

* just group them all together

* more cleanup

* silent analyzers -> suggestion

* restore constant

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2025-02-04 21:58:59 +01:00

61 lines
1.6 KiB
C#

using System;
using System.IO;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Renci.SshNet.Tests.Common
{
public abstract class TestBase
{
private static readonly Assembly ExecutingAssembly = Assembly.GetExecutingAssembly();
[TestInitialize]
public void Init()
{
OnInit();
}
[TestCleanup]
public void Cleanup()
{
OnCleanup();
}
protected virtual void OnInit()
{
}
protected virtual void OnCleanup()
{
}
/// <summary>
/// Creates the test file.
/// </summary>
/// <param name="fileName">Name of the file.</param>
/// <param name="size">Size in megabytes.</param>
protected void CreateTestFile(string fileName, int size)
{
using (var testFile = File.Create(fileName))
{
var random = new Random();
for (int i = 0; i < 1024 * size; i++)
{
var buffer = new byte[1024];
random.NextBytes(buffer);
testFile.Write(buffer, 0, buffer.Length);
}
}
}
internal static Stream GetData(string name)
{
string resourceName = $"Renci.SshNet.Tests.Data.{name}";
return ExecutingAssembly.GetManifestResourceStream(resourceName)
?? throw new ArgumentException($"Resource '{resourceName}' not found in assembly '{typeof(TestBase).Assembly.FullName}'.");
}
}
}