diff --git a/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs b/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs index 75924ab110..33726ca163 100644 --- a/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs +++ b/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; @@ -27,10 +28,17 @@ namespace Volo.Abp.Domain.Repositories //Assert + //MyTestAggregateRootWithoutPk services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestDefaultRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestDefaultRepository)); + + //MyTestAggregateRootWithGuidPk services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestDefaultRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestDefaultRepository)); services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestDefaultRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestDefaultRepository)); + //MyTestEntityWithInt32Pk services.ShouldNotContainService(typeof(IBasicRepository)); } @@ -50,11 +58,21 @@ namespace Volo.Abp.Domain.Repositories //Assert + //MyTestAggregateRootWithoutPk services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestDefaultRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestDefaultRepository)); + + //MyTestAggregateRootWithGuidPk services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestDefaultRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestDefaultRepository)); services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestDefaultRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestDefaultRepository)); + + //MyTestEntityWithInt32Pk services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestDefaultRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestDefaultRepository)); services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestDefaultRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestDefaultRepository)); } [Fact] @@ -75,10 +93,19 @@ namespace Volo.Abp.Domain.Repositories //Assert + //MyTestAggregateRootWithoutPk services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestDefaultRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestDefaultRepository)); + + //MyTestAggregateRootWithGuidPk services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestAggregateRootWithDefaultPkCustomRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestAggregateRootWithDefaultPkCustomRepository)); services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestAggregateRootWithDefaultPkCustomRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestAggregateRootWithDefaultPkCustomRepository)); + + //MyTestEntityWithInt32Pk services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestDefaultRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestDefaultRepository)); } [Fact] @@ -99,10 +126,19 @@ namespace Volo.Abp.Domain.Repositories //Assert + //MyTestAggregateRootWithoutPk services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestCustomBaseRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestCustomBaseRepository)); + + //MyTestAggregateRootWithGuidPk services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestCustomBaseRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestCustomBaseRepository)); services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestCustomBaseRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestCustomBaseRepository)); + + //MyTestEntityWithInt32Pk services.ShouldContainTransient(typeof(IBasicRepository), typeof(MyTestCustomBaseRepository)); + services.ShouldContainTransient(typeof(IRepository), typeof(MyTestCustomBaseRepository)); } public class MyTestRepositoryRegistrar : RepositoryRegistrarBase @@ -150,7 +186,7 @@ namespace Volo.Abp.Domain.Repositories public string MyId { get; set; } } - public class MyTestDefaultRepository : BasicRepositoryBase + public class MyTestDefaultRepository : RepositoryBase where TEntity : class, IEntity { public override TEntity Insert(TEntity entity, bool autoSave = false) @@ -167,9 +203,14 @@ namespace Volo.Abp.Domain.Repositories { throw new NotImplementedException(); } + + protected override IQueryable GetQueryable() + { + throw new NotImplementedException(); + } } - public class MyTestDefaultRepository : MyTestDefaultRepository, IBasicRepository + public class MyTestDefaultRepository : MyTestDefaultRepository, IRepository where TEntity : class, IEntity { public TEntity Get(TKey id)