Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 4, 2025

Refactors collection equality assertions to use the more appropriate CollectionAssert.AreEqual instead of Assert.IsTrue with .IsEqualTo() or .SequenceEqual().

Changes

  • 96 assertions refactored across 55 test files
  • Consistent argument order: CollectionAssert.AreEqual(expected, actual) throughout
  • Handled complex patterns:
    • Method calls: Encoding.UTF8.GetBytes(password).IsEqualTo(...)
    • Property access: target.Handle.SequenceEqual(...)
    • LINQ operations: Added .ToArray() for IEnumerable results from .Skip()
    • Custom extensions: Distinguished between byte[].Take() (custom, returns byte[]) and LINQ Take() (returns IEnumerable)
    • Custom error messages: Preserved in CollectionAssert.AreEqual(..., ..., message)

Example

Before:

Assert.IsTrue(actual.IsEqualTo(expected));
Assert.IsTrue(_handle.SequenceEqual(actualHandle));
Assert.IsTrue(expected.SequenceEqual(_dataReceivedByServer.Take(expected.Length)));

After:

CollectionAssert.AreEqual(expected, actual);
CollectionAssert.AreEqual(_handle, actualHandle);
CollectionAssert.AreEqual(expected, _dataReceivedByServer.Take(expected.Length).ToArray());

Note

111 IDE0005 warnings about unnecessary using System.Linq; directives remain - these can be auto-fixed separately.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 3a96ffa1915a49dfb84b11f5b2447950
  • 58982f06ee364cc49f621a6c0d464dbe
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net8.0/Renci.SshNet.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net8.0/Renci.SshNet.Tests.deps.json /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net8.0/testhost.dll --port 42663 --endpoint 127.0.0.1:042663 --role client --parentprocessid 3812 --telemetryoptedin false (dns block)
  • 6afc99696eee4389a33595c9cfe404bb
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net8.0/Renci.SshNet.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net8.0/Renci.SshNet.Tests.deps.json /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net8.0/testhost.dll --port 38561 --endpoint 127.0.0.1:038561 --role client --parentprocessid 7070 --telemetryoptedin false (dns block)
  • 6ba3b85ace0440d6b94db473a84aeb7b
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net9.0/Renci.SshNet.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net9.0/Renci.SshNet.Tests.deps.json /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net9.0/testhost.dll --port 43833 --endpoint 127.0.0.1:043833 --role client --parentprocessid 3805 --telemetryoptedin false (dns block)
  • 71484929c936441fa41ab97af04193c8
  • a835272fa37946bb8e12b38844fd1b79
  • b07c59bc49954075aab99d0334a6206a
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net8.0/Renci.SshNet.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net8.0/Renci.SshNet.Tests.deps.json /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net8.0/testhost.dll --port 38561 --endpoint 127.0.0.1:038561 --role client --parentprocessid 7070 --telemetryoptedin false (dns block)
  • be67715d7d0e4b678b2ca0715c4389ea
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net9.0/Renci.SshNet.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net9.0/Renci.SshNet.Tests.deps.json /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net9.0/testhost.dll --port 43833 --endpoint 127.0.0.1:043833 --role client --parentprocessid 3805 --telemetryoptedin false (dns block)
  • invalid
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net8.0/Renci.SshNet.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net8.0/Renci.SshNet.Tests.deps.json /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net8.0/testhost.dll --port 42663 --endpoint 127.0.0.1:042663 --role client --parentprocessid 3812 --telemetryoptedin false (dns block)
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net9.0/Renci.SshNet.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net9.0/Renci.SshNet.Tests.deps.json /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net9.0/testhost.dll --port 43833 --endpoint 127.0.0.1:043833 --role client --parentprocessid 3805 --telemetryoptedin false (dns block)
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net9.0/Renci.SshNet.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net9.0/Renci.SshNet.Tests.deps.json /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net9.0/testhost.dll --port 43113 --endpoint 127.0.0.1:043113 --role client --parentprocessid 7062 --telemetryoptedin false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

find all places in tests where some collections are being asserted for equality, e.g. Assert.IsTrue(xxx.IsEqualTo(yyy)) or Assert.IsTrue(xxx.SequenceEqual(yyy)) and replace them with CollectionAssert.AreEqual. Pay attention to the order of arguments to CollectionAssert.AreEqual - the expected value is the first argument and the actual value is the second. If there is a separate assertion on the collections' lengths, then remove it since CollectionsAssert.AreEqual takes care of that as well


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Replace Assert.IsTrue(xxx.IsEqualTo(yyy)) and Assert.IsTrue(xxx.SequenceEqual(yyy))
with CollectionAssert.AreEqual(expected, actual) across 55 test files

Co-authored-by: Rob-Hague <5132141+Rob-Hague@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor collection assertions to use CollectionAssert.AreEqual Replace Assert.IsTrue with CollectionAssert.AreEqual for collection comparisons Nov 4, 2025
Copilot AI requested a review from Rob-Hague November 4, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants