- Change exception type from ArgumentOutOfRangeException to ArgumentException - Fix node seeking logic by correcting candidate order - Update Visit, Insert, and Remove methods with proper range checks - Enhance cursor management after removal operations - Add comprehensive test cases for edge scenarios - Introduce AssertExtension for better exception testing - Handle empty collection states more robustly
29 lines
937 B
C#
29 lines
937 B
C#
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BallanceTasEditorTests {
|
|
public static class AssertExtension {
|
|
public static T ThrowsDerivedException<T>(Action action) where T : Exception {
|
|
try {
|
|
action();
|
|
} catch (T ex) {
|
|
return ex;
|
|
} catch (Exception ex) {
|
|
if (ex is T derivedEx)
|
|
return derivedEx;
|
|
|
|
throw new AssertFailedException(
|
|
$"Expected exception of type {typeof(T)} or derived type, but got {ex.GetType()}. " +
|
|
$"Message: {ex.Message}");
|
|
}
|
|
|
|
throw new AssertFailedException(
|
|
$"Expected exception of type {typeof(T)} or derived type, but no exception was thrown.");
|
|
}
|
|
}
|
|
}
|