Loading files
using Microsoft.Extensions.DependencyInjection;
namespace Moq;
public static class MoqExtensions
{
public static IServiceCollection AddMock<T>(this IServiceCollection services)
where T : class =>
services.AddSingleton<T>(_ => new Mock<T>().Object);
public static void ForceMock<T>(this Mock<T> mock, IServiceCollection services)
where T : class
{
services.RemoveImplementationsOf<T>();
services.AddSingleton(mock.Object);
}
}
7f9864208This file is pinned to the selected release. Download the original to open it in your design tool.