// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CommunityToolkit.Mvvm.UnitTests.Helpers;
///
/// A helper class to validate scenarios related to -s.
///
internal static class ExceptionHelper
{
///
/// Asserts that a given action throws an with a specific parameter name.
///
/// The input to invoke.
/// The expected parameter name.
public static void ThrowsArgumentExceptionWithParameterName(Action action, string parameterName)
{
bool success = false;
try
{
action();
}
catch (Exception e)
{
Assert.IsTrue(e.GetType() == typeof(ArgumentException));
Assert.AreEqual(parameterName, ((ArgumentException)e).ParamName);
success = true;
}
Assert.IsTrue(success);
}
}