You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/test/Volo.Abp.Tests/Volo/Abp/DependencyInjection/AutoRegistrationHelper_Test...

57 lines
1.5 KiB

using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using System.Linq;
using Xunit;
namespace Volo.Abp.DependencyInjection
{
public class AutoRegistrationHelper_Tests
{
[Fact]
public void Should_Get_Conventional_Exposed_Types_By_Default()
{
//Act
var exposedServices = AutoRegistrationHelper.GetExposedServices(new ServiceCollection(), typeof(DefaultDerivedService)).ToList();
//Assert
exposedServices.Count.ShouldBe(3);
exposedServices.ShouldContain(typeof(DefaultDerivedService));
exposedServices.ShouldContain(typeof(IService));
exposedServices.ShouldContain(typeof(IDerivedService));
}
[Fact]
public void Should_Get_Custom_Exposed_Types_If_Available()
{
//Act
var exposedServices = AutoRegistrationHelper.GetExposedServices(new ServiceCollection(), typeof(ExplicitDerivedService)).ToList();
//Assert
exposedServices.Count.ShouldBe(1);
exposedServices.ShouldContain(typeof(IDerivedService));
}
public class DefaultDerivedService : IDerivedService
{
}
public interface IService
{
}
public interface IDerivedService : IService
{
}
[ExposeServices(typeof(IDerivedService))]
public class ExplicitDerivedService : IDerivedService
{
}
}
}