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

47 lines
1.6 KiB
C#

using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Renci.SshNet.Tests.Common
{
public static class DictionaryAssert
{
public static void AreEqual<TKey, TValue>(IDictionary<TKey, TValue> expected, IDictionary<TKey, TValue> actual)
{
if (ReferenceEquals(expected, actual))
{
return;
}
if (expected == null)
{
throw new AssertFailedException("Expected dictionary to be null, but was not null.");
}
if (actual == null)
{
throw new AssertFailedException("Expected dictionary not to be null, but was null.");
}
if (expected.Count != actual.Count)
{
throw new AssertFailedException(string.Format("Expected dictionary to contain {0} entries, but was {1}.",
expected.Count, actual.Count));
}
foreach (var expectedEntry in expected)
{
if (!actual.TryGetValue(expectedEntry.Key, out var actualValue))
{
throw new AssertFailedException(string.Format("Dictionary contains no entry with key '{0}'.", expectedEntry.Key));
}
if (!Equals(expectedEntry.Value, actualValue))
{
throw new AssertFailedException(string.Format("Value for key '{0}' does not match.", expectedEntry.Key));
}
}
}
}
}