mirror of https://github.com/abpframework/abp
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.
56 lines
1.4 KiB
56 lines
1.4 KiB
using System.Linq;
|
|
using Shouldly;
|
|
using Xunit;
|
|
|
|
namespace Volo.DependencyInjection
|
|
{
|
|
public class AutoRegistrationHelper_Tests
|
|
{
|
|
[Fact]
|
|
public void Should_Get_Conventional_Exposed_Types_By_Default()
|
|
{
|
|
//Act
|
|
|
|
var exposedServices = AutoRegistrationHelper.GetExposedServices(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(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
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|