diff --git a/Volo.Abp.sln b/Volo.Abp.sln index a0564a2690..6e24dbafe1 100644 --- a/Volo.Abp.sln +++ b/Volo.Abp.sln @@ -118,13 +118,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.AutoMapper", "src\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.AutoMapper.Tests", "test\Volo.Abp.AutoMapper.Tests\Volo.Abp.AutoMapper.Tests.csproj", "{8343BE23-6A7B-4C58-BF0D-95188B11B180}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.Tests", "test\Volo.Abp.AspNetCore.Mvc.Tests\Volo.Abp.AspNetCore.Mvc.Tests.csproj", "{27D76546-6091-4AEE-9079-1FE3991C81BC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.AspNetCore.Mvc.Tests", "test\Volo.Abp.AspNetCore.Mvc.Tests\Volo.Abp.AspNetCore.Mvc.Tests.csproj", "{27D76546-6091-4AEE-9079-1FE3991C81BC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.TestApp", "test\Volo.Abp.TestApp\Volo.Abp.TestApp.csproj", "{DE160F1A-92FB-44BA-87E2-B8AD7A938AC7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.TestApp", "test\Volo.Abp.TestApp\Volo.Abp.TestApp.csproj", "{DE160F1A-92FB-44BA-87E2-B8AD7A938AC7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.MemoryDb", "src\Volo.Abp.MemoryDb\Volo.Abp.MemoryDb.csproj", "{CF564447-8E0B-4A07-B0D2-396E00A8E437}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.MemoryDb", "src\Volo.Abp.MemoryDb\Volo.Abp.MemoryDb.csproj", "{CF564447-8E0B-4A07-B0D2-396E00A8E437}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.MemoryDb.Tests", "test\Volo.Abp.MemoryDb.Tests\Volo.Abp.MemoryDb.Tests.csproj", "{D0279C94-E9A3-4A1B-968B-D3BBF3E06FD8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.MemoryDb.Tests", "test\Volo.Abp.MemoryDb.Tests\Volo.Abp.MemoryDb.Tests.csproj", "{D0279C94-E9A3-4A1B-968B-D3BBF3E06FD8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.TestApp.Tests", "test\Volo.Abp.TestApp.Tests\Volo.Abp.TestApp.Tests.csproj", "{4C2F7B03-C598-4432-A43A-B065D9D0712F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -312,6 +314,10 @@ Global {D0279C94-E9A3-4A1B-968B-D3BBF3E06FD8}.Debug|Any CPU.Build.0 = Debug|Any CPU {D0279C94-E9A3-4A1B-968B-D3BBF3E06FD8}.Release|Any CPU.ActiveCfg = Release|Any CPU {D0279C94-E9A3-4A1B-968B-D3BBF3E06FD8}.Release|Any CPU.Build.0 = Release|Any CPU + {4C2F7B03-C598-4432-A43A-B065D9D0712F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4C2F7B03-C598-4432-A43A-B065D9D0712F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4C2F7B03-C598-4432-A43A-B065D9D0712F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4C2F7B03-C598-4432-A43A-B065D9D0712F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -371,6 +377,7 @@ Global {DE160F1A-92FB-44BA-87E2-B8AD7A938AC7} = {37087D1B-3693-4E96-983D-A69F210BDE53} {CF564447-8E0B-4A07-B0D2-396E00A8E437} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8} {D0279C94-E9A3-4A1B-968B-D3BBF3E06FD8} = {37087D1B-3693-4E96-983D-A69F210BDE53} + {4C2F7B03-C598-4432-A43A-B065D9D0712F} = {37087D1B-3693-4E96-983D-A69F210BDE53} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperConfigurationContext.cs b/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperConfigurationContext.cs new file mode 100644 index 0000000000..e11ce2534c --- /dev/null +++ b/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperConfigurationContext.cs @@ -0,0 +1,19 @@ +using System; +using AutoMapper; + +namespace Volo.Abp.AutoMapper +{ + public class AbpAutoMapperConfigurationContext : IAbpAutoMapperConfigurationContext + { + public IMapperConfigurationExpression MapperConfiguration { get; } + public IServiceProvider ServiceProvider { get; } + + public AbpAutoMapperConfigurationContext( + IMapperConfigurationExpression mapperConfigurationExpression, + IServiceProvider serviceProvider) + { + MapperConfiguration = mapperConfigurationExpression; + ServiceProvider = serviceProvider; + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperModule.cs b/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperModule.cs index afc09e3a08..1dcbb1da24 100644 --- a/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperModule.cs +++ b/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperModule.cs @@ -81,6 +81,8 @@ namespace Volo.Abp.AutoMapper private void FindAndAutoMapTypes(IAbpAutoMapperConfigurationContext context) { + //TODO: AutoMapping (by attributes) can be optionally enabled/disabled. + var typeFinder = context.ServiceProvider.GetRequiredService(); var logger = context.ServiceProvider.GetRequiredService>(); diff --git a/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperOptions.cs b/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperOptions.cs index a98bb88dbd..030084764b 100644 --- a/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperOptions.cs +++ b/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperOptions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using AutoMapper; namespace Volo.Abp.AutoMapper { @@ -16,25 +15,4 @@ namespace Volo.Abp.AutoMapper Configurators = new List>(); } } - - public interface IAbpAutoMapperConfigurationContext - { - IMapperConfigurationExpression MapperConfiguration { get; } - - IServiceProvider ServiceProvider { get; } - } - - public class AbpAutoMapperConfigurationContext : IAbpAutoMapperConfigurationContext - { - public IMapperConfigurationExpression MapperConfiguration { get; } - public IServiceProvider ServiceProvider { get; } - - public AbpAutoMapperConfigurationContext( - IMapperConfigurationExpression mapperConfigurationExpression, - IServiceProvider serviceProvider) - { - MapperConfiguration = mapperConfigurationExpression; - ServiceProvider = serviceProvider; - } - } } \ No newline at end of file diff --git a/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/IAbpAutoMapperConfigurationContext.cs b/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/IAbpAutoMapperConfigurationContext.cs new file mode 100644 index 0000000000..885e9f0d64 --- /dev/null +++ b/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/IAbpAutoMapperConfigurationContext.cs @@ -0,0 +1,12 @@ +using System; +using AutoMapper; + +namespace Volo.Abp.AutoMapper +{ + public interface IAbpAutoMapperConfigurationContext + { + IMapperConfigurationExpression MapperConfiguration { get; } + + IServiceProvider ServiceProvider { get; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp/Volo/Abp/Application/Services/AsyncCrudAppService.cs b/src/Volo.Abp/Volo/Abp/Application/Services/AsyncCrudAppService.cs index adc6795dcb..f69a11fe51 100644 --- a/src/Volo.Abp/Volo/Abp/Application/Services/AsyncCrudAppService.cs +++ b/src/Volo.Abp/Volo/Abp/Application/Services/AsyncCrudAppService.cs @@ -13,7 +13,7 @@ namespace Abp.Application.Services where TEntity : class, IEntity where TEntityDto : IEntityDto { - protected AsyncCrudAppService(IRepository repository) + protected AsyncCrudAppService(IQueryableRepository repository) : base(repository) { @@ -25,7 +25,7 @@ namespace Abp.Application.Services where TEntity : class, IEntity where TEntityDto : IEntityDto { - protected AsyncCrudAppService(IRepository repository) + protected AsyncCrudAppService(IQueryableRepository repository) : base(repository) { @@ -37,7 +37,7 @@ namespace Abp.Application.Services where TEntity : class, IEntity where TEntityDto : IEntityDto { - protected AsyncCrudAppService(IRepository repository) + protected AsyncCrudAppService(IQueryableRepository repository) : base(repository) { @@ -51,7 +51,7 @@ namespace Abp.Application.Services where TEntityDto : IEntityDto where TCreateInput : IEntityDto { - protected AsyncCrudAppService(IRepository repository) + protected AsyncCrudAppService(IQueryableRepository repository) : base(repository) { @@ -64,7 +64,7 @@ namespace Abp.Application.Services where TEntityDto : IEntityDto where TUpdateInput : IEntityDto { - protected AsyncCrudAppService(IRepository repository) + protected AsyncCrudAppService(IQueryableRepository repository) : base(repository) { @@ -78,7 +78,7 @@ namespace Abp.Application.Services where TUpdateInput : IEntityDto where TGetInput : IEntityDto { - protected AsyncCrudAppService(IRepository repository) + protected AsyncCrudAppService(IQueryableRepository repository) : base(repository) { @@ -96,7 +96,7 @@ namespace Abp.Application.Services { public IAsyncQueryableExecuter AsyncQueryableExecuter { get; set; } - protected AsyncCrudAppService(IRepository repository) + protected AsyncCrudAppService(IQueryableRepository repository) :base(repository) { AsyncQueryableExecuter = DefaultAsyncQueryableExecuter.Instance; diff --git a/src/Volo.Abp/Volo/Abp/Application/Services/CrudAppService.cs b/src/Volo.Abp/Volo/Abp/Application/Services/CrudAppService.cs index 64e0cf8e92..22fc061b27 100644 --- a/src/Volo.Abp/Volo/Abp/Application/Services/CrudAppService.cs +++ b/src/Volo.Abp/Volo/Abp/Application/Services/CrudAppService.cs @@ -11,7 +11,7 @@ namespace Abp.Application.Services where TEntity : class, IEntity where TEntityDto : IEntityDto { - protected CrudAppService(IRepository repository) + protected CrudAppService(IQueryableRepository repository) : base(repository) { @@ -23,7 +23,7 @@ namespace Abp.Application.Services where TEntity : class, IEntity where TEntityDto : IEntityDto { - protected CrudAppService(IRepository repository) + protected CrudAppService(IQueryableRepository repository) : base(repository) { @@ -35,7 +35,7 @@ namespace Abp.Application.Services where TEntity : class, IEntity where TEntityDto : IEntityDto { - protected CrudAppService(IRepository repository) + protected CrudAppService(IQueryableRepository repository) : base(repository) { @@ -48,7 +48,7 @@ namespace Abp.Application.Services where TEntityDto : IEntityDto where TCreateInput : IEntityDto { - protected CrudAppService(IRepository repository) + protected CrudAppService(IQueryableRepository repository) : base(repository) { @@ -61,7 +61,7 @@ namespace Abp.Application.Services where TEntityDto : IEntityDto where TUpdateInput : IEntityDto { - protected CrudAppService(IRepository repository) + protected CrudAppService(IQueryableRepository repository) : base(repository) { @@ -75,7 +75,7 @@ namespace Abp.Application.Services where TUpdateInput : IEntityDto where TGetInput : IEntityDto { - protected CrudAppService(IRepository repository) + protected CrudAppService(IQueryableRepository repository) : base(repository) { @@ -91,7 +91,7 @@ namespace Abp.Application.Services where TGetInput : IEntityDto where TDeleteInput : IEntityDto { - protected CrudAppService(IRepository repository) + protected CrudAppService(IQueryableRepository repository) : base(repository) { diff --git a/src/Volo.Abp/Volo/Abp/Application/Services/CrudAppServiceBase.cs b/src/Volo.Abp/Volo/Abp/Application/Services/CrudAppServiceBase.cs index 9cea5dfb60..0a40e55e5b 100644 --- a/src/Volo.Abp/Volo/Abp/Application/Services/CrudAppServiceBase.cs +++ b/src/Volo.Abp/Volo/Abp/Application/Services/CrudAppServiceBase.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using System.Linq.Dynamic.Core; -using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Entities; @@ -18,7 +17,7 @@ namespace Abp.Application.Services where TEntityDto : IEntityDto where TUpdateInput : IEntityDto { - protected IRepository Repository { get; } + protected IQueryableRepository Repository { get; } protected virtual string GetPermissionName { get; set; } @@ -30,7 +29,7 @@ namespace Abp.Application.Services protected virtual string DeletePermissionName { get; set; } - protected CrudAppServiceBase(IRepository repository) + protected CrudAppServiceBase(IQueryableRepository repository) { Repository = repository; } @@ -96,13 +95,7 @@ namespace Abp.Application.Services /// The input. protected virtual IQueryable CreateFilteredQuery(TGetAllInput input) { - var queryableRepository = Repository as IQueryableRepository; - if (queryableRepository == null) - { - throw new AbpException("Repository should be IQueryableRepository in order to call CreateFilteredQuery, but it's not. It's type: " + Repository.GetType().AssemblyQualifiedName); - } - - return queryableRepository; + return Repository; } /// diff --git a/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/MemoryDbTestBase.cs b/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/MemoryDbTestBase.cs index 081dda8d4b..1835a247be 100644 --- a/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/MemoryDbTestBase.cs +++ b/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/MemoryDbTestBase.cs @@ -1,6 +1,6 @@ using Volo.Abp.TestBase; -namespace Volo.Abp.MemoryDb.Repositories +namespace Volo.Abp.MemoryDb { public abstract class MemoryDbTestBase : AbpIntegratedTest { diff --git a/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/Repositories/MemoryDb_Basic_Repository_Tests.cs b/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/Repositories/MemoryDb_Basic_Repository_Tests.cs index b20ba5c118..98812731f0 100644 --- a/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/Repositories/MemoryDb_Basic_Repository_Tests.cs +++ b/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/Repositories/MemoryDb_Basic_Repository_Tests.cs @@ -31,7 +31,7 @@ namespace Volo.Abp.MemoryDb.Repositories var name = Guid.NewGuid().ToString(); //Act - _personRepository.Insert(new Person(name, 42)); + _personRepository.Insert(new Person(Guid.NewGuid(), name, 42)); //Assert UseUnitOfWork(() => diff --git a/test/Volo.Abp.TestApp.Tests/Volo.Abp.TestApp.Tests.csproj b/test/Volo.Abp.TestApp.Tests/Volo.Abp.TestApp.Tests.csproj new file mode 100644 index 0000000000..745a514486 --- /dev/null +++ b/test/Volo.Abp.TestApp.Tests/Volo.Abp.TestApp.Tests.csproj @@ -0,0 +1,22 @@ + + + + netcoreapp2.0 + Volo.Abp.TestApp.Tests + Volo.Abp.TestApp.Tests + true + false + false + false + + + + + + + + + + + + diff --git a/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/Application/PersonAppService_Tests.cs b/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/Application/PersonAppService_Tests.cs new file mode 100644 index 0000000000..bd3d3f61dd --- /dev/null +++ b/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/Application/PersonAppService_Tests.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.DependencyInjection; +using Shouldly; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Xunit; + +namespace Volo.Abp.TestApp.Application +{ + public class PersonAppService_Tests : TestAppTestBase + { + private readonly IPersonAppService _personAppService; + + public PersonAppService_Tests() + { + _personAppService = ServiceProvider.GetRequiredService(); + } + + [Fact] + public async Task GetAll() + { + var people = await _personAppService.GetAll(new PagedAndSortedResultRequestDto()); + people.Items.Count.ShouldBeGreaterThan(0); + } + } +} diff --git a/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/TestAppTestBase.cs b/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/TestAppTestBase.cs new file mode 100644 index 0000000000..8a9daf346c --- /dev/null +++ b/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/TestAppTestBase.cs @@ -0,0 +1,12 @@ +using Volo.Abp.TestBase; + +namespace Volo.Abp.TestApp +{ + public class TestAppTestBase : AbpIntegratedTest + { + protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) + { + options.UseAutofac(); + } + } +} \ No newline at end of file diff --git a/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/TestAppTestModule.cs b/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/TestAppTestModule.cs new file mode 100644 index 0000000000..b7e16ad4b1 --- /dev/null +++ b/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/TestAppTestModule.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.MemoryDb; +using Volo.Abp.Modularity; + +namespace Volo.Abp.TestApp +{ + [DependsOn(typeof(AbpMemoryDbTestModule))] + public class TestAppTestModule : AbpModule + { + public override void ConfigureServices(IServiceCollection services) + { + services.AddAssemblyOf(); + } + } +} diff --git a/test/Volo.Abp.TestApp/Volo.Abp.TestApp.csproj b/test/Volo.Abp.TestApp/Volo.Abp.TestApp.csproj index 7b7cf5ac2a..5c04368a4b 100644 --- a/test/Volo.Abp.TestApp/Volo.Abp.TestApp.csproj +++ b/test/Volo.Abp.TestApp/Volo.Abp.TestApp.csproj @@ -12,11 +12,8 @@ + - - - - diff --git a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPersonAppService.cs b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPersonAppService.cs new file mode 100644 index 0000000000..c4d3041f33 --- /dev/null +++ b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPersonAppService.cs @@ -0,0 +1,8 @@ +using Abp.Application.Services; + +namespace Volo.Abp.TestApp.Application +{ + public interface IPersonAppService : IAsyncCrudAppService + { + } +} \ No newline at end of file diff --git a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PersonAppService.cs b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PersonAppService.cs new file mode 100644 index 0000000000..cd98f195db --- /dev/null +++ b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PersonAppService.cs @@ -0,0 +1,14 @@ +using Abp.Application.Services; +using Volo.Abp.TestApp.Domain; +using Volo.Abp.Domain.Repositories; + +namespace Volo.Abp.TestApp.Application +{ + public class PersonAppService : AsyncCrudAppService, IPersonAppService + { + public PersonAppService(IQueryableRepository repository) + : base(repository) + { + } + } +} diff --git a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PersonDto.cs b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PersonDto.cs new file mode 100644 index 0000000000..c894860275 --- /dev/null +++ b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PersonDto.cs @@ -0,0 +1,11 @@ +using Volo.Abp.Application.Dtos; + +namespace Volo.Abp.TestApp.Application +{ + public class PersonDto : EntityDto + { + public string Name { get; set; } + + public int Age { get; set; } + } +} diff --git a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Person.cs b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Person.cs index 78a8aabf9d..0f60b722a3 100644 --- a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Person.cs +++ b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/Person.cs @@ -1,3 +1,4 @@ +using System; using Volo.Abp.Domain.Entities; namespace Volo.Abp.TestApp.Domain @@ -8,8 +9,9 @@ namespace Volo.Abp.TestApp.Domain public int Age { get; set; } - public Person(string name, int age) + public Person(Guid id, string name, int age) { + Id = id; Name = name; Age = age; } diff --git a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/PersonAppService.cs b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/PersonAppService.cs deleted file mode 100644 index d50219b2ce..0000000000 --- a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Domain/PersonAppService.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections.Generic; -using Volo.Abp.Application.Services; - -namespace Volo.Abp.TestApp.Domain -{ - public class PersonAppService : ApplicationService - { - public List GetAll() - { - return new List - { - new Person("John", 33), - new Person("Dougles", 42), - }; - } - } -} diff --git a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/TestAppModule.cs b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/TestAppModule.cs index 25790a999f..941f92cea1 100644 --- a/test/Volo.Abp.TestApp/Volo/Abp/TestApp/TestAppModule.cs +++ b/test/Volo.Abp.TestApp/Volo/Abp/TestApp/TestAppModule.cs @@ -1,23 +1,36 @@ -using Microsoft.Extensions.DependencyInjection; +using System; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Domain.Repositories; using Volo.Abp.Modularity; using Volo.Abp.TestApp.Domain; +using Volo.Abp.AutoMapper; +using Volo.Abp.TestApp.Application; namespace Volo.Abp.TestApp { + [DependsOn(typeof(AbpAutoMapperModule))] public class TestAppModule : AbpModule { public override void ConfigureServices(IServiceCollection services) { + services.Configure(options => + { + options.Configurators.Add((IAbpAutoMapperConfigurationContext ctx) => + { + ctx.MapperConfiguration.CreateMap(); + }); + }); + services.AddAssemblyOf(); } public override void OnApplicationInitialization(ApplicationInitializationContext context) { + //TODO: Refactor to a seed class! using(IServiceScope scope = context.ServiceProvider.CreateScope()) { var personRepository = scope.ServiceProvider.GetRequiredService>(); - personRepository.Insert(new Person("Douglas", 42)); + personRepository.Insert(new Person(Guid.NewGuid(), "Douglas", 42)); } } }