diff --git a/README.md b/README.md
index dbf8bce537..ebba20da41 100644
--- a/README.md
+++ b/README.md
@@ -108,6 +108,10 @@ ABP is a community-driven open source project. See [the contribution guide](http
Love ABP Framework? **Please give a star** to this repository :star:
+## Discord Channel
+
+You can use this link to join the ABP Community Discord Server: https://discord.gg/abp
+
## ABP Commercial
See also [ABP Commercial](https://commercial.abp.io/) if you are looking for pre-built application modules, professional themes, code generation tooling and premium support for the ABP Framework.
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json
index d1890e1786..1dc0d7c1f7 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json
@@ -337,18 +337,6 @@
"Expired": "Expired",
"TrialLicenseDeletionWarningMessage": "Are you sure you want to delete the trial license? Trial license, organization, support accounts will be deleted!",
"LicenseCategoryFilter": "License category",
- "Volo.AbpIo.Commercial:030000": "You already used your trial period.",
- "Volo.AbpIo.Commercial:030001": "This organization name already exists.",
- "Volo.AbpIo.Commercial:030002": "Once activated, trial license cannot be set to requested!",
- "Volo.AbpIo.Commercial:030003": "There is no such status!",
- "Volo.AbpIo.Commercial:030004": "Status could not be changed due to an unexpected error!",
- "Volo.AbpIo.Commercial:030005": "Start and end date can be updated when the trial license is in the -activated- status!",
- "Volo.AbpIo.Commercial:030006": "End date must always be greater than start date!",
- "Volo.AbpIo.Commercial:030007": "This trial license has already been activated once!",
- "Volo.AbpIo.Commercial:030008": "Purchase date can be set only when status is Purchased!",
- "Volo.AbpIo.Commercial:030009": "User not found!",
- "Volo.AbpIo.Commercial:030010": "To purchase the trial license, first you need to activate your trial license!",
- "Volo.AbpIo.Commercial:030011": "You cannot delete a trial license when it is purchased!",
"Permission:SendWelcomeEmail": "Send Welcome Email",
"SendWelcomeEmail": "Send Welcome Email",
"SendWelcomeEmailWarningMessage": "Are you sure you want to send welcome email to the organization members?",
@@ -385,12 +373,26 @@
"Menu:Speakers": "Speakers",
"ChooseSpeakerImage": "Choose a speaker image...",
"SpeakerImage": "Speaker image",
+ "AddSpeaker": "Add Speaker",
"ShowPurchaseItemsOfOrganizations": "Purchase Items",
"Enum:OrganizationPurchaseState:0": "Not delivered",
"Enum:OrganizationPurchaseState:1": "Delivered",
"PurchaseItems": "Purchase Items",
"SuccessfullyUpdated": "Successfully updated",
"SuccessfullyAdded": "Successfully added",
- "PurchaseState": "Purchase State"
+ "PurchaseState": "Purchase State",
+ "ShowBetweenDayCount": "Show Between Days",
+ "PurchaseOrder": "Purchase Order",
+ "ShowCreateInvoiceOfOrganization": "Create Invoice",
+ "ShowCreateQuotationOfOrganization": "Create Quotation",
+ "BookDiscounts": "Book Discounts",
+ "Permission:BookDiscount": "Book Discount",
+ "Menu:BookDiscounts": "Book Discounts",
+ "BookType": "Book Type",
+ "PurchasePlatform": "Purchase Platform",
+ "StartTime": "Start Time",
+ "EndTime": "End Time",
+ "CreateABookDiscount": "Create a book discount",
+ "BookDiscountDeletionConfirmationMessage": "Are you sure you want to delete this book discount?"
}
}
\ No newline at end of file
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/en.json
index fe9085e427..e898619b64 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/en.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/en.json
@@ -14,6 +14,18 @@
"Volo.AbpIo.Domain:020002": "Could not delete this NPM Package because \"{Modules}\" Modules are using this package.",
"Volo.AbpIo.Domain:020003": "Could not delete this NPM Package because \"{Modules}\" Modules are using this package and \"{NugetPackages}\" Nuget Packages are dependent to this package.",
"Volo.AbpIo.Domain:020004": "Could not delete this Nuget Package because \"{Modules}\" Modules are using this package.",
+ "Volo.AbpIo.Domain:030000": "You have already completed your trial period.",
+ "Volo.AbpIo.Domain:030001": "This organization name already exists.",
+ "Volo.AbpIo.Domain:030002": "Once activated, you cannot switch the trial license to -requested- status!",
+ "Volo.AbpIo.Domain:030003": "There is no such status!",
+ "Volo.AbpIo.Domain:030004": "Status could not be changed due to an unexpected error!",
+ "Volo.AbpIo.Domain:030005": "Start and end date can be updated when the trial license is in the -activated- status!",
+ "Volo.AbpIo.Domain:030006": "The end date must be greater than the start date!",
+ "Volo.AbpIo.Domain:030007": "This trial license has already been activated!",
+ "Volo.AbpIo.Domain:030008": "The purchase date can be set only when the status is -purchased-!",
+ "Volo.AbpIo.Domain:030009": "User not found!",
+ "Volo.AbpIo.Domain:030010": "To purchase the trial license, you first need to activate your trial license!",
+ "Volo.AbpIo.Domain:030011": "You cannot delete a trial license when it is purchased!",
"WantToLearn?": "Want to learn?",
"ReadyToGetStarted?": "Ready to get started?",
"JoinOurCommunity": "Join our community",
@@ -72,7 +84,7 @@
"WouldLikeToReceiveMarketingMaterials": "I would like to receive marketing materials like product deals & special offers.",
"JoinOurMarketingNewsletter": "Join our marketing newsletter",
"CommunityPrivacyPolicyConfirmation": "I agree to the Terms & Conditions and Privacy Policy.",
- "ABPIO-Common": "ABPIO-Common",
+ "WouldLikeToReceiveNotification": "I would like to receive the latest news from abp.io websites.",
"CommercialNewsletterConfirmationMessage": "I agree to the Terms & Conditions and Privacy Policy.",
"FreeDDDEBook": "Free DDD E-Book",
"AdditionalServices": "Additional Services",
@@ -104,7 +116,15 @@
"WatchTheEvent": "Watch the Event",
"RegisterNow": "Register Now",
"ThereIsNoEvent": "There is no event.",
+ "Events": "Events",
"Volo.AbpIo.Domain:080000": "There is already a purchase item named \"{Name}\"",
- "MasteringAbpFrameworkBook": "Book: Mastering ABP Framework"
+ "MasteringAbpFrameworkBook": "Book: Mastering ABP Framework",
+ "ABPIO-CommonPreferenceDefinition": "Get the latest news about ABP Platform like new posts, events and more.",
+ "BuiltOn": "Built-on",
+ "AbpFramework": "ABP Framework",
+ "Volo.AbpIo.Domain:080001": "Start Time can not be greater than End Time",
+ "Enum:BookType:0": "Mastering ABP Framework",
+ "Enum:PurchasePlatform:0": "Amazon",
+ "Enum:PurchasePlatform:1": "Packt"
}
}
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json
index 8fa96b5ee2..a977671501 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json
@@ -49,7 +49,7 @@
"IndexPageHeroSection": "A complete web development platformbuilt-on framework",
"AbpCommercialShortDescription": "ABP Commercial provides pre-built application modules, rapid application development tooling, professional UI themes, premium support and more.",
"LiveDemo": "Live Demo",
- "GetLicence": "Get a Licence",
+ "GetLicence": "Get a License",
"Application": "Application",
"StartupTemplates": "Startup Templates",
"Startup": "Startup",
@@ -204,7 +204,7 @@
"TrialPlan": "Do you have a trial plan?",
"TrialPlanExplanation": "For now, ABP Commercial doesn't have a trial plan. For the Team licenses we provide 30 days money back guarantee. You can just request a refund in the first 30 days. For the Business and Enterprise licenses, we provide 60% refund in 30 days. This is because Business and Enterprise licenses include the full source code of all the modules and the themes.",
"DoYouAcceptBankWireTransfer": "Do you accept bank wire transfers?",
- "DoYouAcceptBankWireTransferExplanation": "Yes, we accept bank wire transfers. After sending the license fee via bank transfer, email us your receipt and the type of license requested at accounting@abp.io, here's our international bank account information:",
+ "DoYouAcceptBankWireTransferExplanation": "Yes, we accept bank wire transfers. After sending the license fee via bank transfer, send your receipt and requested license type to accounting@abp.io. Our international bank account information:",
"HowToUpgrade": "How to upgrade existing applications when a new version is available?",
"HowToUpgradeExplanation1": "When you create a new application using ABP Commercial, all the modules and theme are used as NuGet and NPM packages. So, you can easily upgrade the packages when a new version is available.",
"HowToUpgradeExplanation2": "In addition to the standard NuGet/NPM upgrades, ABP CLI provides an update command that automatically finds and upgrades all ABP related packages in your solution.",
@@ -271,7 +271,7 @@
"Enterprise": "Enterprise",
"Custom": "Custom",
"IncludedDeveloperLicenses": "Included developer licenses",
- "CustomLicenceOrAdditionalServices": "Need custom licence or additional services?",
+ "CustomLicenceOrAdditionalServices": "Need custom license or additional services?",
"CustomOrVolumeLicense": "Custom or volume license",
"LiveTrainingSupport": "Live training & support",
"AndMore": "and more",
@@ -495,7 +495,9 @@
"LicenseTypeNotCorrect": "The license type is not correct!",
"Trainings": "Trainings",
"ChoseTrainingPlaceholder": "Chose the training...",
- "ContactUsToGetQuote": "Contact us to get a quote",
+ "DoYouNeedTrainings": "Do you need one of these trainings?",
+ "DoYouNeedTraining": "Do you need {0} training?",
+ "GetInTouchUs": "Get in touch with us",
"ForMoreInformationClickHere": "For more information, click here.",
"IsGetOnboardingTraining": "Would you like to get onboarding & web application development training?",
"OnboardingWebApplicationDevelopmentTrainingMessage": "To schedule your training calendar, please contact {0} after creating the organization",
@@ -503,6 +505,7 @@
"AdditionalNote": "Additional Note",
"OnboardingTrainingFaqTitle": "Do you have ABP onboarding training?",
"OnboardingTrainingFaqExplanation": "Yes, we have ABP Training Services to help you get your ABP project started fast. You will learn about ABP from an ABP core team member and you will get the skills to begin your ABP project. In the onboarding training, we will explain how to set up your development environment, install the required tools, create a fully functional CRUD page. The training will be live and the Zoom application will be used, and we are open to using other online meeting platforms. The language of the training will be English. You can also ask your questions about ABP during the sessions. A convenient time and date will be planned for both parties. To get more information, contact us at info@abp.io.",
- "AddBasket": "Add to Basket"
+ "AddBasket": "Add to Basket",
+ "SendTrainingRequest": "Send Training Request"
}
}
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json
index 60215b5fec..35b755e8c3 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json
@@ -183,7 +183,7 @@
"InstallABPCLIInfo": "ABP CLI is the fastest way to start a new solution with the ABP framework. Install the ABP CLI using a command line window:",
"DifferentLevelOfNamespaces": "You can use different levels of namespaces; e.g. BookStore, Acme.BookStore or Acme.Retail.BookStore.",
"ABPCLIExamplesInfo": "The new command creates a layered MVC application with Entity Framework Core as the database provider. However, it has additional options.",
- "SeeCliDocumentForMoreInformation": "Check out the ABP CLI document for more options or select the \"Direct Download\" tab above.",
+ "SeeCliDocumentForMoreInformation": "Check out the ABP CLI document for more options or select the \"Direct Download\" tab above.",
"Optional": "Optional",
"LocalFrameworkRef": "Keep the local project reference for the framework packages.",
"BlobStoring": "BLOB Storing",
@@ -214,7 +214,11 @@
"SeeDocs": "See Docs",
"None": "None",
"Application": "Application",
+ "ApplicationExplanation": "Creates a fully layered solution based on Domain Driven Design practices. Recommended for long-term projects that need a maintainable and extensible codebase.",
+ "ApplicationNoLayer": "Application (single layer)",
+ "ApplicationNoLayerExplanation": "Creates a single-layer web application. Recommended for building an application with a simpler and easy to understand architecture.",
"Module": "Module",
+ "ModuleExplanation": "Creates a reusable, fully layered application module solution. You can use this option to create modules for your modular application.",
"PackageName": "Package Name",
"LicenseURL": "License URL",
"License": "License",
@@ -318,6 +322,7 @@
"InstallingTheABPCLI": "Installing the ABP CLI",
"CreateYourProjectNow": "Create Your Project Now",
"OrderOn": "Order on {0}",
- "DownloadFreeDDDBook": "Download Free DDD Book"
+ "DownloadFreeDDDBook": "Download Free DDD Book",
+ "WhatIsABPFramework": "What is the ABP Framework?"
}
}
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/tr.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/tr.json
index f9c6d54204..ad8393fab3 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/tr.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/tr.json
@@ -214,7 +214,11 @@
"SeeDocs": "Dökümanı Görüntüle",
"None": "Hiç",
"Application": "Uygulama",
+ "ApplicationExplanation": "Domain Driven Design pratikleri üzerine oluşturulmuş çok katmanlı bir çözüm oluşturur. Bakıma ve geliştirmeye açık kod tabanına ihtiyaç duyan uzun süreli projeler için önerilir.",
+ "ApplicationNoLayer": "Uygulama (tek katmanlı)",
+ "ApplicationNoLayerExplanation": "Tek katmanlı Web uygulaması oluşturur. Daha basit ve anlaması kolay mimari ile uygulama geliştirmek için önerilir.",
"Module": "Modül",
+ "ModuleExplanation": "Tamamen katmanlanmış, tekrar kullanılabilir bir uygulama modülü oluşturur. Uygulamanıza modül yaratmak için bu seçeneği kullanabilirsiniz.",
"PackageName": "Paket adı",
"LicenseURL": "Lisans Linki",
"License": "Lisans",
diff --git a/common.props b/common.props
index 176e761975..facc92f0bc 100644
--- a/common.props
+++ b/common.props
@@ -1,7 +1,7 @@
latest
- 5.2.1
+ 5.3.0$(NoWarn);CS1591;CS0436https://abp.io/assets/abp_nupkg.pnghttps://abp.io/
diff --git a/docs/en/Background-Workers-Hangfire.md b/docs/en/Background-Workers-Hangfire.md
index 7f832f2c71..4cbaf8cc24 100644
--- a/docs/en/Background-Workers-Hangfire.md
+++ b/docs/en/Background-Workers-Hangfire.md
@@ -126,4 +126,4 @@ context.ServiceProvider
So, it resolves the given background worker and adds to the `IBackgroundWorkerManager`.
-While we generally add workers in OnApplicationInitialization, there are no restrictions on that. You can inject IBackgroundWorkerManager anywhere and add workers at runtime. Background worker manager will stop and release all the registered workers when your application is being shut down.
\ No newline at end of file
+While we generally add workers in OnApplicationInitialization, there are no restrictions on that. You can inject IBackgroundWorkerManager anywhere and add workers at runtime. Background worker manager will stop and release all the registered workers when your application is being shut down.
diff --git a/docs/en/Blog-Posts/2022-04-05 v5_2_Release_Stable/POST.md b/docs/en/Blog-Posts/2022-04-05 v5_2_Release_Stable/POST.md
new file mode 100644
index 0000000000..ed83f36e19
--- /dev/null
+++ b/docs/en/Blog-Posts/2022-04-05 v5_2_Release_Stable/POST.md
@@ -0,0 +1,51 @@
+# ABP.IO Platform 5.2 Final Has Been Released!
+
+[ABP Framework](https://abp.io/) and [ABP Commercial](https://commercial.abp.io/) 5.2 versions have been released today.
+
+## What's New With 5.2?
+
+Since all the new features are already explained in details with the [5.2 RC Announcement Post](https://blog.abp.io/abp/ABP.IO-Platform-5-2-RC-Has-Been-Published), I will not repeat all the details again. See the [RC Blog Post](https://blog.abp.io/abp/ABP.IO-Platform-5-2-RC-Has-Been-Published) for all the features and enhancements.
+
+## Creating New Solutions
+
+You can create a new solution with the ABP Framework version 5.2 by either using the `abp new` command or using the **direct download** tab on the [get started page](https://abp.io/get-started).
+
+> See the [getting started document](https://docs.abp.io/en/abp/latest/Getting-Started) for more.
+
+## How to Upgrade an Existing Solution
+
+### Install/Update the ABP CLI
+
+First of all, install the ABP CLI or upgrade to the latest version.
+
+If you haven't installed yet:
+
+```bash
+dotnet tool install -g Volo.Abp.Cli
+```
+
+To update an existing installation:
+
+```bash
+dotnet tool update -g Volo.Abp.Cli
+```
+
+### ABP UPDATE Command
+
+[ABP CLI](https://docs.abp.io/en/abp/latest/CLI) provides a handy command to update all the ABP related NuGet and NPM packages in your solution with a single command:
+
+```bash
+abp update
+```
+
+Run this command in the root folder of your solution.
+
+## Migration Guide
+
+Check [the migration guide](https://docs.abp.io/en/abp/5.2/Migration-Guides/Abp-5_2) for the applications with the version 5.x upgrading to the version 5.2.
+
+## About the Next Version
+
+The next feature version will be 5.3. It is planned to release the 5.3 RC (Release Candidate) on May 03 and the final version on May 31, 2022. You can follow the [release planning here](https://github.com/abpframework/abp/milestones).
+
+Please [submit an issue](https://github.com/abpframework/abp/issues/new) if you have any problem with this version.
diff --git a/docs/en/CLI.md b/docs/en/CLI.md
index 491ebee401..8931220705 100644
--- a/docs/en/CLI.md
+++ b/docs/en/CLI.md
@@ -18,13 +18,13 @@ dotnet tool update -g Volo.Abp.Cli
## Global Options
-While each command may have a set of options, there are some global options those can be used with any command;
+While each command may have a set of options, there are some global options that can be used with any command;
* `--skip-cli-version-check`: Skips to check the latest version of the ABP CLI. If you don't specify, it will check the latest version and shows a warning message if there is a newer version of the ABP CLI.
## Commands
-Here, the list of all available commands before explaining their details:
+Here, is the list of all available commands before explaining their details:
* **`help`**: Shows help on the usage of the ABP CLI.
* **`new`**: Generates a new solution based on the ABP [startup templates](Startup-Templates/Index.md).
@@ -115,6 +115,7 @@ For more samples, go to [ABP CLI Create Solution Samples](CLI-New-Command-Sample
* `--database-provider` or `-d`: Specifies the database provider. Default provider is `ef`. Available providers:
* `ef`: Entity Framework Core.
* `mongodb`: MongoDB.
+ * `--pwa`: Specifies to Configure Angular or Blazor WebAssembly project as Progressive Web Application.
* `--output-folder` or `-o`: Specifies the output folder. Default value is the current directory.
* `--version` or `-v`: Specifies the ABP & template version. It can be a [release tag](https://github.com/abpframework/abp/releases) or a [branch name](https://github.com/abpframework/abp/branches). Uses the latest release if not specified. Most of the times, you will want to use the latest version.
* `--preview`: Use latest preview version.
diff --git a/docs/en/Caching.md b/docs/en/Caching.md
index 064323a9c3..1ea95cec87 100644
--- a/docs/en/Caching.md
+++ b/docs/en/Caching.md
@@ -258,7 +258,7 @@ ABP's distributed cache interfaces provide methods to perform batch methods thos
Distributed cache service provides an interesting feature. Assume that you've updated the price of a book in the database, then set the new price to the cache, so you can use the cached value later. What if you have an exception after setting the cache and you **rollback the transaction** that updates the price of the book? In this case, cache value will be incorrect.
-`IDistributedCache<..>` methods gets an optional parameter, named `considerOuw`, which is `false` by default. If you set it to `true`, then the changes you made for the cache are not actually applied to the real cache store, but associated with the current [unit of work](Unit-Of-Work.md). You get the value you set in the same unit of work, but the changes are applied **only if the current unit of work succeed**.
+`IDistributedCache<..>` methods gets an optional parameter, named `considerUow`, which is `false` by default. If you set it to `true`, then the changes you made for the cache are not actually applied to the real cache store, but associated with the current [unit of work](Unit-Of-Work.md). You get the value you set in the same unit of work, but the changes are applied **only if the current unit of work succeed**.
### IDistributedCacheSerializer
diff --git a/docs/en/Community-Articles/2022-04-06-Concurrency-Check-in-ABP-Based-Applications/POST.md b/docs/en/Community-Articles/2022-04-06-Concurrency-Check-in-ABP-Based-Applications/POST.md
new file mode 100644
index 0000000000..b16d6bd9f1
--- /dev/null
+++ b/docs/en/Community-Articles/2022-04-06-Concurrency-Check-in-ABP-Based-Applications/POST.md
@@ -0,0 +1,548 @@
+# Handle Concurrency with EF Core in an ABP Framework Project with ASP.NET Core MVC
+
+In this article, we'll create a basic application to demonstrate how "Concurrency Check/Control" can be implemented in an ABP project.
+
+## Creating the Solution
+
+For this article, we will create a simple BookStore application and add CRUD functionality to the pages. Hence we deal with the concurrency situation.
+
+We can create a new startup template with EF Core as a database provider and MVC for the UI Framework.
+
+> If you already have a project, you don't need to create a new startup template, you can directly implement the following steps to your project. So you can skip this section.
+
+We can create a new startup template by using the [ABP CLI](https://docs.abp.io/en/abp/latest/CLI).
+
+```bash
+abp new Acme.BookStore
+```
+
+After running the above command, our project boilerplate will be downloaded. Then we can open the solution and start the development.
+
+## Starting the Development
+
+Let's start with defining our entities.
+
+### Creating Entities
+
+Create a `Book.cs` (/Books/Book.cs) class in the `.Domain` layer:
+
+```csharp
+public class Book : AuditedAggregateRoot
+{
+ public string Name { get; set; }
+
+ public BookType Type { get; set; }
+
+ public DateTime PublishDate { get; set; }
+
+ public float Price { get; set; }
+}
+```
+
+* To enable **Concurrency Check** for our entities, our entities should be implemented the `IHasConcurrencyStamp` interface, directly or indirectly.
+
+* [Aggregate Root](https://docs.abp.io/en/abp/5.2/Entities#aggregateroot-class) entity classes already implement the `IHasConcurrencyStamp` interface, so if we inherit our entities from one of these entity classes then we won't need to manually implement the `IHasConcurrencyStamp` interface.
+
+* And we've derived the `Book` entity from `AuditedAggregateRoot` here, so we don't need to implement the `IHasConcurrencyStamp` interface because `AuditedAggregateRoot` class already implemented the `IHasConcurrencyStamp` interface.
+
+> You can read more details from the [Concurrency Check](https://docs.abp.io/en/abp/5.2/Concurrency-Check) documentation.
+
+Then, create a `BookType` (/Books/BookType.cs) enum in the `.Domain.Shared` layer:
+
+```csharp
+public enum BookType
+{
+ Undefined,
+ Adventure,
+ Biography,
+ Dystopia,
+ Fantastic,
+ Horror,
+ Science,
+ ScienceFiction,
+ Poetry
+}
+```
+
+### Database Integration
+
+Open the `BookStoreDbContext` (/EntityFrameworkCore/BookStoreDbContext.cs) class in the `*.EntityFrameworkCore` project and add the following `DbSet` statement:
+
+```csharp
+namespace Acme.BookStore.EntityFrameworkCore;
+
+[ReplaceDbContext(typeof(IIdentityDbContext))]
+[ReplaceDbContext(typeof(ITenantManagementDbContext))]
+[ConnectionStringName("Default")]
+public class BookStoreDbContext :
+ AbpDbContext,
+ IIdentityDbContext,
+ ITenantManagementDbContext
+{
+ //Entities from the modules
+
+ public DbSet Books { get; set; } //add this line
+}
+```
+
+Then we can navigate to the `OnModelCreating` method in the same class and configure our tables/entities:
+
+```csharp
+protected override void OnModelCreating(ModelBuilder builder)
+{
+ base.OnModelCreating(builder);
+
+ /* Include modules to your migration db context */
+
+ builder.ConfigurePermissionManagement();
+ ...
+
+ //* Configure your own tables/entities inside here */
+
+ builder.Entity(b =>
+ {
+ b.ToTable(BookStoreConsts.DbTablePrefix + "Books",
+ BookStoreConsts.DbSchema);
+ b.ConfigureByConvention(); //auto configure for the base class props
+ b.Property(x => x.Name).IsRequired().HasMaxLength(128);
+ });
+}
+```
+
+After the mapping configurations, we can create a new migration and apply changes to the database.
+
+To do this, open your command line terminal in the directory of the `EntityFrameworkCore` project and run the below command:
+
+```bash
+dotnet ef migrations add Added_Books
+```
+
+After this command, a new migration will be generated and then we can run the `*.DbMigrator` project to apply the last changes to the database such as creating a new table named `Books` according to the last created migration.
+
+### Defining DTOs and Application Service Interfaces
+
+We can start to define the use cases of the application.
+
+Create the DTO classes (under the **Books** folder) in the `Application.Contracts` project:
+
+**BookDto.cs**
+
+```csharp
+public class BookDto : AuditedEntityDto, IHasConcurrencyStamp
+{
+ public string Name { get; set; }
+
+ public BookType Type { get; set; }
+
+ public DateTime PublishDate { get; set; }
+
+ public float Price { get; set; }
+
+ public string ConcurrencyStamp { get; set; }
+}
+```
+
+* The `AuditedEntityDto` class is not implemented from the `IHasConcurrencyStamp` interface, so for the **BookDto** class we need to implement the `IHasConcurrencyStamp`.
+
+* This is important, because we need to return books with their **ConcurrencyStamp** value.
+
+**CreateBookDto.cs**
+
+```csharp
+public class CreateBookDto
+{
+ [Required]
+ [StringLength(128)]
+ public string Name { get; set; }
+
+ [Required]
+ public BookType Type { get; set; } = BookType.Undefined;
+
+ [Required]
+ [DataType(DataType.Date)]
+ public DateTime PublishDate { get; set; } = DateTime.Now;
+
+ [Required]
+ public float Price { get; set; }
+}
+```
+
+**UpdateBookDto.cs**
+
+```csharp
+public class UpdateBookDto : IHasConcurrencyStamp
+{
+ [Required]
+ [StringLength(128)]
+ public string Name { get; set; }
+
+ [Required]
+ public BookType Type { get; set; } = BookType.Undefined;
+
+ [Required]
+ [DataType(DataType.Date)]
+ public DateTime PublishDate { get; set; } = DateTime.Now;
+
+ [Required]
+ public float Price { get; set; }
+
+ public string ConcurrencyStamp { get; set; }
+}
+```
+
+* Here, we've implemented the `IHasConcurrencyStamp` interface for the **UpdateBookDto** class.
+
+* We will use this value while updating an existing book. ABP Framework will compare the current book's **ConcurrencyStamp** value with the provided one, if values are matched, this means everything is as it is supposed to be and will update the record.
+
+* If values are mismatched, then it means the record that we're trying to update is already updated by another user and we need to get the latest changes to be able to make changes on it.
+
+* Also, in that case, `AbpDbConcurrencyException` will be thrown by the ABP Framework and we can either handle this exception manually or let the ABP Framework handle it on behalf of us and show a user-friendly error message as in the image below.
+
+
+
+Create a new `IBookAppService` (/Books/IBookAppService.cs) interface in the `Application.Contracts` project:
+
+```csharp
+public interface IBookAppService :
+ ICrudAppService
+{
+}
+```
+* We've implemented the `ICrudAppService` here, because we just need to perform CRUD operations and this interface helps us define common CRUD operation methods.
+
+### Application Service Implementations
+
+Create a `BookAppService` (/Books/BookAppService.cs) class inside the `*.Application` project and implement the application service methods, as shown below:
+
+```csharp
+public class BookAppService :
+ CrudAppService,
+ IBookAppService
+{
+ public BookAppService(IRepository repository)
+ : base(repository)
+ {
+ }
+
+ public override async Task UpdateAsync(Guid id, UpdateBookDto input)
+ {
+ var book = await Repository.GetAsync(id);
+
+ book.Name = input.Name;
+ book.Price = input.Price;
+ book.Type = input.Type;
+ book.PublishDate = input.PublishDate;
+
+ //set Concurrency Stamp value to the entity
+ book.ConcurrencyStamp = input.ConcurrencyStamp;
+
+ var updatedBook = await Repository.UpdateAsync(book);
+ return ObjectMapper.Map(updatedBook);
+ }
+}
+```
+
+* We've used the `CrudAppService` base class. This class implements all common CRUD operations and if we want to change a method, we can simply override the method and change it to our needs.
+
+> Normally, you don't need to override the `UpdateAsync` method to do **Concurrency Check**. Because the `UpdateAsync` method of the `CrudAppService` class by default map input values to the entity. But I wanted to override this method to show what we need to do for **Concurrency Check**.
+
+* We can look closer to the `UpdateAsync` method here, because as we've mentioned earlier we need to pass the provided **ConcurrencyStamp** value to be able to do **Concurrency Check/Control** to our entity while updating.
+
+* At that point, if the given record is already updated by any other user, a **ConcurrencyStamp** mismatch will occur and `AbpDbConcurrencyException` will be thrown thanks to the **Concurrency Check** system of ABP, data-consistency will be provided and the current record won't be overridden.
+
+* And if the values are matched, the record will be updated successfully.
+
+After implementing the application service methods, we can do the related mapping configurations, so open the `BookStoreApplicationAutoMapperProfile.cs` and update the content as below:
+
+```csharp
+public class BookStoreApplicationAutoMapperProfile : Profile
+{
+ public BookStoreApplicationAutoMapperProfile()
+ {
+ CreateMap();
+ CreateMap();
+ }
+}
+```
+
+### User Interface
+
+So far, we've applied the all necessary steps for the **Concurrency Check** system, let's see it in action.
+
+Create a razor page in the `.Web` layer named `Index` (**/Pages/Books/Index.cshtml**), open this file and replace the content with the following code block:
+
+```html
+@page
+@using Acme.BookStore.Localization
+@using Microsoft.Extensions.Localization
+@model Acme.BookStore.Web.Pages.Books.Index
+
+@section scripts
+{
+
+}
+
+
+
+
+
+ Books
+
+
+
+
+
+
+
+
+
+
+```
+
+* We've defined a table and "New Book" button inside a card element here, we'll fill the table with our book records in the next step by using the **Datatables** library.
+
+Create an `Index.js` (**/Pages/Books/Index.js**) file and add the following code block:
+
+```js
+$(function () {
+ var l = abp.localization.getResource('BookStore');
+ var createModal = new abp.ModalManager(abp.appPath + 'Books/CreateModal');
+ var editModal = new abp.ModalManager(abp.appPath + 'Books/EditModal');
+
+ var dataTable = $('#BooksTable').DataTable(
+ abp.libs.datatables.normalizeConfiguration({
+ serverSide: true,
+ paging: true,
+ order: [[1, "asc"]],
+ searching: false,
+ scrollX: true,
+ ajax: abp.libs.datatables.createAjax(acme.bookStore.books.book.getList),
+ columnDefs: [
+ {
+ title: l('Actions'),
+ rowAction: {
+ items:
+ [
+ {
+ text: l('Edit'),
+ action: function (data) {
+ editModal.open({ id: data.record.id });
+ }
+ }
+ ]
+ }
+ },
+ {
+ title: l('Name'),
+ data: "name"
+ },
+ {
+ title: l('Type'),
+ data: "type",
+ render: function (data) {
+ return l('Enum:BookType:' + data);
+ }
+ },
+ {
+ title: l('PublishDate'),
+ data: "publishDate",
+ render: function (data) {
+ return luxon
+ .DateTime
+ .fromISO(data, {
+ locale: abp.localization.currentCulture.name
+ }).toLocaleString();
+ }
+ },
+ {
+ title: l('Price'),
+ data: "price"
+ },
+ {
+ title: l('CreationTime'),
+ data: "creationTime",
+ render: function (data) {
+ return luxon
+ .DateTime
+ .fromISO(data, {
+ locale: abp.localization.currentCulture.name
+ }).toLocaleString(luxon.DateTime.DATETIME_SHORT);
+ }
+ }
+ ]
+ })
+ );
+
+ createModal.onResult(function () {
+ dataTable.ajax.reload();
+ });
+
+ editModal.onResult(function () {
+ dataTable.ajax.reload();
+ });
+
+ $('#NewBookButton').click(function (e) {
+ e.preventDefault();
+ createModal.open();
+ });
+});
+```
+
+* We've used the [Datatables](https://datatables.net/) to list our books.
+
+* Also defined **create** and **update** modals by using [ABP Modal Manager](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Modals#modalmanager-reference), but we didn't create them yet, so let's create the modals.
+
+First, create a **CreateModal** razor page and update the **CreateModal.cshtml** and **CreateModal.cshtml.cs** files as below:
+
+**CreateModal.cshtml**
+
+```html
+@page
+@using Acme.BookStore.Web.Pages.Books
+@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
+@model CreateModalModel
+@{
+ Layout = null;
+}
+
+
+
+
+
+
+
+
+
+```
+
+* We've used `abp-dynamic-form` tag-helper and passed it a `Book` model, this tag helper will simply create form contents (inputs, select boxes etc.) on behalf of us.
+
+* **CreateModal.cshtml.cs**
+
+```csharp
+using System.Threading.Tasks;
+using Acme.BookStore.Books;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Acme.BookStore.Web.Pages.Books;
+
+public class CreateModalModel : BookStorePageModel
+{
+ [BindProperty]
+ public CreateBookDto Book { get; set; }
+
+ private readonly IBookAppService _bookAppService;
+
+ public CreateModalModel(IBookAppService bookAppService)
+ {
+ _bookAppService = bookAppService;
+ }
+
+ public void OnGet()
+ {
+ Book = new CreateBookDto();
+ }
+
+ public async Task OnPostAsync()
+ {
+ await _bookAppService.CreateAsync(Book);
+ return NoContent();
+ }
+}
+```
+
+* In this file, we simply define **CreateBookDto** as a bind property and we'll use this class's properties in the form. Thanks to the `abp-dynamic-form` tag-helper we don't need to define all of these form elements one by one, it will generate on behalf of us.
+
+We can create an **EditModal** razor page and update the **EditModal.cshtml** and **EditModal.cshtml.cs** files as below:
+
+**EditModal.cshtml**
+
+```html
+@page
+@using Acme.BookStore.Web.Pages.Books
+@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
+@model EditModalModel
+@{
+ Layout = null;
+}
+
+```
+
+* Here, we didn't use the `abp-dynamic-form` tag-helper and added all the necessary form elements to our form one by one.
+
+* As you may have noticed, we've set the input type as **hidden** for the **ConcurrencyStamp** input, because the end-user should not see this value.
+
+> Instead of doing it like that, we could create a view model class and use the `[HiddenInput]` data attribute for the **ConcurrencyStamp** property and use the `abp-dynamic-form` tag-helper. But to simplify the article I didn't want to do that, if you want you can create a view model and define the necessary data attributes for properties.
+
+**EditModal.cshtml.cs**
+
+```csharp
+public class EditModalModel : BookStorePageModel
+{
+ [HiddenInput]
+ [BindProperty(SupportsGet = true)]
+ public Guid Id { get; set; }
+
+ [BindProperty]
+ public UpdateBookDto Book { get; set; }
+
+ private readonly IBookAppService _bookAppService;
+
+ public EditModalModel(IBookAppService bookAppService)
+ {
+ _bookAppService = bookAppService;
+ }
+
+ public async Task OnGetAsync()
+ {
+ var bookDto = await _bookAppService.GetAsync(Id);
+ Book = ObjectMapper.Map(bookDto);
+ }
+
+ public async Task OnPostAsync()
+ {
+ await _bookAppService.UpdateAsync(Id, Book);
+ return NoContent();
+ }
+}
+```
+
+Lastly, we can define the necessary mapping configurations and run the application to see the result.
+
+Open the `BookStoreWebAutoMapperProfile.cs` class and update the content as below:
+
+```csharp
+public class BookStoreWebAutoMapperProfile : Profile
+{
+ public BookStoreWebAutoMapperProfile()
+ {
+ CreateMap();
+ }
+}
+```
+
+Then we can run the application, navigate to the **/Books** endpoint and see the result.
+
+
+
+* In the image above, we can see that multiple users open the edit model to change a record and try to update the relevant record independently of each other.
+
+* After the first user updated the record, the second user tries to update the same record without getting the last state of the record. And therefore `AbpDbConcurrencyException` is thrown because **ConcurrencyStamp** values are different from each other.
+
+* The second user should close and re-open the model to get the last state of the record and then they can make changes to the current record.
diff --git a/docs/en/Community-Articles/2022-04-06-Concurrency-Check-in-ABP-Based-Applications/concurrency-mismatch.gif b/docs/en/Community-Articles/2022-04-06-Concurrency-Check-in-ABP-Based-Applications/concurrency-mismatch.gif
new file mode 100644
index 0000000000..922bb5b7ca
Binary files /dev/null and b/docs/en/Community-Articles/2022-04-06-Concurrency-Check-in-ABP-Based-Applications/concurrency-mismatch.gif differ
diff --git a/docs/en/Community-Articles/2022-04-06-Concurrency-Check-in-ABP-Based-Applications/optimistic-concurrency.png b/docs/en/Community-Articles/2022-04-06-Concurrency-Check-in-ABP-Based-Applications/optimistic-concurrency.png
new file mode 100644
index 0000000000..85253594c8
Binary files /dev/null and b/docs/en/Community-Articles/2022-04-06-Concurrency-Check-in-ABP-Based-Applications/optimistic-concurrency.png differ
diff --git a/docs/en/Community-Articles/2022-04-14-Dependency-Injection/POST.md b/docs/en/Community-Articles/2022-04-14-Dependency-Injection/POST.md
index edd74c1591..092fb72dbc 100644
--- a/docs/en/Community-Articles/2022-04-14-Dependency-Injection/POST.md
+++ b/docs/en/Community-Articles/2022-04-14-Dependency-Injection/POST.md
@@ -18,15 +18,15 @@ public class ElasticsearchExternalLogger : IExternalLogger
{
public async Task LogAsync(string logText)
{
- //TODO...
+ // TODO...
}
}
public class AzureExternalLogger : IExternalLogger
{
- public Task LogAsync(string logText)
+ public async Task LogAsync(string logText)
{
- throw new System.NotImplementedException();
+ // TODO...
}
}
````
diff --git a/docs/en/Modules/Cms-Kit/Blogging.md b/docs/en/Modules/Cms-Kit/Blogging.md
index 43ab85e129..12039b1669 100644
--- a/docs/en/Modules/Cms-Kit/Blogging.md
+++ b/docs/en/Modules/Cms-Kit/Blogging.md
@@ -33,7 +33,12 @@ Blog feature uses some of the other CMS Kit features. You can enable or disable
You can select/deselect the desired features for blog posts.
-
+
+
+##### Quick Navigation Bar In Blog Post
+If you enable "Quick navigation bar in blog posts", it will enabled scroll index as seen below.
+
+
### Blog Post Management
diff --git a/docs/en/Themes/LeptonXLite/angular.md b/docs/en/Themes/LeptonXLite/angular.md
new file mode 100644
index 0000000000..6e4cbef317
--- /dev/null
+++ b/docs/en/Themes/LeptonXLite/angular.md
@@ -0,0 +1,82 @@
+# LeptonX Lite Angular UI
+LeptonX Lite has implementation for the ABP Framework Angular Client. It's a simplified variation of the [LeptonX Theme](https://x.leptontheme.com/).
+
+> If you are looking for a professional, enterprise ready theme, you can check the [LeptonX Theme](https://x.leptontheme.com/), which is a part of [ABP Commercial](https://commercial.abp.io/).
+
+> See the [Theming document](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Theming) to learn about themes.
+
+## Installation
+
+To add `LeptonX-lite` into your project,
+
+* Install `@abp/ng.theme.lepton-x`
+
+`yarn add @abp/ng.theme.lepton-x@preview`
+
+* Install `bootstrap-icons`
+
+`yarn add bootstrap-icons`
+
+
+* Then, we need to edit the styles array in `angular.json` to replace the existing style with the new one.
+
+Add the following style
+
+```json
+"node_modules/bootstrap-icons/font/bootstrap-icons.css",
+```
+
+* Finally, remove `ThemeBasicModule` from `app.module.ts`, and import the related modules in `app.module.ts`
+
+```js
+import { ThemeLeptonXModule } from '@abp/ng.theme.lepton-x';
+import { SideMenuLayoutModule } from '@abp/ng.theme.lepton-x/layouts';
+
+@NgModule({
+ imports: [
+ // ...
+
+ // do not forget to remove ThemeBasicModule
+ // ThemeBasicModule.forRoot(),
+ ThemeLeptonXModule.forRoot(),
+ SideMenuLayoutModule.forRoot(),
+ ],
+ // ...
+})
+export class AppModule {}
+```
+
+Note: If you employ [Resource Owner Password Flow](https://docs.abp.io/en/abp/latest/UI/Angular/Authorization#resource-owner-password-flow) for authorization, you should import the following module as well:
+
+```js
+import { AccountLayoutModule } from '@abp/ng.theme.lepton-x/account';
+
+@NgModule({
+ // ...
+ imports: [
+ // ...
+ AccountLayoutModule.forRoot(),
+ // ...
+ ],
+ // ...
+})
+export class AppModule {}
+```
+
+To change the logos and brand color of `LeptonX`, simply add the following CSS to the `styles.scss`
+
+```css
+:root {
+ --lpx-logo: url('/assets/images/logo.png');
+ --lpx-logo-icon: url('/assets/images/logo-icon.png');
+ --lpx-brand: #edae53;
+}
+```
+
+- `--lpx-logo` is used to place the logo in the menu.
+- `--lpx-logo-icon` is a square icon used when the menu is collapsed.
+- `--lpx-brand` is a color used throughout the application, especially on active elements.
+
+### Server Side
+
+In order to migrate to LeptonX on your server side projects (Host and/or IdentityServer projects), please follow the [Server Side Migration](mvc.md) document.
diff --git a/docs/en/Themes/LeptonXLite/blazor.md b/docs/en/Themes/LeptonXLite/blazor.md
new file mode 100644
index 0000000000..ddea346585
--- /dev/null
+++ b/docs/en/Themes/LeptonXLite/blazor.md
@@ -0,0 +1,130 @@
+# LeptonX Lite Blazor UI
+
+````json
+//[doc-params]
+{
+ "UI": ["Blazor", "BlazorServer"]
+}
+````
+
+LeptonX Lite has implementation for the ABP Framework Blazor WebAssembly & Blazor Server. It's a simplified variation of the [LeptonX Theme](https://x.leptontheme.com/).
+
+> If you are looking for a professional, enterprise ready theme, you can check the [LeptonX Theme](https://x.leptontheme.com/), which is a part of [ABP Commercial](https://commercial.abp.io/).
+
+> See the [Theming document](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Theming) to learn about themes.
+
+## Installation
+
+{{if UI == "Blazor"}}
+- Complete the [MVC Razor Pages Installation](mvc.md#installation) for the **HttpApi.Host** application first. _If the solution is tiered/micro-service, complete the MVC steps for all MVC applications such as **HttpApi.Host** and if identity server is separated, install to the **IdentityServer**_.
+
+- Add **Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXLiteTheme** package to your **Blazor WebAssembly** application.
+ ```bash
+ dotnet add package Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXLiteTheme
+ ```
+
+- Remove the old theme from the **DependsOn** attribute in your module class and add the **AbpAspNetCoreComponentsWebAssemblyLeptonXLiteThemeModule** type to the **DependsOn** attribute.
+
+```diff
+[DependsOn(
+- typeof(AbpAspNetCoreComponentsWebAssemblyBasicThemeModule),
++ typeof(AbpAspNetCoreComponentsWebAssemblyLeptonXLiteThemeModule)
+)]
+```
+
+- Change startup App component with the LeptonX one.
+
+```csharp
+// Make sure the 'App' comes from 'Volo.Abp.AspNetCore.Components.Web.LeptonXLiteTheme.Themes.LeptonXLite' namespace.
+builder.RootComponents.Add("#ApplicationContainer");
+```
+
+- Run the `abp bundle` command in your **Blazor** application folder.
+
+{{end}}
+
+
+{{if UI == "BlazorServer"}}
+
+- Complete the [MVC Razor Pages Installation](mvc.md#installation) first. _If the solution is tiered/micro-service, complete the MVC steps for all MVC applications such as **HttpApi.Host** and **IdentityServer**_.
+
+- Add **Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme** package to your **Blazor server** application.
+ ```bash
+ dotnet add package Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme
+ ```
+
+- Remove old theme from the **DependsOn** attribute in your module class and add the **AbpAspNetCoreComponentsWebAssemblyLeptonXLiteThemeModule** type to the **DependsOn** attribute.
+
+ ```diff
+ [DependsOn(
+ - typeof(AbpAspNetCoreComponentsServerBasicThemeModule),
+ + typeof(AbpAspNetCoreComponentsServerLeptonXLiteThemeModule)
+ )]
+ ```
+
+- Update AbpBundlingOptions
+ ```diff
+ options.StyleBundles.Configure(
+ - BlazorBasicThemeBundles.Styles.Global,
+ + BlazorLeptonXLiteThemeBundles.Styles.Global,
+ bundle =>
+ {
+ bundle.AddFiles("/blazor-global-styles.css");
+ //You can remove the following line if you don't use Blazor CSS isolation for components
+ bundle.AddFiles("/MyProjectName.Blazor.styles.css");
+ });
+ ```
+
+- Update `_Host.cshtml` file. _(located under **Pages** folder by default.)_
+
+ - Add following usings to Locate **App** and **BlazorLeptonXLiteThemeBundles** classes.
+ ```csharp
+ @using Volo.Abp.AspNetCore.Components.Web.LeptonXLiteTheme.Themes.LeptonXLite
+ @using Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Bundling
+ ```
+ - Then replace script & style bundles as following:
+ ```diff
+ -
+ +
+ ```
+
+ ```diff
+ -
+ +
+ ```
+
+{{end}}
+
+
+---
+
+## Customization
+
+### Toolbars
+LeptonX Lite includes separeted toolbars for desktop & mobile. You can manage toolbars independently. Toolbar names can be accessible in the **LeptonXLiteToolbars** class.
+
+- `LeptonXLiteToolbars.Main`
+- `LeptonXLiteToolbars.MainMobile`
+
+```csharp
+public async Task ConfigureToolbarAsync(IToolbarConfigurationContext context)
+{
+ if (context.Toolbar.Name == LeptonXLiteToolbars.Main)
+ {
+ context.Toolbar.Items.Add(new ToolbarItem(typeof(MyDesktopComponent)));
+ }
+
+ if (context.Toolbar.Name == LeptonXLiteToolbars.MainMobile)
+ {
+ context.Toolbar.Items.Add(new ToolbarItem(typeof(MyMobileComponent)));
+ }
+
+ return Task.CompletedTask;
+}
+```
+
+{{if UI == "BlazorServer"}}
+
+> _You can visit the [Toolbars Documentation](https://docs.abp.io/en/abp/latest/UI/Blazor/Toolbars) for better understanding._
+
+{{end}}
diff --git a/docs/en/Themes/LeptonXLite/mvc.md b/docs/en/Themes/LeptonXLite/mvc.md
new file mode 100644
index 0000000000..b5575cba49
--- /dev/null
+++ b/docs/en/Themes/LeptonXLite/mvc.md
@@ -0,0 +1,67 @@
+# LeptonX Lite MVC UI
+LeptonX Lite has implementation for the ABP Framework Razor Pages. It's a simplified variation of the [LeptonX Theme](https://x.leptontheme.com/).
+
+> If you are looking for a professional, enterprise ready theme, you can check the [LeptonX Theme](https://x.leptontheme.com/), which is a part of [ABP Commercial](https://commercial.abp.io/).
+
+> See the [Theming document](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Theming) to learn about themes.
+
+## Installation
+
+- Add **Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite** package to your **Web** application.
+
+```bash
+abp add-package Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite
+```
+
+- Make sure the old theme is removed and LeptonX is added in your Module class.
+
+```diff
+[DependsOn(
+- typeof(AbpAspNetCoreMvcUiBasicThemeModule),
++ typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule)
+)]
+```
+
+- Update AbpBundlingOptions
+
+```diff
+Configure(options =>
+{
+ options.StyleBundles.Configure(
+- BasicThemeBundles.Styles.Global,
++ LeptonXLiteThemeBundles.Styles.Global
+ bundle =>
+ {
+ bundle.AddFiles("/global-styles.css");
+ }
+ );
+});
+```
+
+---
+
+## Customization
+
+### Toolbars
+LeptonX Lite includes separeted toolbars for desktop & mobile. You can manage toolbars independently. Toolbar names can be accessible in the **LeptonXLiteToolbars** class.
+
+- `LeptonXLiteToolbars.Main`
+- `LeptonXLiteToolbars.MainMobile`
+
+```csharp
+public class MyProjectNameMainToolbarContributor : IToolbarContributor
+{
+ public async Task ConfigureToolbarAsync(IToolbarConfigurationContext context)
+ {
+ if (context.Toolbar.Name == LeptonXLiteToolbars.Main)
+ {
+ context.Toolbar.Items.Add(new ToolbarItem(typeof(MyDesktopComponent)));
+ }
+
+ if (context.Toolbar.Name == LeptonXLiteToolbars.MainMobile)
+ {
+ context.Toolbar.Items.Add(new ToolbarItem(typeof(MyMobileComponent)));
+ }
+ }
+}
+```
diff --git a/docs/en/UI/Angular/Page-Toolbar-Extensions.md b/docs/en/UI/Angular/Page-Toolbar-Extensions.md
index 7e63950224..1edc9594fb 100644
--- a/docs/en/UI/Angular/Page-Toolbar-Extensions.md
+++ b/docs/en/UI/Angular/Page-Toolbar-Extensions.md
@@ -21,9 +21,9 @@ The following code prepares a constant named `identityToolbarActionContributors`
import {
eIdentityComponents,
- IdentityToolbarActionContributors,
- IdentityUserDto,
+ IdentityToolbarActionContributors
} from '@abp/ng.identity';
+import { IdentityUserDto } from '@abp/ng.identity/proxy';
import { ToolbarAction, ToolbarActionList } from '@abp/ng.theme.shared/extensions';
const logUserNames = new ToolbarAction({
@@ -93,7 +93,7 @@ We need to have a component before we can pass it to the toolbar action contribu
```js
// src/app/click-me-button.component.ts
-import { IdentityUserDto } from '@abp/ng.identity';
+import { IdentityUserDto } from '@abp/ng.identity/proxy';
import { ActionData, EXTENSIONS_ACTION_DATA } from '@abp/ng.theme.shared/extensions';
import { Component, Inject } from '@angular/core';
@@ -127,9 +127,9 @@ The following code prepares a constant named `identityToolbarActionContributors`
import {
eIdentityComponents,
- IdentityToolbarActionContributors,
- IdentityUserDto,
+ IdentityToolbarActionContributors
} from '@abp/ng.identity';
+import { IdentityUserDto } from '@abp/ng.identity/proxy';
import { ToolbarActionList, ToolbarComponent } from '@abp/ng.theme.shared/extensions';
import { ClickMeButtonComponent } from './click-me-button.component';
@@ -362,7 +362,7 @@ export function reorderUserContributors(
) {
// drop "New User" button
const newUserActionNode = actionList.dropByValue(
- 'AbpIdentity::NewUser',
+ 'AbpIdentity::NewUser',
(action, text) => action['text'] === text,
);
diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json
index b81f0b6efd..d021824d7f 100644
--- a/docs/en/docs-nav.json
+++ b/docs/en/docs-nav.json
@@ -704,6 +704,10 @@
{
"text": "The Basic Theme",
"path": "UI/AspNetCore/Basic-Theme.md"
+ },
+ {
+ "text": "LeptonX Lite",
+ "path": "Themes/LeptonXLite/mvc.md"
}
]
},
@@ -817,6 +821,10 @@
"text": "The Basic Theme",
"path": "UI/Blazor/Basic-Theme.md"
},
+ {
+ "text": "The Basic Theme",
+ "path": "Themes/LeptonXLite/blazor.md"
+ },
{
"text": "Branding",
"path": "UI/Blazor/Branding.md"
@@ -1071,6 +1079,10 @@
{
"text": "The Basic Theme",
"path": "UI/Angular/Basic-Theme.md"
+ },
+ {
+ "text": "LeptonX Lite",
+ "path": "Themes/LeptonXLite/angular.md"
}
]
},
diff --git a/docs/en/images/cmskit-module-features-dialog-2.png b/docs/en/images/cmskit-module-features-dialog-2.png
new file mode 100644
index 0000000000..b6dd409e0a
Binary files /dev/null and b/docs/en/images/cmskit-module-features-dialog-2.png differ
diff --git a/docs/en/images/cmskit-module-features-scroll-index.png b/docs/en/images/cmskit-module-features-scroll-index.png
new file mode 100644
index 0000000000..0bc3dedcc5
Binary files /dev/null and b/docs/en/images/cmskit-module-features-scroll-index.png differ
diff --git a/docs/zh-Hans/Caching.md b/docs/zh-Hans/Caching.md
index 7e7a314dab..d8f064a24e 100644
--- a/docs/zh-Hans/Caching.md
+++ b/docs/zh-Hans/Caching.md
@@ -1,164 +1,180 @@
# 缓存
-ABP框架扩展了ASP.NET Core的分布式缓存系统.
+ABP框架扩展了 [ASP.NET Core的分布式缓存系统](https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed).
-## Volo.Abp.Caching Package
+## 安装
-> 默认情况下启动模板已经安装了这个包,所以大部分情况下你不需要手动安装.
+> 默认情况下 [启动模板](Startup-Templates/Application.md) 已经安装了这个包. 所以大部分情况下你不需要手动安装.
-Volo.Abp.Caching是缓存系统的核心包.使用包管理控制台(PMC)安装到项目:
+[Volo.Abp.Caching](https://www.nuget.org/packages/Volo.Abp.Caching)是缓存系统的核心包. 可以使用 [ABP CLI](CLI.md) 的add-package命令将其安装到项目中:
```
-Install-Package Volo.Abp.Caching
+abp add-package Volo.Abp.Caching
```
+你需要在包含 `csproj` 文件的文件夹中的命令行终端上运行此命令(请参阅 [其他选项](https://abp.io/package-detail/Volo.Abp.Caching) 安装).
-然后将 **AbpCachingModule** 依赖添加到你的模块:
+## 使用方式
-```c#
-using Volo.Abp.Modularity;
-using Volo.Abp.Caching;
-
-namespace MyCompany.MyProject
-{
- [DependsOn(typeof(AbpCachingModule))]
- public class MyModule : AbpModule
- {
- //...
- }
-}
-```
-
-## `IDistributedCache` 接口
+### `IDistributedCache` 接口
-ASP.NET Core 定义了 `IDistributedCache` 接口用于 get/set 缓存值 . 但是会有以下问题:
+ASP.NET Core 定义了 `IDistributedCache` 接口用于 get/set 缓存值. 但是会有以下问题:
* 它适用于 **byte 数组** 而不是 .NET 对象. 因此你需要对缓存的对象进行**序列化/反序列化**.
-* 它为所有的缓存项提供了 **单个 key 池** , 因此 ;
+* 它为所有的缓存项提供了 **单个 key 池** , 因此;
* 你需要注意键区分 **不同类型的对象**.
* 你需要注意**不同租户**(参见[多租户](Multi-Tenancy.md))的缓存项.
> `IDistributedCache` 定义在 `Microsoft.Extensions.Caching.Abstractions` 包中. 这使它不仅适用于ASP.NET Core应用程序, 也可用于**任何类型的程序**.
-> `IDistributedCache` 接口的默认实现是 `MemoryDistributedCache` 它使用**内存**工作. 参见 [ASP.NET Core文档](https://docs.microsoft.com/zh-cn/aspnet/core/performance/caching/distributed) 了解如何切换到 **Redis** 或其他缓存提供程序.
+> `IDistributedCache` 接口的默认实现是 `MemoryDistributedCache` 它使用**内存**工作. 参见 [ASP.NET Core文档](https://docs.microsoft.com/zh-cn/aspnet/core/performance/caching/distributed) 了解如何切换到 **Redis** 或其他缓存提供程序. 此外, 如果要将Redis用作分布式缓存服务器, [Redis缓存](Redis-Cache.md) 文档.
有关更多信息, 参见 [ASP.NET Core 分布式缓存文档](https://docs.microsoft.com/zh-cn/aspnet/core/performance/caching/distributed).
-## `IDistributedCache` 接口
+### `IDistributedCache` 接口
ABP框架在[Volo.Abp.Caching](https://www.nuget.org/packages/Volo.Abp.Caching/)包定义了通用的泛型 `IDistributedCache` 接口. `TCacheItem` 是存储在缓存中的对象类型.
-`IDistributedCache` 解决了上述中的问题;
+`IDistributedCache` 接口解决了上述中的问题;
* 它在内部 **序列化/反序列化** 缓存对象. 默认使用 **JSON** 序列化, 但可以替换[依赖注入](Dependency-Injection.md)系统中 `IDistributedCacheSerializer` 服务的实现来覆盖默认的处理.
-* 它根据缓存中对象类型自动向缓存key添加 **缓存名称** 前缀. 默认缓存名是缓存对象类的全名(如果你的类名以`CacheItem` 结尾, 那么`CacheItem` 会被忽略,不应用到缓存名称上). 你也可以在缓存类上使用 `CacheName` 设置换缓存的名称.
-* 它自动将当前的**租户id**添加到缓存键中, 以区分不同租户的缓存项 (只有在你的应用程序是[多租户](Multi-Tenancy.md)的情况下生效). 在缓存类上应用 `IgnoreMultiTenancy` attribute, 可以在所有的租户间共享缓存.
-* 允许为每个应用程序定义 **全局缓存键前缀** ,不同的应用程序可以在共享的分布式缓存中拥有自己的隔离池.
+* 它根据缓存中对象类型自动向缓存key添加 **缓存名称** 前缀. 默认缓存名是缓存对象类的全名(如果你的类名以`CacheItem` 结尾, 那么`CacheItem` 会被忽略,不应用到缓存名称上). 你也可以在缓存类上使用 **`CacheName` 特性** 设置缓存的名称.
+* 它自动将**当前的租户id**添加到缓存键中, 以区分不同租户的缓存项 (只有在你的应用程序是[多租户](Multi-Tenancy.md)的情况下生效). 如果要在多租户应用程序中的所有租户之间共享缓存对象, 请在缓存项类上定义`IgnoreMultiTenancy`特性以禁用此选项.
+* 允许为每个应用程序定义 **全局缓存键前缀** , 不同的应用程序可以在共享的分布式缓存中拥有自己的隔离池.
+* 它可以在任何可能绕过缓存的情况下 **容忍错误** 的发生. 这在缓存服务器出现临时问题时非常有用.
+* 它有 `GetManyAsync` 和 `SetManyAsync` 等方法, 可以显著提高**批处理**的性能.
-### 使用方式
-
-缓存中存储项的示例类:
+**示例: 在缓存中存储图书名称和价格**
````csharp
-public class BookCacheItem
+namespace MyProject
{
- public string Name { get; set; }
+ public class BookCacheItem
+ {
+ public string Name { get; set; }
- public float Price { get; set; }
+ public float Price { get; set; }
+ }
}
````
你可以注入 `IDistributedCache` 服务用于 get/set `BookCacheItem` 对象.
-使用示例:
-
````csharp
-public class BookService : ITransientDependency
-{
- private readonly IDistributedCache _cache;
-
- public BookService(IDistributedCache cache)
- {
- _cache = cache;
- }
-
- public async Task GetAsync(Guid bookId)
- {
- return await _cache.GetOrAddAsync(
- bookId.ToString(), //Cache key
- async () => await GetBookFromDatabaseAsync(bookId),
- () => new DistributedCacheEntryOptions
- {
- AbsoluteExpiration = DateTimeOffset.Now.AddHours(1)
- }
- );
- }
+using System;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Caching.Distributed;
+using Volo.Abp.Caching;
+using Volo.Abp.DependencyInjection;
- private Task GetBookFromDatabaseAsync(Guid bookId)
+namespace MyProject
+{
+ public class BookService : ITransientDependency
{
- //TODO: get from database
+ private readonly IDistributedCache _cache;
+
+ public BookService(IDistributedCache cache)
+ {
+ _cache = cache;
+ }
+
+ public async Task GetAsync(Guid bookId)
+ {
+ return await _cache.GetOrAddAsync(
+ bookId.ToString(), //缓存键
+ async () => await GetBookFromDatabaseAsync(bookId),
+ () => new DistributedCacheEntryOptions
+ {
+ AbsoluteExpiration = DateTimeOffset.Now.AddHours(1)
+ }
+ );
+ }
+
+ private Task GetBookFromDatabaseAsync(Guid bookId)
+ {
+ //TODO: 从数据库获取数据
+ }
}
}
````
-* 示例服务代码中的 `GetOrAddAsync()` 方法从缓存中获取图书项.
+* 示例服务代码中的 `GetOrAddAsync()` 方法从缓存中获取图书项. `GetOrAddAsync`是ABP框架在 ASP.NET Core 分布式缓存方法中添增的附加方法.
* 如果没有在缓存中找到图书,它会调用工厂方法 (本示例中是 `GetBookFromDatabaseAsync`)从原始数据源中获取图书项.
* `GetOrAddAsync` 有一个可选参数 `DistributedCacheEntryOptions` , 可用于设置缓存的生命周期.
-`IDistributedCache` 的其他方法与ASP.NET Core的`IDistributedCache` 接口相同, 你可以参考 [ASP.NET Core文档](https://docs.microsoft.com/zh-cn/aspnet/core/performance/caching/distributed).
+`IDistributedCache` 与ASP.NET Core的`IDistributedCache` 接口拥有相同的方法, 你可以参考 [ASP.NET Core文档](https://docs.microsoft.com/zh-cn/aspnet/core/performance/caching/distributed).
-## `IDistributedCache` 接口
+### `IDistributedCache` 接口
-`IDistributedCache` 接口默认了键是 `string` 类型 (如果你的键不是string类型需要进行手动类型转换). `IDistributedCache` 将键的类型泛型化试图简化手动转换的操作.
+`IDistributedCache` 接口默认了**缓存键**是 `string` 类型 (如果你的键不是string类型需要进行手动类型转换). 但当缓存键的类型不是`string`时, 可以使用`IDistributedCache`.
-### 使用示例
+**示例: 在缓存中存储图书名称和价格**
示例缓存项
````csharp
-public class BookCacheItem
+using Volo.Abp.Caching;
+
+namespace MyProject
{
- public string Name { get; set; }
+ [CacheName("Books")]
+ public class BookCacheItem
+ {
+ public string Name { get; set; }
- public float Price { get; set; }
+ public float Price { get; set; }
+ }
}
````
-用法示例 (这里假设你的键类型是 `Guid`):
+* 在本例中使用`CacheName`特性给`BookCacheItem`类设置缓存名称.
-````csharp
-public class BookService : ITransientDependency
-{
- private readonly IDistributedCache _cache;
+你可以注入 `IDistributedCache` 服务用于 get/set `BookCacheItem` 对象.
- public BookService(IDistributedCache cache)
- {
- _cache = cache;
- }
+````csharp
+using System;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Caching.Distributed;
+using Volo.Abp.Caching;
+using Volo.Abp.DependencyInjection;
- public async Task GetAsync(Guid bookId)
- {
- return await _cache.GetOrAddAsync(
- bookId, //Guid type used as the cache key
- async () => await GetBookFromDatabaseAsync(bookId),
- () => new DistributedCacheEntryOptions
- {
- AbsoluteExpiration = DateTimeOffset.Now.AddHours(1)
- }
- );
- }
- private Task GetBookFromDatabaseAsync(Guid bookId)
+namespace MyProject
+{
+ public class BookService : ITransientDependency
{
- //TODO: get from database
+ private readonly IDistributedCache _cache;
+
+ public BookService(IDistributedCache cache)
+ {
+ _cache = cache;
+ }
+
+ public async Task GetAsync(Guid bookId)
+ {
+ return await _cache.GetOrAddAsync(
+ bookId, //Guid类型作为缓存键
+ async () => await GetBookFromDatabaseAsync(bookId),
+ () => new DistributedCacheEntryOptions
+ {
+ AbsoluteExpiration = DateTimeOffset.Now.AddHours(1)
+ }
+ );
+ }
+ private Task GetBookFromDatabaseAsync(Guid bookId)
+ {
+ //TODO: 从数据库获取数据
+ }
}
}
````
* 示例服务中 `GetOrAddAsync()` 方法获取缓存的图书项.
-* 我们采用了 `Guid` 做为键,在 `_cache_GetOrAddAsync()` 方法中传入 `Guid` 类型的bookid.
+* 我们采用了 `Guid` 做为键, 在 `_cache_GetOrAddAsync()` 方法中传入 `Guid` 类型的bookid.
+
+#### 复杂类型的缓存键
-`IDistributedCache` 在内部使用键对象的 `ToString()` 方法转换类型为string. 如果你的将复杂对象做为键,那么需要重写类的 `ToString` 方法.
+`IDistributedCache` 在内部使用键对象的 `ToString()` 方法转换类型为string. 如果你的将复杂对象做为缓存键,那么需要重写类的 `ToString` 方法.
-示例:
+举例一个作为缓存键的类:
````csharp
public class UserInOrganizationCacheKey
@@ -187,23 +203,72 @@ public class BookService : ITransientDependency
{
_cache = cache;
}
-
+
...
}
````
+## 配置
+
+### AbpDistributedCacheOptions
+`AbpDistributedCacheOptions` 是配置缓存的主要[Option类](Options.md).
+
+**示例:为应用程序设置缓存键前缀**
+
+```csharp
+Configure(options =>
+{
+ options.KeyPrefix = "MyApp1";
+});
+```
+> 在[模块类](Module-Development-Basics.md)的`ConfigureServices`方法中添加代码.
+
+#### 可用选项
+
+* `HideErrors` (`bool`, 默认: `true`): 启用/禁用隐藏从缓存服务器写入/读取值时的错误.
+* `KeyPrefix` (`string`, 默认: `null`): 如果你的缓存服务器由多个应用程序共同使用, 则可以为应用程序的缓存键设置一个前缀. 在这种情况下, 不同的应用程序不能覆盖彼此的缓存内容.
+* `GlobalCacheEntryOptions` (`DistributedCacheEntryOptions`): 用于设置保存缓内容却没有指定选项时, 默认的分布式缓存选项 (例如 `AbsoluteExpiration` 和 `SlidingExpiration`). `SlidingExpiration`的默认值设置为20分钟.
+
+## 错误处理
+
+当为你的对象设计缓存时, 通常会首先尝试从缓存中获取值. 如果在缓存中找不到该值, 则从**来源**查询对象. 它可能在**数据库**中, 或者可能需要通过HTTP调用远程服务器.
+
+在大多数情况下, 你希望**容忍缓存错误**; 如果缓存服务器出现错误, 也不希望取消该操作. 相反, 你可以默默地隐藏(并记录)错误并**从来源查询**. 这就是ABP框架默认的功能.
+
+ABP的分布式缓存 [异常处理](Exception-Handling.md), 默认记录并隐藏错误. 有一个全局修改该功能的选项(参见下面的选项内容).
+
+所有的`IDistributedCache` (和 `IDistributedCache`)方法都有一个可选的参数`hideErrors`, 默认值为`null`. 如果此参数设置为`null`, 则全局生效, 否则你可以选择单个方法调用时隐藏或者抛出异常.
+
## 批量操作
ABP的分布式缓存接口定义了以下批量操作方法,当你需要在一个方法中调用多次缓存操作时,这些方法可以提高性能
-* `SetManyAsync` 和 `SetMany` 方法可以用来设置多个值.
+* `SetManyAsync` 和 `SetMany` 方法可以用来向缓存中设置多个值.
* `GetManyAsync` 和 `GetMany` 方法可以用来从缓存中获取多个值.
* `GetOrAddManyAsync` 和 `GetOrAddMany` 方法可以用来从缓存中获取并添加缺少的值.
* `RefreshManyAsync` 和 `RefreshMany` 方法可以来用重置多个值的滚动过期时间.
-* `RemoveManyAsync` 和 `RemoveMany` 方法呆以用来删除多个值.
+* `RemoveManyAsync` 和 `RemoveMany` 方法可以用来从缓存中删除多个值.
> 这些不是标准的ASP.NET Core缓存方法, 所以某些提供程序可能不支持. [ABP Redis集成包](Redis-Cache.md)实现了它们. 如果提供程序不支持,会回退到 `SetAsync` 和 `GetAsync` ... 方法(循环调用).
-### DistributedCacheOptions
+## 高级主题
+
+### 工作单元级别的缓存
+
+分布式缓存服务提供了一个有趣的功能. 假设你已经更新了数据库中某本书的价格, 然后将新价格设置到缓存中, 以便以后使用缓存的值. 如果设置缓存后出现异常, 并且更新图书价格的**事务被回滚了**, 该怎么办?在这种情况下, 缓存值是错误的.
+
+`IDistributedCache<..>`方法提供一个可选参数, `considerUow`, 默认为`false`. 如果将其设置为`true`, 则你对缓存所做的更改不会应用于真正的缓存存储, 而是与当前的[工作单元](Unit-Of-Work.md)关联. 你将获得在同一工作单元中设置的缓存值, 但**仅当前工作单元成功时**更改才会生效.
+
+### IDistributedCacheSerializer
+
+`IDistributedCacheSerializer`服务用于序列化和反序列化缓存内容. 默认实现是`Utf8JsonDistributedCacheSerializer`类, 它使用`IJsonSerializer`服务将对象转换为[JSON](Json-Serialization.md), 反之亦然. 然后, 它使用UTC8编码将JSON字符串转换为分布式缓存接受的字节数组.
+
+如果你想实现自己的序列化逻辑, 可以自己实现并[替换](Dependency-Injection.md) 此服务.
+
+### IDistributedCacheKeyNormalizer
+
+默认情况下, `IDistributedCacheKeyNormalizer`是由`DistributedCacheKeyNormalizer`类实现的. 它将缓存名称、应用程序缓存前缀和当前租户id添加到缓存键中. 如果需要更高级的键规范化, 可以自己实现并[替换](Dependency-Injection.md)此服务.
+
+## 另请参阅
-TODO
+* [Redis 缓存](Redis-Cache.md)
diff --git a/docs/zh-Hans/Distributed-Event-Bus-Kafka-Integration.md b/docs/zh-Hans/Distributed-Event-Bus-Kafka-Integration.md
index f621a95fae..171fe3c23b 100644
--- a/docs/zh-Hans/Distributed-Event-Bus-Kafka-Integration.md
+++ b/docs/zh-Hans/Distributed-Event-Bus-Kafka-Integration.md
@@ -1,10 +1,10 @@
# 分布式事件总线Kafka集成
-> 本文解释了**如何配置[Kafka](https://kafka.apache.org/)**做为分布式总线提供程序. 参阅[分布式事件总线文档](Distributed-Event-Bus.md)了解如何使用分布式事件总线系统.
+> 本文解释了 **如何配置[Kafka](https://kafka.apache.org/)** 做为分布式总线提供程序. 参阅[分布式事件总线文档](Distributed-Event-Bus.md)了解如何使用分布式事件总线系统.
## 安装
-使用ABP CLI添加[Volo.Abp.EventBus.Kafka[Volo.Abp.EventBus.Kafka](https://www.nuget.org/packages/Volo.Abp.EventBus.Kafka)NuGet包到你的项目:
+使用ABP CLI添加[Volo.Abp.EventBus.Kafka](https://www.nuget.org/packages/Volo.Abp.EventBus.Kafka)NuGet包到你的项目:
* 安装[ABP CLI](https://docs.abp.io/en/abp/latest/CLI),如果你还没有安装.
* 在你想要安装 `Volo.Abp.EventBus.Kafka` 包的 `.csproj` 文件目录打开命令行(终端).
@@ -18,7 +18,7 @@
### `appsettings.json` 文件配置
-这是配置Kafka设置最简单的方法. 它也非常强大,因为你可以使用[由AspNet Core支持的](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/)的任何其他配置源(如环境变量).
+这是配置Kafka设置最简单的方法. 它也非常强大,因为你可以使用[由AspNet Core支持](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/)的任何其他配置源(如环境变量).
**示例:最小化配置与默认配置连接到本地的Kafka服务器**
@@ -160,4 +160,4 @@ Configure(options =>
});
````
-使用这些选项类可以与 `appsettings.json` 组合在一起. 在代码中配置选项属性会覆盖配置文件中的值.
\ No newline at end of file
+使用这些选项类可以与 `appsettings.json` 组合在一起. 在代码中配置选项属性会覆盖配置文件中的值.
diff --git a/docs/zh-Hans/Distributed-Event-Bus-RabbitMQ-Integration.md b/docs/zh-Hans/Distributed-Event-Bus-RabbitMQ-Integration.md
index ab7cb68bd7..1cd6b5b9dd 100644
--- a/docs/zh-Hans/Distributed-Event-Bus-RabbitMQ-Integration.md
+++ b/docs/zh-Hans/Distributed-Event-Bus-RabbitMQ-Integration.md
@@ -1,10 +1,10 @@
# 分布式事件总线RabbitMQ集成
-> 本文解释了**如何配置[RabbitMQ](https://www.rabbitmq.com/)**做为分布式总线提供程序. 参阅[分布式事件总线文档](Distributed-Event-Bus.md)了解如何使用分布式事件总线系统.
+> 本文解释了 **如何配置[RabbitMQ](https://www.rabbitmq.com/)** 做为分布式总线提供程序. 参阅[分布式事件总线文档](Distributed-Event-Bus.md)了解如何使用分布式事件总线系统.
## 安装
-使用ABP CLI添加[Volo.Abp.EventBus.RabbitMQ[Volo.Abp.EventBus.RabbitMQ](https://www.nuget.org/packages/Volo.Abp.EventBus.RabbitMQ)NuGet包到你的项目:
+使用ABP CLI添加[Volo.Abp.EventBus.RabbitMQ](https://www.nuget.org/packages/Volo.Abp.EventBus.RabbitMQ)NuGet包到你的项目:
* 安装[ABP CLI](https://docs.abp.io/en/abp/latest/CLI),如果你还没有安装.
* 在你想要安装 `Volo.Abp.EventBus.RabbitMQ` 包的 `.csproj` 文件目录打开命令行(终端).
@@ -18,7 +18,7 @@
### `appsettings.json` 文件配置
-这是配置RabbitMQ设置最简单的方法. 它也非常强大,因为你可以使用[由AspNet Core支持的](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/)的任何其他配置源(如环境变量).
+这是配置RabbitMQ设置最简单的方法. 它也非常强大,因为你可以使用[由AspNet Core支持](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/)的任何其他配置源(如环境变量).
**示例:最小化配置与默认配置连接到本地的RabbitMQ服务器**
@@ -151,4 +151,4 @@ Configure(options =>
});
````
-使用这些选项类可以与 `appsettings.json` 组合在一起. 在代码中配置选项属性会覆盖配置文件中的值.
\ No newline at end of file
+使用这些选项类可以与 `appsettings.json` 组合在一起. 在代码中配置选项属性会覆盖配置文件中的值.
diff --git a/docs/zh-Hans/Distributed-Event-Bus-Rebus-Integration.md b/docs/zh-Hans/Distributed-Event-Bus-Rebus-Integration.md
index 409b935ace..64fce06d1b 100644
--- a/docs/zh-Hans/Distributed-Event-Bus-Rebus-Integration.md
+++ b/docs/zh-Hans/Distributed-Event-Bus-Rebus-Integration.md
@@ -1,10 +1,10 @@
# 分布式事件总线Rebus集成
-> 本文解释了**如何配置[Rebus](http://mookid.dk/category/rebus/)**做为分布式总线提供程序. 参阅[分布式事件总线文档](Distributed-Event-Bus.md)了解如何使用分布式事件总线系统.
+> 本文解释了 **如何配置[Rebus](http://mookid.dk/category/rebus/)** 做为分布式总线提供程序. 参阅[分布式事件总线文档](Distributed-Event-Bus.md)了解如何使用分布式事件总线系统.
## 安装
-使用ABP CLI添加[Volo.Abp.EventBus.Rebus[Volo.Abp.EventBus.Rebus](https://www.nuget.org/packages/Volo.Abp.EventBus.Rebus)NuGet包到你的项目:
+使用ABP CLI添加[Volo.Abp.EventBus.Rebus](https://www.nuget.org/packages/Volo.Abp.EventBus.Rebus)NuGet包到你的项目:
* 安装[ABP CLI](https://docs.abp.io/en/abp/latest/CLI),如果你还没有安装.
* 在你想要安装 `Volo.Abp.EventBus.Rebus` 包的 `.csproj` 文件目录打开命令行(终端).
diff --git a/docs/zh-Hans/Distributed-Event-Bus.md b/docs/zh-Hans/Distributed-Event-Bus.md
index f16aa0610f..e59fa5e726 100644
--- a/docs/zh-Hans/Distributed-Event-Bus.md
+++ b/docs/zh-Hans/Distributed-Event-Bus.md
@@ -264,7 +264,7 @@ Configure(options =>
因此可以实现 `IDistributedEventHandler>` 订阅事件. 但是订阅这样的通用事件不是一个好方法,你可以为实体类型定义对应的ETO.
-**示例: 为 `Product` 声明使用 `ProductDto`**
+**示例: 为 `Product` 声明使用 `ProductEto`**
````csharp
Configure(options =>
diff --git a/docs/zh-Hans/Domain-Services.md b/docs/zh-Hans/Domain-Services.md
index 9c9bb7dfd2..a617aea645 100644
--- a/docs/zh-Hans/Domain-Services.md
+++ b/docs/zh-Hans/Domain-Services.md
@@ -1,3 +1,128 @@
-# ABP Documentation
+# 领域服务
-待添加
+## 介绍
+
+在 [领域驱动设计](Domain-Driven-Design.md) (DDD) 解决方案中,核心业务逻辑通常在聚合 ([实体](Entities.md)) 和领域服务中实现. 在以下情况下特别需要创建领域服务
+
+* 你实现了依赖于某些服务(如存储库或其他外部服务)的核心域逻辑.
+* 你需要实现的逻辑与多个聚合/实体相关,因此它不适合任何聚合.
+
+## ABP 领域服务基础设施
+
+领域服务是简单的无状态类. 虽然你不必从任何服务或接口派生,但 ABP 框架提供了一些有用的基类和约定.
+
+### DomainService 和 IDomainService
+
+从 `DomainService` 基类派生领域服务或直接实现 `IDomainService` 接口.
+
+**示例: 创建从 `DomainService` 基类派生的领域服务.**
+
+````csharp
+using Volo.Abp.Domain.Services;
+namespace MyProject.Issues
+{
+ public class IssueManager : DomainService
+ {
+
+ }
+}
+````
+
+当你这样做时:
+
+* ABP 框架自动将类注册为瞬态生命周期到依赖注入系统.
+* 你可以直接使用一些常用服务作为基础属性,而无需手动注入 (例如 [ILogger](Logging.md) and [IGuidGenerator](Guid-Generation.md)).
+
+> 建议使用 `Manager` 或 `Service` 后缀命名领域服务. 我们通常使用如上面示例中的 `Manager` 后缀.
+**示例: 实现将问题分配给用户的领域逻辑**
+
+````csharp
+public class IssueManager : DomainService
+{
+ private readonly IRepository _issueRepository;
+ public IssueManager(IRepository issueRepository)
+ {
+ _issueRepository = issueRepository;
+ }
+
+ public async Task AssignAsync(Issue issue, AppUser user)
+ {
+ var currentIssueCount = await _issueRepository
+ .CountAsync(i => i.AssignedUserId == user.Id);
+
+ //Implementing a core business validation
+ if (currentIssueCount >= 3)
+ {
+ throw new IssueAssignmentException(user.UserName);
+ }
+ issue.AssignedUserId = user.Id;
+ }
+}
+````
+
+问题是定义如下所示的 [聚合根](Entities.md):
+
+````csharp
+public class Issue : AggregateRoot
+{
+ public Guid? AssignedUserId { get; internal set; }
+
+ //...
+}
+````
+
+* 使用 `internal` 的 set 确保外层调用者不能直接在调用 set ,并强制始终使用 `IssueManager` 为 `User` 分配 `Issue`.
+
+### 使用领域服务
+
+领域服务通常用于 [应用程序服务](Application-Services.md).
+
+**示例: 使用 `IssueManager` 将问题分配给用户**
+
+````csharp
+using System;
+using System.Threading.Tasks;
+using MyProject.Users;
+using Volo.Abp.Application.Services;
+using Volo.Abp.Domain.Repositories;
+namespace MyProject.Issues
+{
+ public class IssueAppService : ApplicationService, IIssueAppService
+ {
+ private readonly IssueManager _issueManager;
+ private readonly IRepository _userRepository;
+ private readonly IRepository _issueRepository;
+ public IssueAppService(
+ IssueManager issueManager,
+ IRepository userRepository,
+ IRepository issueRepository)
+ {
+ _issueManager = issueManager;
+ _userRepository = userRepository;
+ _issueRepository = issueRepository;
+ }
+ public async Task AssignAsync(Guid id, Guid userId)
+ {
+ var issue = await _issueRepository.GetAsync(id);
+ var user = await _userRepository.GetAsync(userId);
+ await _issueManager.AssignAsync(issue, user);
+ await _issueRepository.UpdateAsync(issue);
+ }
+ }
+}
+````
+
+由于 `IssueAppService` 在应用层, 它不能直接将问题分配给用户.因此,它使用 `IssueManager`.
+
+## 应用程序服务与领域服务
+
+虽然应用服务和领域服务都实现了业务规则,但存在根本的逻辑和形式差异;
+虽然 [应用服务](Application-Services.md) 和领域服务都实现了业务规则,但存在根本的逻辑和形式差异:
+
+* 应用程序服务实现应用程序的 **用例** (典型 Web 应用程序中的用户交互), 而领域服务实现 **核心的、用例独立的领域逻辑**.
+* 应用程序服务获取/返回 [数据传输对象](Data-Transfer-Objects.md), 领域服务方法通常获取和返回 **领域对象** ([实体](Entities.md), [值对象](Value-Objects.md)).
+* 领域服务通常由应用程序服务或其他领域服务使用,而应用程序服务由表示层或客户端应用程序使用.
+
+## 生命周期
+
+领域服务的生命周期是 [瞬态](https://docs.abp.io/en/abp/latest/Dependency-Injection) 的,它们会自动注册到依赖注入服务.
diff --git a/docs/zh-Hans/Modules/Background-Jobs.md b/docs/zh-Hans/Modules/Background-Jobs.md
index b183febd80..fe021f1a56 100644
--- a/docs/zh-Hans/Modules/Background-Jobs.md
+++ b/docs/zh-Hans/Modules/Background-Jobs.md
@@ -1,3 +1,55 @@
-# Background Jobs Module
+# 后台作业模块
-待添加
\ No newline at end of file
+后台作业模块实现了 `IBackgroundJobStore` 接口,并且可以使用ABP框架的默认后台作业管理.如果你不想使用这个模块,那么你需要自己实现 `IBackgroundJobStore` 接口.
+
+> 本文档仅介绍后台作业模块,该模块将后台作业持久化到数据库.有关后台作业系统的更多信息,请参阅[后台作业](../Background-Jobs.md)文档.
+
+## 如何使用
+
+当你使用ABP框架[创建一个新的解决方案](https://abp.io/get-started)时,这个模块是(作为NuGet/NPM包)预先安装的.你可以继续将其作为软件包使用并轻松获取更新,也可以将其源代码包含到解决方案中(请参阅 `get-source` [CLI](../CLI.md)命令)以开发自定义模块.
+
+### 源代码
+
+此模块的源代码可在[此处](https://github.com/abpframework/abp/tree/dev/modules/background-jobs)访问.源代码是由[MIT](https://choosealicense.com/licenses/mit/)授权的,所以你可以自由使用和定制它.
+
+## 内部结构
+
+### 领域层
+
+#### 聚合
+
+- `BackgroundJobRecord` (聚合根): 表示后台工作记录.
+
+#### 仓储
+
+为该模块定义了以下自定义仓储:
+
+- `IBackgroundJobRepository`
+
+### 数据库提供程序
+
+#### 通用
+
+##### 表/集合的前缀与架构
+
+默认情况下,所有表/集合都使用 `Abp` 前缀.如果需要更改表前缀或设置架构名称(如果数据库提供程序支持),请在 `BackgroundJobsDbProperties` 类上设置静态属性.
+
+##### 连接字符串
+
+此模块使用 `AbpBackgroundJobs` 作为连接字符串名称.如果不使用此名称定义连接字符串,它将返回 `Default` 连接字符串.有关详细信息,请参阅[连接字符串](https://docs.abp.io/en/abp/latest/Connection-Strings)文档.
+
+#### Entity Framework Core
+
+##### 表
+
+- **AbpBackgroundJobs**
+
+#### MongoDB
+
+##### 集合
+
+- **AbpBackgroundJobs**
+
+## 另请参阅
+
+* [后台作业系统](../Background-Jobs.md)
diff --git a/docs/zh-Hans/Specifications.md b/docs/zh-Hans/Specifications.md
index f927c80255..40a473dbc0 100644
--- a/docs/zh-Hans/Specifications.md
+++ b/docs/zh-Hans/Specifications.md
@@ -1,3 +1,257 @@
## 规约
-TODO..
\ No newline at end of file
+规约模式用于为实体和其他业务对象定义 **命名、可复用、可组合和可测试的过滤器** .
+
+> 规约是领域层的一部分.
+
+## 安装
+
+> 这个包 **已经安装** 在启动模板中.所以,大多数时候你不需要手动去安装.
+
+添加 [Volo.Abp.Specifications](https://abp.io/package-detail/Volo.Abp.Specifications) 包到你的项目. 如果当前文件夹是你的项目的根目录(`.csproj`)时,你可以在命令行终端中使用 [ABP CLI](CLI.md) *add package* 命令:
+
+````bash
+abp add-package Volo.Abp.Specifications
+````
+
+## 定义规约
+
+假设你定义了如下的顾客实体:
+
+````csharp
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace MyProject
+{
+ public class Customer : AggregateRoot
+ {
+ public string Name { get; set; }
+
+ public byte Age { get; set; }
+
+ public long Balance { get; set; }
+
+ public string Location { get; set; }
+ }
+}
+````
+
+你可以创建一个由 `Specification` 派生的新规约类.
+
+**例如:规定选择一个18岁以上的顾客**
+
+````csharp
+using System;
+using System.Linq.Expressions;
+using Volo.Abp.Specifications;
+
+namespace MyProject
+{
+ public class Age18PlusCustomerSpecification : Specification
+ {
+ public override Expression> ToExpression()
+ {
+ return c => c.Age >= 18;
+ }
+ }
+}
+````
+
+你只需通过定义一个lambda[表达式](https://docs.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/lambda-expressions)来定义规约.
+
+> 你也可以直接实现`ISpecification`接口,但是基类`Specification`做了大量简化.
+
+## 使用规约
+
+这里有两种常见的规约用例.
+
+### IsSatisfiedBy
+
+`IsSatisfiedBy` 方法可以用于检查单个对象是否满足规约.
+
+**例如:如果顾客不满足年龄规定,则抛出异常**
+
+````csharp
+using System;
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+
+namespace MyProject
+{
+ public class CustomerService : ITransientDependency
+ {
+ public async Task BuyAlcohol(Customer customer)
+ {
+ if (!new Age18PlusCustomerSpecification().IsSatisfiedBy(customer))
+ {
+ throw new Exception(
+ "这位顾客不满足年龄规定!"
+ );
+ }
+
+ //TODO...
+ }
+ }
+}
+````
+
+### ToExpression & Repositories
+
+`ToExpression()` 方法可用于将规约转化为表达式.通过这种方式,你可以使用规约在**数据库查询时过滤实体**.
+
+````csharp
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Domain.Repositories;
+using Volo.Abp.Domain.Services;
+
+namespace MyProject
+{
+ public class CustomerManager : DomainService, ITransientDependency
+ {
+ private readonly IRepository _customerRepository;
+
+ public CustomerManager(IRepository customerRepository)
+ {
+ _customerRepository = customerRepository;
+ }
+
+ public async Task> GetCustomersCanBuyAlcohol()
+ {
+ var queryable = await _customerRepository.GetQueryableAsync();
+ var query = queryable.Where(
+ new Age18PlusCustomerSpecification().ToExpression()
+ );
+
+ return await AsyncExecuter.ToListAsync(query);
+ }
+ }
+}
+````
+
+> 规约被正确地转换为SQL/数据库查询语句,并且在DBMS端高效执行.虽然它与规约无关,但如果你想了解有关 `AsyncExecuter` 的更多信息,请参阅[仓储](Repositories.md)文档.
+
+实际上,没有必要使用 `ToExpression()` 方法,因为规约会自动转换为表达式.这也会起作用:
+
+````csharp
+var queryable = await _customerRepository.GetQueryableAsync();
+var query = queryable.Where(
+ new Age18PlusCustomerSpecification()
+);
+````
+
+## 编写规约
+
+规约有一个强大的功能是,它们可以与`And`、`Or`、`Not`以及`AndNot`扩展方法组合使用.
+
+假设你有另一个规约,定义如下:
+
+```csharp
+using System;
+using System.Linq.Expressions;
+using Volo.Abp.Specifications;
+
+namespace MyProject
+{
+ public class PremiumCustomerSpecification : Specification
+ {
+ public override Expression> ToExpression()
+ {
+ return (customer) => (customer.Balance >= 100000);
+ }
+ }
+}
+```
+
+你可以将 `PremiumCustomerSpecification` 和 `Age18PlusCustomerSpecification` 结合起来,查询优质成人顾客的数量,如下所示:
+
+````csharp
+using System;
+using System.Threading.Tasks;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Domain.Repositories;
+using Volo.Abp.Domain.Services;
+using Volo.Abp.Specifications;
+
+namespace MyProject
+{
+ public class CustomerManager : DomainService, ITransientDependency
+ {
+ private readonly IRepository _customerRepository;
+
+ public CustomerManager(IRepository customerRepository)
+ {
+ _customerRepository = customerRepository;
+ }
+
+ public async Task GetAdultPremiumCustomerCountAsync()
+ {
+ return await _customerRepository.CountAsync(
+ new Age18PlusCustomerSpecification()
+ .And(new PremiumCustomerSpecification()).ToExpression()
+ );
+ }
+ }
+}
+````
+
+如果你想让这个组合成为一个可复用的规约,你可以创建这样一个组合的规约类,它派生自`AndSpecification`:
+
+````csharp
+using Volo.Abp.Specifications;
+
+namespace MyProject
+{
+ public class AdultPremiumCustomerSpecification : AndSpecification
+ {
+ public AdultPremiumCustomerSpecification()
+ : base(new Age18PlusCustomerSpecification(),
+ new PremiumCustomerSpecification())
+ {
+ }
+ }
+}
+````
+
+现在,你就可以向下面一样重新编写 `GetAdultPremiumCustomerCountAsync` 方法:
+
+````csharp
+public async Task GetAdultPremiumCustomerCountAsync()
+{
+ return await _customerRepository.CountAsync(
+ new AdultPremiumCustomerSpecification()
+ );
+}
+````
+
+> 你可以从这些例子中看到规约的强大之处.如果你之后想要更改 `PremiumCustomerSpecification` ,比如将余额从 `100.000` 修改为 `200.000` ,所有查询语句和合并的规约都将受到本次更改的影响.这是减少代码重复的好方法!
+
+## 讨论
+
+虽然规约模式通常与C#的lambda表达式相比较,算是一种更老的方式.一些开发人员可能认为不再需要它,我们可以直接将表达式传入到仓储或领域服务中,如下所示:
+
+````csharp
+var count = await _customerRepository.CountAsync(c => c.Balance > 100000 && c.Age => 18);
+````
+
+自从ABP的[仓储](Repositories.md)支持表达式,这是一个完全有效的用法.你不必在应用程序中定义或使用任何规约,可以直接使用表达式.
+
+所以,规约的意义是什么?为什么或者应该在什么时候考虑去使用它?
+
+### 何时使用?
+
+使用规约的一些好处:
+
+- **可复用**:假设你在代码库的许多地方都需要用到优质顾客过滤器.如果使用表达式而不创建规约,那么如果以后更改“优质顾客”的定义会发生什么?假设你想将最低余额从100000美元更改为250000美元,并添加另一个条件,成为顾客超过3年.如果使用了规约,只需修改一个类.如果在任何其他地方重复(复制/粘贴)相同的表达式,则需要更改所有的表达式.
+- **可组合**:可以组合多个规约来创建新规约.这是另一种可复用性.
+- **命名**:`PremiumCustomerSpecification` 更好地解释了为什么使用规约,而不是复杂的表达式.因此,如果在你的业务中使用了一个有意义的表达式,请考虑使用规约.
+- **可测试**:规约是一个单独(且易于)测试的对象.
+
+### 什么时侯不要使用?
+
+- **没有业务含义的表达式**:不要对与业务无关的表达式和操作使用规约.
+- **报表**:如果只是创建报表,不要创建规约,而是直接使用 `IQueryable` 和LINQ表达式.你甚至可以使用普通SQL、视图或其他工具生成报表.DDD不关心报表,因此从性能角度来看,查询底层数据存储的方式可能很重要.
diff --git a/docs/zh-Hans/Testing.md b/docs/zh-Hans/Testing.md
new file mode 100644
index 0000000000..5bb72803c8
--- /dev/null
+++ b/docs/zh-Hans/Testing.md
@@ -0,0 +1,768 @@
+# 自动化测试
+
+## 介绍
+
+ABP框架的设计考虑了可测试性. 有一些不同级别的自动化测试:
+
+* **单元测试**: 通常只测试一个类(或者一起测试几个类). 这些测试会很快. 然而, 你通常需要处理对服务依赖项的模拟.
+* **集成测试**: 你通常会测试一个服务, 但这一次你不会模拟基本的基础设施和服务, 以查看它们是否正确地协同工作.
+* **用户界面测试**: 测试应用程序的UI, 就像用户与应用程序交互一样.
+
+### 单元测试 vs 集成测试
+
+与单元测试相比, 集成测试有一些显著的**优势**:
+
+* **编写更加简单** 因为你不需要模拟和处理依赖关系.
+* 你的测试代码运行于所有真正的服务和基础设施(包括数据库映射和查询), 因此它更接近于**真正的应用程序测试**.
+
+同时它们有一些缺点:
+
+* 与单元测试相比, 它们**更慢**, 因为所有的基础设施都准备好了测试用例.
+* 服务中的一个bug可能会导致多个测试用例失败, 因此在某些情况下, 可能会**更难找到真正的问题**.
+
+我们建议混合使用: 在必要的地方编写单元测试或集成测试, 并且有效的编写和维护它.
+
+## 应用程序启动模板
+
+测试基础设施提供[应用程序启动模板](Startup-Templates/Application.md) , 并已经正确安装和配置.
+
+### 测试项目
+
+请参见Visual Studio中的以下解决方案:
+
+
+
+按层级系统分为多个测试项目:
+
+* `Domain.Tests` 用于测试领域层对象 (例如[领域服务](Domain-Services.md) 和 [实体](Entities.md)).
+* `Application.Tests` 用于测试应用层对象 (例如[应用服务](Application-Services.md)).
+* `EntityFrameworkCore.Tests` 用于测试你的自定义仓储实现或EF Core映射(如果你使用其他[数据访问](Data-Access.md))的话, 该项目将有所不同).
+* `Web.Tests` 用于测试UI层(如页面、控制器和视图组件). 该项目仅适用于MVC / Razor页面应用程序.
+* `TestBase` 包含一些由其他项目共享/使用的类.
+
+> `HttpApi.Client.ConsoleTestApp` 不是自动化测试的应用程序. 它是一个示例的控制台应用程序, 展示了如何从.NET控制台应用程序中调用HTTP API.
+
+以下的部分将介绍这些项目中包含的基类和其他基础设施.
+
+### 测试基础设施
+
+解决方案中已经安装了以下库:
+
+* [xUnit](https://xunit.net/) 作为测试框架.
+* [NSubstitute](https://nsubstitute.github.io/) 用于模拟.
+* [Shouldly](https://github.com/shouldly/shouldly) 用于断言.
+
+虽然你可以用自己喜欢的工具替换它们, 但本文档和示例将基于这些工具.
+
+## 测试资源管理器
+
+你可以在Visual Studio中使用测试资源管理器查看和运行测试. 其他IDE, 请参阅它们自己的文档.
+
+### 打开测试资源管理器
+
+打开*测试*菜单下的*测试资源管理器*(如果尚未打开):
+
+
+
+### 运行测试
+
+然后, 你可以单击在视图中运行所有测试或运行按钮来运行测试. 初始启动模板为你提供了一些测试用例:
+
+
+
+### 并行运行测试
+
+支持并行运行测试. **强烈建议**并行运行所有测试, 这比逐个运行测试要快得多.
+
+要启用它, 请单击设置(齿轮)按钮附近的插入符号图标, 然后选择*并行运行测试*.
+
+
+
+## 单元测试
+
+对于单元测试, 不需要太多的配置. 通常会实例化你的类, 并对要测试的对象提供一些预先配置的模拟对象.
+
+### 没有依赖项的类
+
+要测试的类没有依赖项是最简单的情况, 你可以直接实例化类, 调用其方法并做出断言.
+
+#### 示例: 测试实体
+
+假设你有一个 `Issue` [实体](Entities.md), 如下所示:
+
+````csharp
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace MyProject.Issues
+{
+ public class Issue : AggregateRoot
+ {
+ public string Title { get; set; }
+ public string Description { get; set; }
+ public bool IsLocked { get; set; }
+ public bool IsClosed { get; private set; }
+ public DateTime? CloseDate { get; private set; }
+
+ public void Close()
+ {
+ IsClosed = true;
+ CloseDate = DateTime.UtcNow;
+ }
+
+ public void Open()
+ {
+ if (!IsClosed)
+ {
+ return;
+ }
+
+ if (IsLocked)
+ {
+ throw new IssueStateException("You can not open a locked issue!");
+ }
+
+ IsClosed = true;
+ CloseDate = null;
+ }
+ }
+}
+
+````
+
+请注意, `IsClosed`和`CloseDate`属性具有私有setter, 可以使用`Open()`和`Close()`方法强制执行某些业务逻辑:
+
+* 无论何时关闭issue, `CloseDate`都应设置为[当前时间](Timing.md).
+* 如果issue被锁定, 则无法重新打开. 如果它被重新打开, `CloseDate`应该设置为`null`.
+
+由于`Issue`实体是领域层的一部分, 所以我们应该在`Domain.Tests`项目中测试它. 在`Domain.Tests`项目中创建一个`Issue_Tests`类:
+
+````csharp
+using Shouldly;
+using Xunit;
+
+namespace MyProject.Issues
+{
+ public class Issue_Tests
+ {
+ [Fact]
+ public void Should_Set_The_CloseDate_Whenever_Close_An_Issue()
+ {
+ // Arrange
+
+ var issue = new Issue();
+ issue.CloseDate.ShouldBeNull(); // null at the beginning
+
+ // Act
+
+ issue.Close();
+
+ // Assert
+
+ issue.IsClosed.ShouldBeTrue();
+ issue.CloseDate.ShouldNotBeNull();
+ }
+ }
+}
+````
+
+这个测试遵循AAA(Arrange-Act-Assert)模式:
+
+* **Arrange** 部分创建一个`Issue`实体, 并确保`CloseDate`在初始值为`null`.
+* **Act** 部分执行我们想要测试的方法.
+* **Assert** 部分检查`Issue`属性是否与我们预期的相同.
+
+`[Fact]`属性由[xUnit](https://xunit.net/)并将方法标记为测试方法. `Should...`扩展方法由[Shouldly](https://github.com/shouldly/shouldly)提供. 你可以直接使用xUnit中的`Assert`类, 使用Shouldly让它更舒适、更直观.
+
+当你执行测试时, 你将看到它成功通过:
+
+
+
+让我们再添加两种测试方法:
+
+````csharp
+[Fact]
+public void Should_Allow_To_ReOpen_An_Issue()
+{
+ // Arrange
+
+ var issue = new Issue();
+ issue.Close();
+
+ // Act
+
+ issue.Open();
+
+ // Assert
+
+ issue.IsClosed.ShouldBeFalse();
+ issue.CloseDate.ShouldBeNull();
+}
+
+[Fact]
+public void Should_Not_Allow_To_ReOpen_A_Locked_Issue()
+{
+ // Arrange
+
+ var issue = new Issue();
+ issue.Close();
+ issue.IsLocked = true;
+
+ // Act & Assert
+
+ Assert.Throws(() =>
+ {
+ issue.Open();
+ });
+}
+````
+
+`Assert.Throws` 检查执行的代码是否匹配引发的异常.
+
+> 有关这些库的更多信息, 请参阅xUnit & Shoudly的文档.
+
+### 具有依赖项的类
+
+如果你的服务中有依赖项, 并且你想对该服务进行单元测试, 那么你需要模拟这些依赖项.
+
+#### 示例: 测试领域服务
+
+假设你有一个`IssueManager` [领域服务](Domain-Services.md), 定义如下:
+
+````csharp
+using System;
+using System.Threading.Tasks;
+using Volo.Abp;
+using Volo.Abp.Domain.Services;
+
+namespace MyProject.Issues
+{
+ public class IssueManager : DomainService
+ {
+ public const int MaxAllowedOpenIssueCountForAUser = 3;
+
+ private readonly IIssueRepository _issueRepository;
+
+ public IssueManager(IIssueRepository issueRepository)
+ {
+ _issueRepository = issueRepository;
+ }
+
+ public async Task AssignToUserAsync(Issue issue, Guid userId)
+ {
+ var issueCount = await _issueRepository.GetIssueCountOfUserAsync(userId);
+
+ if (issueCount >= MaxAllowedOpenIssueCountForAUser)
+ {
+ throw new BusinessException(
+ code: "IM:00392",
+ message: $"You can not assign more" +
+ $"than {MaxAllowedOpenIssueCountForAUser} issues to a user!"
+ );
+ }
+
+ issue.AssignedUserId = userId;
+ }
+ }
+}
+````
+
+`IssueManager`依赖于`IssueRepository`服务, 在本例中将模拟该服务.
+
+**业务逻辑**: 示例`AssignToUserAsync`不允许向用户分配超过3个issue (`MaxAllowedOpenIssueCountForAUser`常量). 在这种情况下, 如果要分配issue, 首先需要取消现有issue的分配.
+
+下面的测试用例给出一个有效的赋值:
+
+````csharp
+using System;
+using System.Threading.Tasks;
+using NSubstitute;
+using Shouldly;
+using Volo.Abp;
+using Xunit;
+
+namespace MyProject.Issues
+{
+ public class IssueManager_Tests
+ {
+ [Fact]
+ public async Task Should_Assign_An_Issue_To_A_User()
+ {
+ // Arrange
+
+ var userId = Guid.NewGuid();
+
+ var fakeRepo = Substitute.For();
+ fakeRepo.GetIssueCountOfUserAsync(userId).Returns(1);
+
+ var issueManager = new IssueManager(fakeRepo);
+
+ var issue = new Issue();
+
+ // Act
+
+ await issueManager.AssignToUserAsync(issue, userId);
+
+ //Assert
+
+ issue.AssignedUserId.ShouldBe(userId);
+ await fakeRepo.Received(1).GetIssueCountOfUserAsync(userId);
+ }
+ }
+}
+````
+
+* `Substitute.For` 创建一个模拟(假)对象, 该对象被传递到`IssueManager`构造函数中.
+* `fakeRepo.GetIssueCountOfUserAsync(userId).Returns(1)` 确保仓储中的`GetIssueContofuseRasync`方法返回`1`.
+* `issueManager.AssignToUserAsync` 不会引发任何异常, 因为仓储统计当前分配的issue数量并且返回`1`.
+* `issue.AssignedUserId.ShouldBe(userId);` 行检查`AssignedUserId`的值是否正确.
+* `await fakeRepo.Received(1).GetIssueCountOfUserAsync(userId);` 检查 `IssueManager` 实际只调用了 `GetIssueCountOfUserAsync` 方法一次.
+
+让我们添加第二个测试, 看看它是否能阻止将issue分配给超过分配数量的用户:
+
+````csharp
+[Fact]
+public async Task Should_Not_Allow_To_Assign_Issues_Over_The_Limit()
+{
+ // Arrange
+
+ var userId = Guid.NewGuid();
+
+ var fakeRepo = Substitute.For();
+ fakeRepo
+ .GetIssueCountOfUserAsync(userId)
+ .Returns(IssueManager.MaxAllowedOpenIssueCountForAUser);
+
+ var issueManager = new IssueManager(fakeRepo);
+
+ // Act & Assert
+
+ var issue = new Issue();
+
+ await Assert.ThrowsAsync(async () =>
+ {
+ await issueManager.AssignToUserAsync(issue, userId);
+ });
+
+ issue.AssignedUserId.ShouldBeNull();
+ await fakeRepo.Received(1).GetIssueCountOfUserAsync(userId);
+}
+````
+
+> 有关模拟的更多信息, 请参阅[NSubstitute](https://nsubstitute.github.io/)文档.
+
+模拟单个依赖项相对容易. 但是, 当依赖关系增长时, 设置测试对象和模拟所有依赖关系变得越来越困难. 请参阅不需要模拟依赖项的*Integration Tests*部分.
+
+### 提示: 共享测试类构造函数
+
+[xUnit](https://xunit.net/) 为每个测试方法创建一个**新测试类实例**(本例中为`IssueManager_Tests`). 因此, 你可以将一些*Arrange*代码移动到构造函数中, 以减少代码重复. 构造函数将针对每个测试用例执行, 并且不会相互影响, 即使它们是并行工作.
+
+**示例: 重构`IssueManager_Tests`以减少代码重复**
+
+````csharp
+using System;
+using System.Threading.Tasks;
+using NSubstitute;
+using Shouldly;
+using Volo.Abp;
+using Xunit;
+
+namespace MyProject.Issues
+{
+ public class IssueManager_Tests
+ {
+ private readonly Guid _userId;
+ private readonly IIssueRepository _fakeRepo;
+ private readonly IssueManager _issueManager;
+ private readonly Issue _issue;
+
+ public IssueManager_Tests()
+ {
+ _userId = Guid.NewGuid();
+ _fakeRepo = Substitute.For();
+ _issueManager = new IssueManager(_fakeRepo);
+ _issue = new Issue();
+ }
+
+ [Fact]
+ public async Task Should_Assign_An_Issue_To_A_User()
+ {
+ // Arrange
+ _fakeRepo.GetIssueCountOfUserAsync(_userId).Returns(1);
+
+ // Act
+ await _issueManager.AssignToUserAsync(_issue, _userId);
+
+ //Assert
+ _issue.AssignedUserId.ShouldBe(_userId);
+ await _fakeRepo.Received(1).GetIssueCountOfUserAsync(_userId);
+ }
+
+ [Fact]
+ public async Task Should_Not_Allow_To_Assign_Issues_Over_The_Limit()
+ {
+ // Arrange
+ _fakeRepo
+ .GetIssueCountOfUserAsync(_userId)
+ .Returns(IssueManager.MaxAllowedOpenIssueCountForAUser);
+
+ // Act & Assert
+ await Assert.ThrowsAsync(async () =>
+ {
+ await _issueManager.AssignToUserAsync(_issue, _userId);
+ });
+
+ _issue.AssignedUserId.ShouldBeNull();
+ await _fakeRepo.Received(1).GetIssueCountOfUserAsync(_userId);
+ }
+ }
+}
+````
+
+> 保持测试代码整洁, 以创建可维护的测试组件.
+
+## 集成测试
+
+> 你还可以按照[Web应用程序开发教程](Tutorials/Part-1.md)学习开发全栈应用程序, 包括集成测试.
+
+### 集成测试基础
+
+ABP为编写集成测试提供了完整的基础设施. 所有ABP基础设施和服务都将在你的测试中执行. 应用程序启动模板附带了为你预先配置的必要基础设施;
+
+#### 数据库
+
+启动模板使用EF Core配置**内存中的SQLite**数据库(对于MongoDB, 它使用[Mongo2Go](https://github.com/Mongo2Go/Mongo2Go)). 因此, 所有配置和查询都是针对真实数据库执行的, 你甚至可以测试数据库事务.
+
+使用内存中的SQLite数据库有两个主要优点:
+
+* 它比外部DBMS更快.
+* 它会为每个测试用例创建一个**新的数据库**, 这样测试就不会相互影响.
+
+> **提示**: 不要将EF Core的内存数据库用于高级集成测试. 它不是一个真正的DBMS, 在细节上有很多不同. 例如, 它不支持事务和回滚场景, 因此无法真正测试失败的场景. 另一方面, 内存中的SQLite是一个真正的DBMS, 支持SQL数据库的基本功能.
+
+### 种子数据
+
+针对空数据库编写测试是不现实的. 在大多数情况下, 需要在数据库中保存一些初始数据. 例如, 如果你编写了一个查询、更新和删除产品的测试类, 那么在执行测试用例之前, 在数据库中有一些产品数据会很有帮助.
+
+ABP的[种子数据](Data-Seeding.md)系统是一种强大的初始化数据的方法. 应用程序启动模板在`.TestBase`项目中有一个*YourProject*TestDataSeedContributor类. 你可以在其中添加, 以获得可用于每个测试方法的初始数据.
+
+**示例: 创建一些Issue作为种子数据**
+
+````csharp
+using System.Threading.Tasks;
+using MyProject.Issues;
+using Volo.Abp.Data;
+using Volo.Abp.DependencyInjection;
+
+namespace MyProject
+{
+ public class MyProjectTestDataSeedContributor
+ : IDataSeedContributor, ITransientDependency
+ {
+ private readonly IIssueRepository _issueRepository;
+
+ public MyProjectTestDataSeedContributor(IIssueRepository issueRepository)
+ {
+ _issueRepository = issueRepository;
+ }
+
+ public async Task SeedAsync(DataSeedContext context)
+ {
+ await _issueRepository.InsertAsync(
+ new Issue
+ {
+ Title = "Test issue one",
+ Description = "Test issue one description",
+ AssignedUserId = TestData.User1Id
+ });
+
+ await _issueRepository.InsertAsync(
+ new Issue
+ {
+ Title = "Test issue two",
+ Description = "Test issue two description",
+ AssignedUserId = TestData.User1Id
+ });
+
+ await _issueRepository.InsertAsync(
+ new Issue
+ {
+ Title = "Test issue three",
+ Description = "Test issue three description",
+ AssignedUserId = TestData.User1Id
+ });
+
+ await _issueRepository.InsertAsync(
+ new Issue
+ {
+ Title = "Test issue four",
+ Description = "Test issue four description",
+ AssignedUserId = TestData.User2Id
+ });
+ }
+ }
+}
+````
+
+还创建了一个静态类来存储用户的 `Id`:
+
+````csharp
+using System;
+
+namespace MyProject
+{
+ public static class TestData
+ {
+ public static Guid User1Id = Guid.Parse("41951813-5CF9-4204-8B18-CD765DBCBC9B");
+ public static Guid User2Id = Guid.Parse("2DAB4460-C21B-4925-BF41-A52750A9B999");
+ }
+}
+````
+
+通过这种方式, 我们可以使用这些已知Issue和用户的`Id`来运行测试.
+
+### 示例: 测试领域服务
+
+`AbpIntegratedTest`类 (定义在[Volo.Abp.TestBase](https://www.nuget.org/packages/Volo.Abp.TestBase)) 用于编写集成到ABP框架的测试. `T`是用于设置和初始化应用程序的根模块的类型.
+
+应用程序启动模板在每个测试项目中都有基类, 因此你可以从这些基类派生, 以使其更简单.
+
+`IssueManager`测试将被重写成集成测试
+
+````csharp
+using System.Threading.Tasks;
+using Shouldly;
+using Volo.Abp;
+using Xunit;
+
+namespace MyProject.Issues
+{
+ public class IssueManager_Integration_Tests : MyProjectDomainTestBase
+ {
+ private readonly IssueManager _issueManager;
+ private readonly Issue _issue;
+
+ public IssueManager_Integration_Tests()
+ {
+ _issueManager = GetRequiredService();
+ _issue = new Issue
+ {
+ Title = "Test title",
+ Description = "Test description"
+ };
+ }
+
+ [Fact]
+ public async Task Should_Not_Allow_To_Assign_Issues_Over_The_Limit()
+ {
+ // Act & Assert
+ await Assert.ThrowsAsync(async () =>
+ {
+ await _issueManager.AssignToUserAsync(_issue, TestData.User1Id);
+ });
+
+ _issue.AssignedUserId.ShouldBeNull();
+ }
+
+ [Fact]
+ public async Task Should_Assign_An_Issue_To_A_User()
+ {
+ // Act
+ await _issueManager.AssignToUserAsync(_issue, TestData.User2Id);
+
+ //Assert
+ _issue.AssignedUserId.ShouldBe(TestData.User2Id);
+ }
+ }
+}
+````
+
+* 第一个测试方法将issue分配给User1, 其中User1已经分配了种子数据代码中的3个issue. 因此, 它抛出了一个`BusinessException`.
+* 第二种测试方法将issue分配给User2, User2只分配了一个issue. 因此, 该方法成功了.
+
+这个类通常位于`.Domain.Tests`项目中, 因为它测试位于`.Domain`项目中的类. 它派生自`MyProjectDomainTestBase`, 并已经为正确运行测试进行了配置.
+
+编写这样一个集成测试类非常简单. 另一个好处是, 在以后向`IssueManager`类添加另一个依赖项时, 不需要更改测试类.
+
+### 示例: 测试应用服务
+
+测试[应用服务](Application-Services.md)并没有太大的不同. 假设你已经创建了一个`IssueAppService`, 定义如下:
+
+````csharp
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Services;
+
+namespace MyProject.Issues
+{
+ public class IssueAppService : ApplicationService, IIssueAppService
+ {
+ private readonly IIssueRepository _issueRepository;
+
+ public IssueAppService(IIssueRepository issueRepository)
+ {
+ _issueRepository = issueRepository;
+ }
+
+ public async Task> GetListAsync()
+ {
+ var issues = await _issueRepository.GetListAsync();
+
+ return ObjectMapper.Map, List>(issues);
+ }
+ }
+}
+````
+
+*(假设你还定义了`IIssueAppService`和`IssueDto`, 并在`Issue`和`IssueDto`之间创建了[对象映射](Object-To-Object-Mapping.md))*
+
+现在, 你可以在`.Application.Tests`项目中编写一个测试类:
+
+````csharp
+using System.Threading.Tasks;
+using Shouldly;
+using Xunit;
+
+namespace MyProject.Issues
+{
+ public class IssueAppService_Tests : MyProjectApplicationTestBase
+ {
+ private readonly IIssueAppService _issueAppService;
+
+ public IssueAppService_Tests()
+ {
+ _issueAppService = GetRequiredService();
+ }
+
+ [Fact]
+ public async Task Should_Get_All_Issues()
+ {
+ //Act
+ var issueDtos = await _issueAppService.GetListAsync();
+
+ //Assert
+ issueDtos.Count.ShouldBeGreaterThan(0);
+ }
+ }
+}
+````
+
+就这么简单. 此测试方法测试的所有内容, 包括应用服务、EF Core映射、对象到对象映射和仓储实现. 通过这种方式, 你可以完全测试解决方案的应用层和领域层.
+
+### 处理集成测试中的工作单元
+
+ABP的[工作单元](Unit-Of-Work.md)系统控制应用程序中的数据库连接和事务管理. 它可以在你编写应用程序代码时无缝工作, 因此你可能没有意识到它.
+
+在ABP框架中, 所有数据库操作都必须在一个工作单元作用域内执行. 当你测试[应用服务](Application-Services.md)方法时, 工作单元的作用域将是应用服务方法的作用域. 如果你正在测试[仓储](Repositories.md)方法, 那么工作单元作用域将是你的仓储方法的作用域.
+
+在某些情况下, 你可能需要手动控制工作单元作用域. 可以考虑下面的测试方法:
+
+````csharp
+public class IssueRepository_Tests : MyProjectDomainTestBase
+{
+ private readonly IRepository _issueRepository;
+
+ public IssueRepository_Tests()
+ {
+ _issueRepository = GetRequiredService>();
+ }
+
+ public async Task Should_Query_By_Title()
+ {
+ IQueryable queryable = await _issueRepository.GetQueryableAsync();
+ var issue = queryable.FirstOrDefaultAsync(i => i.Title == "My issue title");
+ issue.ShouldNotBeNull();
+ }
+}
+````
+
+我们正在使用`_issueRepository.GetQueryableAsync`获取`IQueryable` 对象. 然后, 我们使用`FirstOrDefaultAsync`方法按标题查询issue. 此时执行数据库查询, 你将会得到一个异常, 表明没有起作用的工作单元.
+
+要使该测试正常工作, 你应该手动启动工作单元作用域, 如下所示:
+
+````csharp
+public class IssueRepository_Tests : MyProjectDomainTestBase
+{
+ private readonly IRepository _issueRepository;
+ private readonly IUnitOfWorkManager _unitOfWorkManager;
+
+ public IssueRepository_Tests()
+ {
+ _issueRepository = GetRequiredService>();
+ _unitOfWorkManager = GetRequiredService();
+ }
+
+ public async Task Should_Query_By_Title()
+ {
+ using (var uow = _unitOfWorkManager.Begin())
+ {
+ IQueryable queryable = await _issueRepository.GetQueryableAsync();
+ var issue = queryable.FirstOrDefaultAsync(i => i.Title == "My issue title");
+ issue.ShouldNotBeNull();
+ await uow.CompleteAsync();
+ }
+ }
+}
+````
+
+我们已经使用了`IUnitOfWorkManager`服务来创建一个工作单元作用域, 然后在该作用域内调用了`FirstOrDefaultAsync`方法, 所以不再有问题了.
+
+> 请注意, 我们测试了`FirstOrDefaultAsync`来演示工作单元的问题. 作为一个好的标准, 编写自己的代码.
+
+### 使用DbContext
+
+在某些情况下, 你可能希望使用Entity Framework的`DbContext`对象来执行测试方法中的数据库操作. 在这种情况下, 可以使用`IDbContextProvider`服务在工作单元内获取`DbContext`实例.
+
+下面的示例展示了如何在测试方法中创建`DbContext`对象:
+
+````csharp
+public class MyDbContext_Tests : MyProjectDomainTestBase
+{
+ private readonly IDbContextProvider _dbContextProvider;
+ private readonly IUnitOfWorkManager _unitOfWorkManager;
+
+ public IssueRepository_Tests()
+ {
+ _dbContextProvider = GetRequiredService>();
+ _unitOfWorkManager = GetRequiredService();
+ }
+
+ public async Task Should_Query_By_Title()
+ {
+ using (var uow = _unitOfWorkManager.Begin())
+ {
+ var dbContext = await _dbContextProvider.GetDbContextAsync();
+ var issue = await dbContext.Issues.FirstOrDefaultAsync(i => i.Title == "My issue title");
+ issue.ShouldNotBeNull();
+ await uow.CompleteAsync();
+ }
+ }
+}
+````
+
+就像我们在*集成测试中处理工作单元*一节中所做的那样, 我们应该在起作用的工作单元内执行`DbContext`操作.
+
+对于[MongoDB](MongoDB.md), 你可以使用`IMongoDbContextProvider`服务获取`DbContext`对象, 并在测试方法中直接使用MongoDB APIs.
+
+## 用户界面测试
+
+一般来说, 有两种类型的UI测试:
+
+### 非可视化测试
+
+此类测试完全取决于UI框架的选择:
+
+* 对于MVC / Razor页面UI, 通常向服务器发出请求, 获取HTML, 并测试返回的结果中是否存在一些预期的DOM元素.
+* Angular有自己的基础设施和实践来测试组件、视图和服务.
+
+请参阅以下文档以了解非可视化UI测试:
+
+* [Testing in ASP.NET Core MVC / Razor Pages](UI/AspNetCore/Testing.md)
+* [Testing in Angular](UI/Angular/Testing.md)
+* [Testing in Blazor](UI/Blazor/Testing.md)
+
+### 可视化测试
+
+与真实用户一样, 可视化测试用于与应用程序UI交互. 它全面测试应用程序, 包括页面和组件的外观.
+
+可视化UI测试超出了ABP框架的范围. 行业中有很多工具(比如[Selenium](https://www.selenium.dev/))可以用来测试应用程序的UI.
diff --git a/docs/zh-Hans/UI/Angular/Testing.md b/docs/zh-Hans/UI/Angular/Testing.md
new file mode 100644
index 0000000000..c176d82247
--- /dev/null
+++ b/docs/zh-Hans/UI/Angular/Testing.md
@@ -0,0 +1,380 @@
+# Angular UI 单元测试
+
+ABP Angular UI的测试与其他Angular应用程序一样. 所以, [这里的指南](https://angular.io/guide/testing)也适用于ABP. 也就是说, 我们想指出一些**特定于ABP Angular应用程序的单元测试内容**.
+
+## 设置
+
+在Angular中, 单元测试默认使用[Karma](https://karma-runner.github.io/)和[Jasmine](https://jasmine.github.io). 虽然我们更喜欢Jest, 但我们选择不偏离这些默认设置, 因此**你下载的应用程序模板将预先配置Karma和Jasmine**. 你可以在根目录中的 _karma.conf.js_ 文件中找到Karma配置. 你什么都不用做. 添加一个spec文件并运行`npm test`即可.
+
+## 基础
+
+简化版的spec文件如下所示:
+
+```js
+import { CoreTestingModule } from "@abp/ng.core/testing";
+import { ThemeBasicTestingModule } from "@abp/ng.theme.basic/testing";
+import { ThemeSharedTestingModule } from "@abp/ng.theme.shared/testing";
+import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing";
+import { NgxValidateCoreModule } from "@ngx-validate/core";
+import { MyComponent } from "./my.component";
+
+describe("MyComponent", () => {
+ let fixture: ComponentFixture;
+
+ beforeEach(
+ waitForAsync(() => {
+ TestBed.configureTestingModule({
+ declarations: [MyComponent],
+ imports: [
+ CoreTestingModule.withConfig(),
+ ThemeSharedTestingModule.withConfig(),
+ ThemeBasicTestingModule.withConfig(),
+ NgxValidateCoreModule,
+ ],
+ providers: [
+ /* mock providers here */
+ ],
+ }).compileComponents();
+ })
+ );
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(MyComponent);
+ fixture.detectChanges();
+ });
+
+ it("should be initiated", () => {
+ expect(fixture.componentInstance).toBeTruthy();
+ });
+});
+```
+
+如果你看一下导入内容, 你会注意到我们已经准备了一些测试模块来取代内置的ABP模块. 这对于模拟某些特性是必要的, 否则这些特性会破坏你的测试. 请记住**使用测试模块**并**调用其`withConfig`静态方法**.
+
+## 提示
+
+### Angular测试库
+
+虽然你可以使用Angular TestBed测试代码, 但你可以找到一个好的替代品[Angular测试库](https://testing-library.com/docs/angular-testing-library/intro).
+
+上面的简单示例可以用Angular测试库编写, 如下所示:
+
+```js
+import { CoreTestingModule } from "@abp/ng.core/testing";
+import { ThemeBasicTestingModule } from "@abp/ng.theme.basic/testing";
+import { ThemeSharedTestingModule } from "@abp/ng.theme.shared/testing";
+import { ComponentFixture } from "@angular/core/testing";
+import { NgxValidateCoreModule } from "@ngx-validate/core";
+import { render } from "@testing-library/angular";
+import { MyComponent } from "./my.component";
+
+describe("MyComponent", () => {
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ const result = await render(MyComponent, {
+ imports: [
+ CoreTestingModule.withConfig(),
+ ThemeSharedTestingModule.withConfig(),
+ ThemeBasicTestingModule.withConfig(),
+ NgxValidateCoreModule,
+ ],
+ providers: [
+ /* mock providers here */
+ ],
+ });
+
+ fixture = result.fixture;
+ });
+
+ it("should be initiated", () => {
+ expect(fixture.componentInstance).toBeTruthy();
+ });
+});
+```
+
+正如你所见, 二者非常相似. 当我们使用查询和触发事件时, 真正的区别就显现出来了.
+
+```js
+// other imports
+import { getByLabelText, screen } from "@testing-library/angular";
+import userEvent from "@testing-library/user-event";
+
+describe("MyComponent", () => {
+ beforeEach(/* removed for sake of brevity */);
+
+ it("should display advanced filters", () => {
+ const filters = screen.getByTestId("author-filters");
+ const nameInput = getByLabelText(filters, /name/i) as HTMLInputElement;
+ expect(nameInput.offsetWidth).toBe(0);
+
+ const advancedFiltersBtn = screen.getByRole("link", { name: /advanced/i });
+ userEvent.click(advancedFiltersBtn);
+
+ expect(nameInput.offsetWidth).toBeGreaterThan(0);
+
+ userEvent.type(nameInput, "fooo{backspace}");
+ expect(nameInput.value).toBe("foo");
+ });
+});
+```
+
+**Angular测试库中的查询遵循可维护测试**, 用户事件库提供了与DOM的**类人交互**, 并且该库通常有**清晰的API**简化组件测试. 下面提供一些有用的链接:
+
+- [查询](https://testing-library.com/docs/dom-testing-library/api-queries)
+- [用户事件](https://testing-library.com/docs/ecosystem-user-event)
+- [范例](https://github.com/testing-library/angular-testing-library/tree/main/apps/example-app/src/app/examples)
+
+### 在每个Spec之后清除DOM
+
+需要记住的一点是, Karma在真实的浏览器实例中运行测试. 这意味着, 你将能够看到测试代码的结果, 但也会遇到与文档正文连接的组件的问题, 这些组件可能无法在每次测试后都清除, 即使你配置了Karma也一样无法清除.
+
+我们准备了一个简单的函数, 可以在每次测试后清除所有剩余的DOM元素.
+
+```js
+// other imports
+import { clearPage } from "@abp/ng.core/testing";
+
+describe("MyComponent", () => {
+ let fixture: ComponentFixture;
+
+ afterEach(() => clearPage(fixture));
+
+ beforeEach(async () => {
+ const result = await render(MyComponent, {
+ /* removed for sake of brevity */
+ });
+ fixture = result.fixture;
+ });
+
+ // specs here
+});
+```
+
+请确保你使用它, 否则Karma将无法删除对话框, 并且你将有多个模态对话框、确认框等的副本.
+
+### 等待
+
+一些组件, 特别是在检测周期之外工作的模态对话框. 换句话说, 你无法在打开这些组件后立即访问这些组件插入的DOM元素. 同样, 插入的元素在关闭时也不会立即销毁.
+
+为此, 我们准备了一个`wait`函数.
+
+```js
+// other imports
+import { wait } from "@abp/ng.core/testing";
+
+describe("MyComponent", () => {
+ beforeEach(/* removed for sake of brevity */);
+
+ it("should open a modal", async () => {
+ const openModalBtn = screen.getByRole("button", { name: "Open Modal" });
+ userEvent.click(openModalBtn);
+
+ await wait(fixture);
+
+ const modal = screen.getByRole("dialog");
+
+ expect(modal).toBeTruthy();
+
+ /* wait again after closing the modal */
+ });
+});
+```
+
+`wait`函数接受第二个参数, 即超时(默认值为`0`). 但是尽量不要使用它. 使用大于`0`的超时通常表明某些不正确事情发生了.
+
+## 测试示例
+
+下面是一个测试示例. 它并没有涵盖所有内容, 但却能够对测试有一个更好的了解.
+
+```js
+import { clearPage, CoreTestingModule, wait } from "@abp/ng.core/testing";
+import { ThemeBasicTestingModule } from "@abp/ng.theme.basic/testing";
+import { ThemeSharedTestingModule } from "@abp/ng.theme.shared/testing";
+import { ComponentFixture } from "@angular/core/testing";
+import {
+ NgbCollapseModule,
+ NgbDatepickerModule,
+ NgbDropdownModule,
+} from "@ng-bootstrap/ng-bootstrap";
+import { NgxValidateCoreModule } from "@ngx-validate/core";
+import { CountryService } from "@proxy/countries";
+import {
+ findByText,
+ getByLabelText,
+ getByRole,
+ getByText,
+ queryByRole,
+ render,
+ screen,
+} from "@testing-library/angular";
+import userEvent from "@testing-library/user-event";
+import { BehaviorSubject, of } from "rxjs";
+import { CountryComponent } from "./country.component";
+
+const list$ = new BehaviorSubject({
+ items: [{ id: "ID_US", name: "United States of America" }],
+ totalCount: 1,
+});
+
+describe("Country", () => {
+ let fixture: ComponentFixture;
+
+ afterEach(() => clearPage(fixture));
+
+ beforeEach(async () => {
+ const result = await render(CountryComponent, {
+ imports: [
+ CoreTestingModule.withConfig(),
+ ThemeSharedTestingModule.withConfig(),
+ ThemeBasicTestingModule.withConfig(),
+ NgxValidateCoreModule,
+ NgbCollapseModule,
+ NgbDatepickerModule,
+ NgbDropdownModule,
+ ],
+ providers: [
+ {
+ provide: CountryService,
+ useValue: {
+ getList: () => list$,
+ },
+ },
+ ],
+ });
+
+ fixture = result.fixture;
+ });
+
+ it("should display advanced filters", () => {
+ const filters = screen.getByTestId("country-filters");
+ const nameInput = getByLabelText(filters, /name/i) as HTMLInputElement;
+ expect(nameInput.offsetWidth).toBe(0);
+
+ const advancedFiltersBtn = screen.getByRole("link", { name: /advanced/i });
+ userEvent.click(advancedFiltersBtn);
+
+ expect(nameInput.offsetWidth).toBeGreaterThan(0);
+
+ userEvent.type(nameInput, "fooo{backspace}");
+ expect(nameInput.value).toBe("foo");
+
+ userEvent.click(advancedFiltersBtn);
+ expect(nameInput.offsetWidth).toBe(0);
+ });
+
+ it("should have a heading", () => {
+ const heading = screen.getByRole("heading", { name: "Countries" });
+ expect(heading).toBeTruthy();
+ });
+
+ it("should render list in table", async () => {
+ const table = await screen.findByTestId("country-table");
+
+ const name = getByText(table, "United States of America");
+ expect(name).toBeTruthy();
+ });
+
+ it("should display edit modal", async () => {
+ const actionsBtn = screen.queryByRole("button", { name: /actions/i });
+ userEvent.click(actionsBtn);
+
+ const editBtn = screen.getByRole("button", { name: /edit/i });
+ userEvent.click(editBtn);
+
+ await wait(fixture);
+
+ const modal = screen.getByRole("dialog");
+ const modalHeading = queryByRole(modal, "heading", { name: /edit/i });
+ expect(modalHeading).toBeTruthy();
+
+ const closeBtn = getByText(modal, "×");
+ userEvent.click(closeBtn);
+
+ await wait(fixture);
+
+ expect(screen.queryByRole("dialog")).toBeFalsy();
+ });
+
+ it("should display create modal", async () => {
+ const newBtn = screen.getByRole("button", { name: /new/i });
+ userEvent.click(newBtn);
+
+ await wait(fixture);
+
+ const modal = screen.getByRole("dialog");
+ const modalHeading = queryByRole(modal, "heading", { name: /new/i });
+
+ expect(modalHeading).toBeTruthy();
+ });
+
+ it("should validate required name field", async () => {
+ const newBtn = screen.getByRole("button", { name: /new/i });
+ userEvent.click(newBtn);
+
+ await wait(fixture);
+
+ const modal = screen.getByRole("dialog");
+ const nameInput = getByRole(modal, "textbox", {
+ name: /^name/i,
+ }) as HTMLInputElement;
+
+ userEvent.type(nameInput, "x");
+ userEvent.type(nameInput, "{backspace}");
+
+ const nameError = await findByText(modal, /required/i);
+ expect(nameError).toBeTruthy();
+ });
+
+ it("should delete a country", () => {
+ const getSpy = spyOn(fixture.componentInstance.list, "get");
+ const deleteSpy = jasmine.createSpy().and.returnValue(of(null));
+ fixture.componentInstance.service.delete = deleteSpy;
+
+ const actionsBtn = screen.queryByRole("button", { name: /actions/i });
+ userEvent.click(actionsBtn);
+
+ const deleteBtn = screen.getByRole("button", { name: /delete/i });
+ userEvent.click(deleteBtn);
+
+ const confirmText = screen.getByText("AreYouSure");
+ expect(confirmText).toBeTruthy();
+
+ const confirmBtn = screen.getByRole("button", { name: "Yes" });
+ userEvent.click(confirmBtn);
+
+ expect(deleteSpy).toHaveBeenCalledWith(list$.value.items[0].id);
+ expect(getSpy).toHaveBeenCalledTimes(1);
+ });
+});
+```
+
+## CI配置
+
+你的CI环境需要不同的配置. 要为单元测试设置新的配置, 请在测试项目中找到 _angular.json_ 文件, 或者如下所示添加一个:
+
+```json
+// angular.json
+
+"test": {
+ "builder": "@angular-devkit/build-angular:karma",
+ "options": { /* several options here */ },
+ "configurations": {
+ "production": {
+ "karmaConfig": "karma.conf.prod.js"
+ }
+ }
+}
+```
+
+现在你可以复制 _karma.conf.js_ 作为 _karma.conf.prod.js_ 并在其中使用你喜欢的任何配置. 请查看[Karma配置文档](http://karma-runner.github.io/5.2/config/configuration-file.html)配置选项.
+
+最后, 不要忘记使用以下命令运行CI测试:
+
+```sh
+npm test -- --prod
+```
+
+## 另请参阅
+
+- [ABP Community Video - Unit Testing with the Angular UI](https://community.abp.io/articles/unit-testing-with-the-angular-ui-p4l550q3)
diff --git a/docs/zh-Hans/UI/AspNetCore/Testing.md b/docs/zh-Hans/UI/AspNetCore/Testing.md
new file mode 100644
index 0000000000..e5b09353fb
--- /dev/null
+++ b/docs/zh-Hans/UI/AspNetCore/Testing.md
@@ -0,0 +1,220 @@
+# ASP.NET Core MVC / Razor Pages: 测试
+
+> 你可以参考[ASP.NET Core集成测试文档](https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests)了解ASP.NET Core集成测试的详细内容. 本文档解释了ABP框架提供的附加测试基础设施.
+
+## 应用程序启动模板
+
+应用程序启动模板的`.Web`项目其中包含应用程序的UI视图/页面/组件, 并提供`.Web.Tests`项目来测试这些内容.
+
+
+
+## 测试Razor页面
+
+假设你已经创建了一个名为`Issues.cshtml`的Razor页面, 包含以下内容;
+
+**Issues.cshtml.cs**
+
+````csharp
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+using MyProject.Issues;
+
+namespace MyProject.Web.Pages
+{
+ public class IssuesModel : PageModel
+ {
+ public List Issues { get; set; }
+
+ private readonly IIssueAppService _issueAppService;
+
+ public IssuesModel(IIssueAppService issueAppService)
+ {
+ _issueAppService = issueAppService;
+ }
+
+ public async Task OnGetAsync()
+ {
+ Issues = await _issueAppService.GetListAsync();
+ }
+ }
+}
+````
+
+**Issues.cshtml**
+
+````html
+@page
+@model MyProject.Web.Pages.IssuesModel
+