DD.WellWorkover.Cloud/AsbCloudWebApi.Tests/AspExtensions.cs
Frolov-Nikita cfe936abf0
remove DateValidationAttribute,
reorganize and fix unitTests
2024-01-21 13:43:15 +05:00

20 lines
620 B
C#

using Microsoft.Extensions.DependencyInjection;
using System.Linq;
namespace AsbCloudWebApi.Tests
{
public static class AspExtensions
{
public static IServiceCollection ReplaceService<T>(this IServiceCollection services, T instance)
where T : notnull
{
var typeofT = typeof(T);
var originalDecriptor = services.Last(s => s.ServiceType == typeofT);
var newDecriptor = new ServiceDescriptor(typeofT, instance);
services.Remove(originalDecriptor);
services.Add(newDecriptor);
return services;
}
}
}