Code Structure - Extension Methods
Extension Methods are methods that add new functionality to existing types without modifying their original implementation.
Extension Methods are offered as part of the C#RA API. They are implemented as static methods that extend interfaces and types, providing consistent functionality across the library.
Implementation
Extension methods are defined on interfaces with XML documentation to provide context for users.
namespace Csra {
/// <summary>
/// Returns the single element of a sequence, or the element at the specified index if the sequence contains more than one element.
/// </summary>
[DebuggerStepThrough]
public static T SingleOrAt<T>(this T[] values, int index) => values.Length == 1 ? values[0] : values[index];
Mocking extension methods directly is not possible because they are static methods. Most mocking frameworks, including Moq, do not support mocking static methods, which limits the ability to mock extension methods directly.