mirror of https://github.com/abpframework/abp.git
965 changed files with 56646 additions and 47150 deletions
@ -0,0 +1,7 @@ |
|||
./1-fetch-and-build.ps1 |
|||
./2-nuget-pack.ps1 |
|||
./3-nuget-push.ps1 |
|||
./4-npm-publish-mvc.ps1 |
|||
./5-npm-publish-angular.ps1 |
|||
./6-git-commit.ps1 |
|||
echo "Create a new release on GitHub manually and run the step 8..." |
|||
@ -0,0 +1,94 @@ |
|||
# ABP.IO Platform 5.1 RC.1 Has Been Released |
|||
|
|||
Today, we are releasing the [ABP Framework](https://abp.io/) and the [ABP Commercial](https://commercial.abp.io/) version **5.1 RC** (Release Candidate). This blog post introduces the new features and important changes in this new version. |
|||
|
|||
> **The planned release date for the [5.1 stable](https://github.com/abpframework/abp/milestone/64) version is February 8, 2022**. |
|||
|
|||
Please try this version and provide feedback for a more stable ABP version 5.1! Thank you all. |
|||
|
|||
## Get Started with the 5.1 RC |
|||
|
|||
follow the steps below to try the version 5.1 RC today; |
|||
|
|||
1) **Upgrade** the ABP CLI to the version `5.1.0-rc.1` using a command line terminal: |
|||
|
|||
````bash |
|||
dotnet tool update Volo.Abp.Cli -g --version 5.1.0-rc.1 |
|||
```` |
|||
|
|||
**or install** if you haven't installed before: |
|||
|
|||
````bash |
|||
dotnet tool install Volo.Abp.Cli -g --version 5.1.0-rc.1 |
|||
```` |
|||
|
|||
2) Create a **new application** with the `--preview` option: |
|||
|
|||
````bash |
|||
abp new BookStore --preview |
|||
```` |
|||
|
|||
See the [ABP CLI documentation](https://docs.abp.io/en/abp/latest/CLI) for all the available options. |
|||
|
|||
> You can also use the *Direct Download* tab on the [Get Started](https://abp.io/get-started) page by selecting the **Preview checkbox**. |
|||
|
|||
You can use any IDE that supports .NET 6.0 development (e.g. [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/)). |
|||
|
|||
### Migration Notes & Breaking Changes |
|||
|
|||
TODO: Startup template changes |
|||
|
|||
## What's new with 5.1? |
|||
|
|||
In this section, I will introduce some major features released with this version. |
|||
|
|||
### DRAFT list of things done |
|||
|
|||
#### ABP Framework |
|||
|
|||
* Use new hosting model for the app template. [#10928](https://github.com/abpframework/abp/pull/10928) - what to do for existing solutions? |
|||
* Async application initialization methods on the AbpModule class [#6828](https://github.com/abpframework/abp/issues/6828) |
|||
* Angular 13? |
|||
* [#10552](https://github.com/abpframework/abp/pull/10696) Used file scoped namespaces :) |
|||
* Support markdown in CMS-Kit comments [#10792](https://github.com/abpframework/abp/pull/10792) |
|||
* eShopOnAbp is getting mature |
|||
* Nightly builds are working again |
|||
* Coming: New ABP.IO design! |
|||
|
|||
All issues & PRs in [5.1 milesone](https://github.com/abpframework/abp/milestone/60?closed=1). |
|||
|
|||
#### ABP Commercial |
|||
|
|||
* CMS Kit Pro: URL forwarding |
|||
* LeptonX is coming for ABP Blazor and MVC UI too (share the sample dashboard) |
|||
|
|||
### Header 1 |
|||
|
|||
TODO |
|||
|
|||
## Community News |
|||
|
|||
### ABP Community Talks 2021.1 |
|||
|
|||
 |
|||
|
|||
This is the second episode of the ABP Community Talks and we are talking about microservice development with the ABP Framework, based on the [eShopOnAbp](https://github.com/abpframework/eShopOnAbp) reference solution. This live meeting will be at **January 20, 2022, 17:00 (UTC)** on YouTube. |
|||
|
|||
**Join this event on the Kommunity platform: https://kommunity.com/volosoft/events/abp-community-talks-20221-microservice-development-acd0f44b** |
|||
|
|||
You can also [subscribe to the Volosoft channel](https://www.youtube.com/channel/UCO3XKlpvq8CA5MQNVS6b3dQ) for reminders for further ABP events and videos. |
|||
|
|||
### New ABP Community posts |
|||
|
|||
Here, some of the recent posts added to the [ABP community](https://community.abp.io/): |
|||
|
|||
* [Minimal API development with the ABP Framework](https://community.abp.io/articles/minimal-api-with-abp-hello-world-part-1-sg5i44p8) by [@antosubash](https://github.com/antosubash) (three parts, video tutorial). |
|||
* [Integrating the Syncfusion MVC Components to the ABP MVC UI](https://community.abp.io/articles/integrating-the-syncfusion-mvc-components-to-the-abp-mvc-ui-0gpkr1if) by [@EngincanV](https://github.com/EngincanV). |
|||
* [Add Tailwind CSS to your ABP Blazor UI](https://community.abp.io/articles/add-tailwindcss-to-your-abp-blazor-ui-vidiwzcy) by [@antosubash](https://github.com/antosubash) (video tutorial). |
|||
* [Import external users into the users Table from an ABP Framework application](https://community.abp.io/articles/import-external-users-into-the-users-table-from-an-abp-framework-application-7lnyw415) by [@bartvanhoey](https://github.com/bartvanhoey). |
|||
|
|||
Thanks to the ABP Community for all the contents they have published. You can also [post your ABP and .NET related (text or video) contents](https://community.abp.io/articles/submit) to the ABP Community. |
|||
|
|||
## Conclusion |
|||
|
|||
In this blog post, I summarized the news about that new version and the ABP Community. Please try it and provide feedback by opening issues on [the GitHub repository](https://github.com/abpframework/abp). Thank you all! |
|||
|
After Width: | Height: | Size: 559 KiB |
@ -0,0 +1,111 @@ |
|||
# How to Test Blazor Components in ABP |
|||
|
|||
## Source Code |
|||
|
|||
You can find the source of the example solution used in this article [here](https://github.com/abpframework/abp-samples/tree/master/BlazorPageUniTest). |
|||
|
|||
|
|||
In this article, I will use [bUnit](https://github.com/bUnit-dev/bUnit) for a simple test of a Blazor component. |
|||
|
|||
## Getting Started |
|||
|
|||
Use the ABP CLI to create a blazor app |
|||
|
|||
`abp new BookStore -t app -u blazor` |
|||
|
|||
Then add the `BookStore.Blazor.Tests` xunit test project to the solution, and add [bUnit](https://github.com/bUnit-dev/bUnit) package and `ProjectReference` to the test project. |
|||
|
|||
The contents of `BookStore.Blazor.Tests.csproj` |
|||
```xml |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<Nullable>enable</Nullable> |
|||
<IsPackable>false</IsPackable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="bunit" Version="1.2.49" /> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> |
|||
<PackageReference Include="Volo.Abp.Authorization.Abstractions" Version="5.0.1" /> |
|||
<PackageReference Include="xunit" Version="2.4.1" /> |
|||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> |
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
|||
<PrivateAssets>all</PrivateAssets> |
|||
</PackageReference> |
|||
<PackageReference Include="coverlet.collector" Version="3.1.0"> |
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
|||
<PrivateAssets>all</PrivateAssets> |
|||
</PackageReference> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\BookStore.Blazor\BookStore.Blazor.csproj" /> |
|||
<ProjectReference Include="..\BookStore.EntityFrameworkCore.Tests\BookStore.EntityFrameworkCore.Tests.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
``` |
|||
|
|||
Create `BookStoreBlazorTestModule` that depends on `AbpAspNetCoreComponentsModule` and `BookStoreEntityFrameworkCoreTestModule`. |
|||
|
|||
```cs |
|||
[DependsOn( |
|||
typeof(AbpAspNetCoreComponentsModule), |
|||
typeof(BookStoreEntityFrameworkCoreTestModule) |
|||
)] |
|||
public class BookStoreBlazorTestModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
``` |
|||
|
|||
Create a `BookStoreBlazorTestBase` class and add the `CreateTestContext` method. The `CreateTestContext` have key code. |
|||
|
|||
It uses ABP's `ServiceProvider` as a fallback `ServiceProvider` and add all ABP's services to the `TestContext`. |
|||
|
|||
```cs |
|||
public abstract class BookStoreBlazorTestBase : BookStoreTestBase<BookStoreBlazorTestModule> |
|||
{ |
|||
protected virtual TestContext CreateTestContext() |
|||
{ |
|||
var testContext = new TestContext(); |
|||
testContext.Services.AddFallbackServiceProvider(ServiceProvider); |
|||
foreach (var service in ServiceProvider.GetRequiredService<IAbpApplicationWithExternalServiceProvider>().Services) |
|||
{ |
|||
testContext.Services.Add(service); |
|||
} |
|||
testContext.Services.AddBlazorise().AddBootstrap5Providers().AddFontAwesomeIcons(); |
|||
return testContext; |
|||
} |
|||
} |
|||
``` |
|||
|
|||
Finally, we add an `Index_Tests` class to test the `Index` component. |
|||
|
|||
```cs |
|||
public class Index_Tests : BookStoreBlazorTestBase |
|||
{ |
|||
[Fact] |
|||
public void Index_Test() |
|||
{ |
|||
using (var ctx = CreateTestContext()) |
|||
{ |
|||
// Act |
|||
var cut = ctx.RenderComponent<BookStore.Blazor.Pages.Index>(); |
|||
|
|||
// Assert |
|||
cut.Find(".lead").InnerHtml.Contains("Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io.").ShouldBeTrue(); |
|||
|
|||
cut.Find("#username").InnerHtml.Contains("Welcome admin").ShouldBeTrue(); |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Reference document |
|||
|
|||
https://github.com/bUnit-dev/bUnit |
|||
|
|||
https://docs.microsoft.com/en-us/aspnet/core/blazor/test |
|||
File diff suppressed because it is too large
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 38 KiB |
@ -0,0 +1,52 @@ |
|||
using System; |
|||
using System.Collections.Concurrent; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
|
|||
namespace Volo.Abp.EventBus; |
|||
|
|||
public class EventHandlerInvoker : IEventHandlerInvoker, ISingletonDependency |
|||
{ |
|||
private readonly ConcurrentDictionary<string, EventHandlerInvokerCacheItem> _cache; |
|||
|
|||
public EventHandlerInvoker() |
|||
{ |
|||
_cache = new ConcurrentDictionary<string, EventHandlerInvokerCacheItem>(); |
|||
} |
|||
|
|||
public async Task InvokeAsync(IEventHandler eventHandler, object eventData, Type eventType) |
|||
{ |
|||
var cacheItem = _cache.GetOrAdd($"{eventHandler.GetType().FullName}-{eventType.FullName}", _ => |
|||
{ |
|||
var item = new EventHandlerInvokerCacheItem(); |
|||
|
|||
if (typeof(ILocalEventHandler<>).MakeGenericType(eventType).IsInstanceOfType(eventHandler)) |
|||
{ |
|||
item.Local = (IEventHandlerMethodExecutor)Activator.CreateInstance(typeof(LocalEventHandlerMethodExecutor<>).MakeGenericType(eventType)); |
|||
} |
|||
|
|||
if (typeof(IDistributedEventHandler<>).MakeGenericType(eventType).IsInstanceOfType(eventHandler)) |
|||
{ |
|||
item.Distributed = (IEventHandlerMethodExecutor)Activator.CreateInstance(typeof(DistributedEventHandlerMethodExecutor<>).MakeGenericType(eventType)); |
|||
} |
|||
|
|||
return item; |
|||
}); |
|||
|
|||
if (cacheItem.Local != null) |
|||
{ |
|||
await cacheItem.Local.ExecutorAsync(eventHandler, eventData); |
|||
} |
|||
|
|||
if (cacheItem.Distributed != null) |
|||
{ |
|||
await cacheItem.Distributed.ExecutorAsync(eventHandler, eventData); |
|||
} |
|||
|
|||
if (cacheItem.Local == null && cacheItem.Distributed == null) |
|||
{ |
|||
throw new AbpException("The object instance is not an event handler. Object type: " + eventHandler.GetType().AssemblyQualifiedName); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace Volo.Abp.EventBus; |
|||
|
|||
public class EventHandlerInvokerCacheItem |
|||
{ |
|||
public IEventHandlerMethodExecutor Local { get; set; } |
|||
|
|||
public IEventHandlerMethodExecutor Distributed { get; set; } |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
|
|||
namespace Volo.Abp.EventBus; |
|||
|
|||
public delegate Task EventHandlerMethodExecutorAsync(IEventHandler target, object parameter); |
|||
|
|||
public interface IEventHandlerMethodExecutor |
|||
{ |
|||
EventHandlerMethodExecutorAsync ExecutorAsync { get; } |
|||
} |
|||
|
|||
public class LocalEventHandlerMethodExecutor<TEvent> : IEventHandlerMethodExecutor |
|||
where TEvent : class |
|||
{ |
|||
public EventHandlerMethodExecutorAsync ExecutorAsync => (target, parameter) => target.As<ILocalEventHandler<TEvent>>().HandleEventAsync(parameter.As<TEvent>()); |
|||
|
|||
public Task ExecuteAsync(IEventHandler target, TEvent parameters) |
|||
{ |
|||
return ExecutorAsync(target, parameters); |
|||
} |
|||
} |
|||
|
|||
public class DistributedEventHandlerMethodExecutor<TEvent> : IEventHandlerMethodExecutor |
|||
where TEvent : class |
|||
{ |
|||
public EventHandlerMethodExecutorAsync ExecutorAsync => (target, parameter) => target.As<IDistributedEventHandler<TEvent>>().HandleEventAsync(parameter.As<TEvent>()); |
|||
|
|||
public Task ExecuteAsync(IEventHandler target, TEvent parameters) |
|||
{ |
|||
return ExecutorAsync(target, parameters); |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.EventBus; |
|||
|
|||
public interface IEventHandlerInvoker |
|||
{ |
|||
Task InvokeAsync(IEventHandler eventHandler, object eventData, Type eventType); |
|||
} |
|||
@ -1,33 +0,0 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.Options; |
|||
using Volo.Abp.Settings; |
|||
|
|||
namespace Volo.Abp.Ldap; |
|||
|
|||
public class AbpAbpLdapOptionsManager : AbpDynamicOptionsManager<AbpLdapOptions> |
|||
{ |
|||
protected ISettingProvider SettingProvider { get; } |
|||
|
|||
public AbpAbpLdapOptionsManager(IOptionsFactory<AbpLdapOptions> factory, ISettingProvider settingProvider) |
|||
: base(factory) |
|||
{ |
|||
SettingProvider = settingProvider; |
|||
} |
|||
|
|||
protected override async Task OverrideOptionsAsync(string name, AbpLdapOptions options) |
|||
{ |
|||
options.ServerHost = await GetSettingOrDefaultValue(LdapSettingNames.ServerHost, options.ServerHost); |
|||
options.ServerPort = await SettingProvider.GetAsync(LdapSettingNames.ServerPort, options.ServerPort); |
|||
options.BaseDc = await GetSettingOrDefaultValue(LdapSettingNames.BaseDc, options.BaseDc); |
|||
options.UserName = await GetSettingOrDefaultValue(LdapSettingNames.UserName, options.UserName); |
|||
options.Password = await GetSettingOrDefaultValue(LdapSettingNames.Password, options.Password); |
|||
} |
|||
|
|||
protected virtual async Task<string> GetSettingOrDefaultValue(string name, string defaultValue) |
|||
{ |
|||
var value = await SettingProvider.GetOrNullAsync(name); |
|||
return value.IsNullOrWhiteSpace() ? defaultValue : value; |
|||
} |
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
namespace Volo.Abp.Ldap; |
|||
|
|||
public class AbpLdapOptions |
|||
{ |
|||
public string ServerHost { get; set; } |
|||
|
|||
public int ServerPort { get; set; } |
|||
|
|||
public string BaseDc { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// BindDN
|
|||
/// </summary>
|
|||
public string UserName { get; set; } |
|||
|
|||
/// <summary>
|
|||
///BindPassword
|
|||
/// </summary>
|
|||
public string Password { get; set; } |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.Ldap; |
|||
|
|||
public interface ILdapSettingProvider |
|||
{ |
|||
public Task<string> GetServerHostAsync(); |
|||
|
|||
public Task<int> GetServerPortAsync(); |
|||
|
|||
public Task<string> GetBaseDcAsync(); |
|||
|
|||
public Task<string> GetDomainAsync(); |
|||
|
|||
public Task<string> GetUserNameAsync(); |
|||
|
|||
public Task<string> GetPasswordAsync(); |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
using Volo.Abp.Ldap.Localization; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Settings; |
|||
|
|||
namespace Volo.Abp.Ldap; |
|||
|
|||
public class LdapSettingDefinitionProvider : SettingDefinitionProvider |
|||
{ |
|||
public override void Define(ISettingDefinitionContext context) |
|||
{ |
|||
context.Add( |
|||
new SettingDefinition( |
|||
LdapSettingNames.ServerHost, |
|||
"", |
|||
L("DisplayName:Abp.Ldap.ServerHost"), |
|||
L("Description:Abp.Ldap.ServerHost")), |
|||
|
|||
new SettingDefinition( |
|||
LdapSettingNames.ServerPort, |
|||
"389", |
|||
L("DisplayName:Abp.Ldap.ServerPort"), |
|||
L("Description:Abp.Ldap.ServerPort")), |
|||
|
|||
new SettingDefinition( |
|||
LdapSettingNames.BaseDc, |
|||
"", |
|||
L("DisplayName:Abp.Ldap.BaseDc"), |
|||
L("Description:Abp.Ldap.BaseDc")), |
|||
|
|||
new SettingDefinition( |
|||
LdapSettingNames.Domain, |
|||
"", |
|||
L("DisplayName:Abp.Ldap.Domain"), |
|||
L("Description:Abp.Ldap.Domain")), |
|||
|
|||
new SettingDefinition( |
|||
LdapSettingNames.UserName, |
|||
"", |
|||
L("DisplayName:Abp.Ldap.UserName"), |
|||
L("Description:Abp.Ldap.UserName")), |
|||
|
|||
new SettingDefinition( |
|||
LdapSettingNames.Password, |
|||
"", |
|||
L("DisplayName:Abp.Ldap.Password"), |
|||
L("Description:Abp.Ldap.Password"), |
|||
isEncrypted: true) |
|||
); |
|||
} |
|||
|
|||
private static LocalizableString L(string name) |
|||
{ |
|||
return LocalizableString.Create<LdapResource>(name); |
|||
} |
|||
} |
|||
@ -1,49 +1,46 @@ |
|||
using Volo.Abp.Ldap.Localization; |
|||
using Volo.Abp.Localization; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Settings; |
|||
|
|||
namespace Volo.Abp.Ldap; |
|||
|
|||
public class LdapSettingProvider : SettingDefinitionProvider |
|||
public class LdapSettingProvider : ILdapSettingProvider, ITransientDependency |
|||
{ |
|||
public override void Define(ISettingDefinitionContext context) |
|||
protected ISettingProvider SettingProvider { get; } |
|||
|
|||
public LdapSettingProvider(ISettingProvider settingProvider) |
|||
{ |
|||
SettingProvider = settingProvider; |
|||
} |
|||
|
|||
public async Task<string> GetServerHostAsync() |
|||
{ |
|||
return await SettingProvider.GetOrNullAsync(LdapSettingNames.ServerHost); |
|||
} |
|||
|
|||
public async Task<int> GetServerPortAsync() |
|||
{ |
|||
return (await SettingProvider.GetOrNullAsync(LdapSettingNames.ServerPort))?.To<int>() ?? default; |
|||
} |
|||
|
|||
public async Task<string> GetBaseDcAsync() |
|||
{ |
|||
return await SettingProvider.GetOrNullAsync(LdapSettingNames.BaseDc); |
|||
} |
|||
|
|||
public async Task<string> GetDomainAsync() |
|||
{ |
|||
return await SettingProvider.GetOrNullAsync(LdapSettingNames.Domain); |
|||
} |
|||
|
|||
public async Task<string> GetUserNameAsync() |
|||
{ |
|||
context.Add( |
|||
new SettingDefinition( |
|||
LdapSettingNames.ServerHost, |
|||
"", |
|||
L("DisplayName:Abp.Ldap.ServerHost"), |
|||
L("Description:Abp.Ldap.ServerHost")), |
|||
|
|||
new SettingDefinition( |
|||
LdapSettingNames.ServerPort, |
|||
"389", |
|||
L("DisplayName:Abp.Ldap.ServerPort"), |
|||
L("Description:Abp.Ldap.ServerPort")), |
|||
|
|||
new SettingDefinition( |
|||
LdapSettingNames.BaseDc, |
|||
"", |
|||
L("DisplayName:Abp.Ldap.BaseDc"), |
|||
L("Description:Abp.Ldap.BaseDc")), |
|||
|
|||
new SettingDefinition( |
|||
LdapSettingNames.UserName, |
|||
"", |
|||
L("DisplayName:Abp.Ldap.UserName"), |
|||
L("Description:Abp.Ldap.UserName")), |
|||
|
|||
new SettingDefinition( |
|||
LdapSettingNames.Password, |
|||
"", |
|||
L("DisplayName:Abp.Ldap.Password"), |
|||
L("Description:Abp.Ldap.Password"), |
|||
isEncrypted: true) |
|||
); |
|||
return await SettingProvider.GetOrNullAsync(LdapSettingNames.UserName); |
|||
} |
|||
|
|||
private static LocalizableString L(string name) |
|||
public async Task<string> GetPasswordAsync() |
|||
{ |
|||
return LocalizableString.Create<LdapResource>(name); |
|||
return await SettingProvider.GetOrNullAsync(LdapSettingNames.Password); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,128 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Shouldly; |
|||
using Volo.Abp.Domain.Entities; |
|||
using Volo.Abp.Domain.Entities.Events; |
|||
using Volo.Abp.Domain.Entities.Events.Distributed; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.EventBus.Local; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.EventBus; |
|||
|
|||
public class EventHandlerInvoker_Tests : EventBusTestBase |
|||
{ |
|||
private readonly IEventHandlerInvoker _eventHandlerInvoker; |
|||
|
|||
public EventHandlerInvoker_Tests() |
|||
{ |
|||
_eventHandlerInvoker = GetRequiredService<IEventHandlerInvoker>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_Invoke_LocalEventHandler_With_MyEventData() |
|||
{ |
|||
var localHandler = new MyLocalEventHandler(); |
|||
var eventData = new MyEventData(); |
|||
|
|||
await _eventHandlerInvoker.InvokeAsync(localHandler, eventData, eventData.GetType()); |
|||
|
|||
localHandler.MyEventDataCount.ShouldBe(2); |
|||
localHandler.EntityChangedEventDataCount.ShouldBe(0); |
|||
localHandler.EntityChangedEventDataCount.ShouldBe(0); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_Invoke_LocalEventHandler_Created_And_Changed_Once() |
|||
{ |
|||
var localHandler = new MyLocalEventHandler(); |
|||
var eventData = new EntityCreatedEventData<MyEntity>(new MyEntity()); |
|||
|
|||
await _eventHandlerInvoker.InvokeAsync(localHandler, eventData, eventData.GetType()); |
|||
await _eventHandlerInvoker.InvokeAsync(localHandler, eventData, typeof(EntityChangedEventData<MyEntity>)); |
|||
|
|||
localHandler.MyEventDataCount.ShouldBe(0); |
|||
localHandler.EntityChangedEventDataCount.ShouldBe(1); |
|||
localHandler.EntityChangedEventDataCount.ShouldBe(1); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_Invoke_DistributedEventHandler_With_MyEventData() |
|||
{ |
|||
var localHandler = new MyDistributedEventHandler(); |
|||
var eventData = new MyEventData(); |
|||
|
|||
await _eventHandlerInvoker.InvokeAsync(localHandler, eventData, eventData.GetType()); |
|||
|
|||
localHandler.MyEventDataCount.ShouldBe(1); |
|||
localHandler.EntityCreatedCount.ShouldBe(0); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_Invoke_DistributedEventHandler_With_EntityCreatedEto() |
|||
{ |
|||
var localHandler = new MyDistributedEventHandler(); |
|||
var eventData = new EntityCreatedEto<MyEntity>(new MyEntity()); |
|||
|
|||
await _eventHandlerInvoker.InvokeAsync(localHandler, eventData, eventData.GetType()); |
|||
|
|||
localHandler.MyEventDataCount.ShouldBe(0); |
|||
localHandler.EntityCreatedCount.ShouldBe(1); |
|||
} |
|||
|
|||
public class MyEventData |
|||
{ |
|||
} |
|||
|
|||
public class MyEntity : Entity<Guid> |
|||
{ |
|||
|
|||
} |
|||
|
|||
public class MyDistributedEventHandler : IDistributedEventHandler<MyEventData>, |
|||
IDistributedEventHandler<EntityCreatedEto<MyEntity>> |
|||
{ |
|||
public int MyEventDataCount { get; set; } |
|||
public int EntityCreatedCount { get; set; } |
|||
|
|||
public Task HandleEventAsync(MyEventData eventData) |
|||
{ |
|||
MyEventDataCount++; |
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
public Task HandleEventAsync(EntityCreatedEto<MyEntity> eventData) |
|||
{ |
|||
EntityCreatedCount++; |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
|
|||
public class MyLocalEventHandler : ILocalEventHandler<MyEventData>, |
|||
IDistributedEventHandler<MyEventData>, |
|||
IDistributedEventHandler<EntityCreatedEventData<MyEntity>>, |
|||
IDistributedEventHandler<EntityChangedEventData<MyEntity>> |
|||
{ |
|||
public int MyEventDataCount { get; set; } |
|||
public int EntityCreatedEventDataCount { get; set; } |
|||
public int EntityChangedEventDataCount { get; set; } |
|||
|
|||
public Task HandleEventAsync(MyEventData eventData) |
|||
{ |
|||
MyEventDataCount++; |
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
public Task HandleEventAsync(EntityCreatedEventData<MyEntity> eventData) |
|||
{ |
|||
EntityCreatedEventDataCount++; |
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
public Task HandleEventAsync(EntityChangedEventData<MyEntity> eventData) |
|||
{ |
|||
EntityChangedEventDataCount++; |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
using Microsoft.Extensions.Options; |
|||
using Shouldly; |
|||
using Volo.Abp.Testing; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.Ldap; |
|||
|
|||
public class LdapOptions_Tests : AbpIntegratedTest<AbpLdapTestModule> |
|||
{ |
|||
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) |
|||
{ |
|||
options.UseAutofac(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_Resolve_AbpAbpLdapOptionsFactory() |
|||
{ |
|||
GetRequiredService<IOptions<AbpLdapOptions>>().ShouldBeOfType(typeof(AbpAbpLdapOptionsManager)); |
|||
} |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Settings; |
|||
|
|||
namespace Volo.Abp.Ldap; |
|||
|
|||
public class TestLdapSettingValueProvider : ISettingValueProvider, ITransientDependency |
|||
{ |
|||
public const string ProviderName = "Test"; |
|||
|
|||
public string Name => ProviderName; |
|||
|
|||
public Task<string> GetOrNullAsync(SettingDefinition setting) |
|||
{ |
|||
switch (setting.Name) |
|||
{ |
|||
case LdapSettingNames.ServerHost: |
|||
return Task.FromResult("localhost"); |
|||
|
|||
case LdapSettingNames.ServerPort: |
|||
return Task.FromResult("389"); |
|||
|
|||
case LdapSettingNames.BaseDc: |
|||
return Task.FromResult("dc=abp,dc=io"); |
|||
|
|||
case LdapSettingNames.Domain: |
|||
return Task.FromResult<string>(null); |
|||
|
|||
case LdapSettingNames.UserName: |
|||
return Task.FromResult("admin"); |
|||
|
|||
case LdapSettingNames.Password: |
|||
return Task.FromResult("123qwe"); |
|||
|
|||
default: |
|||
return Task.FromResult<string>(null); |
|||
} |
|||
} |
|||
|
|||
public Task<List<SettingValue>> GetAllAsync(SettingDefinition[] settings) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
{ |
|||
"name": "Volo.Abp.Account.Application.Contracts", |
|||
"hash": "eda5b3412f7e1dd8dc07761a04f3a064", |
|||
"contents": [ |
|||
{ |
|||
"namespace": "Volo.Abp.Account", |
|||
"contentType": "abpModule", |
|||
"name": "AbpAccountApplicationContractsModule" |
|||
} |
|||
] |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue