Interface IMockCollection<TMock>
- Namespace
- Mokkit.Containers.Common
- Assembly
- Mokkit.Containers.Common.dll
Represents a collection of mock registrations that provides fluent registration methods for mock objects. This interface extends System.Collections.Generic.IList`1 to provide list functionality while adding mock-specific registration methods.
public interface IMockCollection<TMock> : IList<MockRegistration<TMock>>, ICollection<MockRegistration<TMock>>, IEnumerable<MockRegistration<TMock>>, IEnumerableType Parameters
TMock-
The type of mock objects managed by this collection.
Implements
Properties
Registrations
Gets a read-only collection of all mock registrations in this collection.
IReadOnlyCollection<MockRegistration<TMock>> Registrations { get; }Property Value
- IReadOnlyCollection<MockRegistration<TMock>>
Methods
AddMock<T>(Func<TMock>)
Adds a mock registration for the specified type with the provided factory function. If a registration for the type already exists, this method will replace it.
IMockCollection<TMock> AddMock<T>(Func<TMock> factory)Parameters
factoryFunc<TMock>-
The factory function that creates the mock instance.
Returns
- IMockCollection<TMock>
-
The current Mokkit.Containers.Common.IMockCollection`1 instance for method chaining.
Type Parameters
T-
The type to register the mock for.
TryAddMock<T>(Func<TMock>)
Attempts to add a mock registration for the specified type with the provided factory function. If a registration for the type already exists, this method will not replace it.
IMockCollection<TMock> TryAddMock<T>(Func<TMock> factory)Parameters
factoryFunc<TMock>-
The factory function that creates the mock instance.
Returns
- IMockCollection<TMock>
-
The current Mokkit.Containers.Common.IMockCollection`1 instance for method chaining.
Type Parameters
T-
The type to register the mock for.