From 9b19041c53cbd71f9aedaae0481b2513888a2f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 15 Mar 2018 23:17:06 +0300 Subject: [PATCH] Added test cases to RepositoryRegistration_Tests --- .../RepositoryRegistration_Tests.cs | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) 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)