@ -0,0 +1,170 @@ |
|||||
|
# VoloDocs |
||||
|
|
||||
|
## What is VoloDocs? |
||||
|
|
||||
|
VoloDocs is a cross-platform web application that allows you to easily create beautiful documentation and build developer communities. It simplifies software documentation with the help of GitHub integration. You use the power of GitHub for versioning, hosting of your docs. You let your users to edit a document. |
||||
|
|
||||
|
## Main Features |
||||
|
|
||||
|
- Serves documents from your GitHub repository. |
||||
|
- Supports Markdown / HTML document formatting. |
||||
|
- Supports versioning (integrated to GitHub releases). |
||||
|
- Supports multiple projects. |
||||
|
- Allows users to edit a document on GitHub. |
||||
|
- Cross-platform; deployable to Windows / Linux / macOS. |
||||
|
|
||||
|
## GitHub Repository |
||||
|
|
||||
|
It's free & open-source. You can browse VoloDocs source-code and contribute on GitHub: |
||||
|
|
||||
|
https://github.com/abpframework/abp/tree/master/modules/docs |
||||
|
|
||||
|
## Download |
||||
|
|
||||
|
You can download the VoloDocs release from the following link: |
||||
|
|
||||
|
http://apps.abp.io/VoloDocs/VoloDocs.zip *(will be ready soon...)* |
||||
|
|
||||
|
## Folder Structure |
||||
|
|
||||
|
When you extract the `VoloDocs.zip` file, you will see a `Web` folder and a `Migrator` folder. `Web` folder contains the website files and `Migrator` contains the application to build your database. Before publishing your website, you need to create a new database or update your existing database to the latest. If this is the first time you install VoloDocs, `Migrator` will create a new database for you, otherwise it updates to the latest version. The only setting you need to configure, is the `ConnectionString` which is located in the `appsettings.json` file. See the next section to learn how to configure your VoloDocs application. |
||||
|
|
||||
|
## Steps by Step Deployment |
||||
|
|
||||
|
- ### Database Migration |
||||
|
|
||||
|
To update your existing database or create your initial database, go to `Migrator` folder in your VoloDocs directory. |
||||
|
|
||||
|
Open `appsettings.json` in your text editor and set your database connection string. If you don't know how to write the connection string for your database system, you can check out https://www.connectionstrings.com/. |
||||
|
|
||||
|
After you set your connection string, run `Migrate.bat` for Windows platform and `VoloDocs.Migrator` for other operating systems. That's it now configure your website. |
||||
|
|
||||
|
- ### Configuring Website |
||||
|
|
||||
|
Go to `Web` folder in your VoloDocs directory. Open `appsettings.json` in your text editor. Set your connection string (same as in the `Migrator`'s `appsettings.json`). Set `title` of your website. This will be written on the left-upper corner of your website. That's it! Now you can publish your website. |
||||
|
|
||||
|
If you want to run |
||||
|
|
||||
|
- ### Publishing Website |
||||
|
|
||||
|
In the previous step, you created or updated your database. Ensure that your database exists on the specified connection string. |
||||
|
|
||||
|
- #### Publishing to IIS |
||||
|
|
||||
|
- Move `Web` folder to your `wwwroot ` folder. |
||||
|
- Rename `Web` folder to `VoloDocs` (Now you have `C:\inetpub\wwwroot\VoloDocs`). |
||||
|
- The `VoloDocs` application pool is being created automatically. Open **Application Pools** and double click `VoloDocs` application pool and set |
||||
|
- **.NET CLR version**: `No Managed Code` |
||||
|
- **Managed pipeline mode**: `Integrated` |
||||
|
|
||||
|
 |
||||
|
|
||||
|
|
||||
|
|
||||
|
- If you get the below error, it means don't have the hosting bundle installed on the server. See [this document](https://docs.microsoft.com/aspnet/core/host-and-deploy/iis/#install-the-net-core-hosting-bundle) to learn how to install it or [download Hosting Bundle](https://www.microsoft.com/net/permalink/dotnetcore-current-windows-runtime-bundle-installer) and run on your server. |
||||
|
|
||||
|
``` |
||||
|
Handler "aspNetCore" has a bad module "AspNetCoreModuleV2" in its module list using IIS |
||||
|
``` |
||||
|
|
||||
|
- Further information about hosting VoloDocs check out [Microsoft's official document for hosting ASP.NET Core application on IIS](https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis). |
||||
|
|
||||
|
- #### Publishing to Azure |
||||
|
|
||||
|
Microsoft has a good document on how to deploy your ASP.NET Core web app to Azure App Service. We recommend you to read this document https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-dotnet. |
||||
|
|
||||
|
- #### Running the Application From Command Line |
||||
|
|
||||
|
Alternatively you can run the application from command line, navigate to `VoloDocs\Web` folder and run the below command in your command line for Windows: |
||||
|
|
||||
|
```powershell |
||||
|
dotnet VoloDocs.Web.dll |
||||
|
``` |
||||
|
|
||||
|
- ### First Run |
||||
|
|
||||
|
To start the website, navigate to your address (as configured in the previous section). |
||||
|
|
||||
|
When you first open the website, you need to create a project. |
||||
|
|
||||
|
#### Creating a Project |
||||
|
|
||||
|
Go to the following address to create project |
||||
|
|
||||
|
- `http://<yourwebsite>/Account/Login?returnUrl=/Docs/Admin/Projects` |
||||
|
|
||||
|
##### Default credentials |
||||
|
|
||||
|
To login the admin side, use the following credentials: |
||||
|
|
||||
|
* **Username**: `admin` |
||||
|
|
||||
|
* **Password**: `1q2w3E*` |
||||
|
|
||||
|
##### An example project definition |
||||
|
|
||||
|
Here's a sample project information that uses GitHub source. |
||||
|
|
||||
|
We will configure the VoloDocs to show ABP Framework's documentation that's stored in GitHub. |
||||
|
|
||||
|
Here's the link to ABP Framework GitHub docs folder: |
||||
|
|
||||
|
https://github.com/abpframework/abp/tree/master/docs/en |
||||
|
|
||||
|
|
||||
|
|
||||
|
* **Name**: `ABP Framework` |
||||
|
|
||||
|
* **Short name**: `abp` |
||||
|
|
||||
|
* **Format**: `markdown` |
||||
|
|
||||
|
* **Default document name**: `Index` |
||||
|
|
||||
|
* **Navigation document name**: `docs-nav.json` ([see the sample navigation](https://github.com/abpframework/abp/blob/master/docs/en/docs-nav.json)) |
||||
|
|
||||
|
* **Minimum version**: *leave empty* *(hides the previous versions)* |
||||
|
|
||||
|
* **Main web site URL**: `/` |
||||
|
|
||||
|
* **Latest version branch name**: leave empty () |
||||
|
|
||||
|
* **GitHub root URL**: `https://github.com/abpframework/abp/tree/{version}/docs/en/` |
||||
|
|
||||
|
* **GitHub access token**: [see how to retrieve GitHub access token](#retrieving-github-access-token) |
||||
|
|
||||
|
* **GitHub user agent**: [see how to learn your GitHub username](#learn-your-github-username) |
||||
|
|
||||
|
 |
||||
|
|
||||
|
##### Retrieving GitHub Access Token |
||||
|
|
||||
|
To create a personal access token in GitHub, you need to visit the **Settings** of the user account and under **Developer settings** you will find **Personal access tokens**. Select **Generate new token**, enter in a name as the Token description and enable the repo checkbox. Alternatively, to enter generate new token, browse to https://github.com/settings/tokens/new. |
||||
|
|
||||
|
###### Generate Token for Public Repositories |
||||
|
|
||||
|
To access public repositories, check `public_repo` under the `repo` section. This will enable VoloDocs to access your public GitHub repositories. Click `Generate Token` button on the bottom of the page. |
||||
|
|
||||
|
 |
||||
|
|
||||
|
###### Generate Token for Private Repositories |
||||
|
|
||||
|
To access public repositories, check all items under the `repo` section. This will enable VoloDocs to access your private GitHub repositories. Click `Generate Token` button on the bottom of the page. |
||||
|
|
||||
|
 |
||||
|
|
||||
|
###### Learn Your GitHub Username |
||||
|
|
||||
|
To learn your GitHub username, click on your profile picture on the top-right corner of the GitHub page. You will see your username right after the text "Signed in as ..." |
||||
|
|
||||
|
 |
||||
|
|
||||
|
|
||||
|
|
||||
|
After you save the project, go to root website address and you will see your documentation. |
||||
|
|
||||
|
`http://<yourwebsite>/documents` |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
@ -0,0 +1,26 @@ |
|||||
|
# Nightly Builds |
||||
|
|
||||
|
All framework & module packages are deployed to MyGet every night in weekdays. So, you can use or test the latest code without waiting the next release. |
||||
|
|
||||
|
## Configure Visual Studio |
||||
|
|
||||
|
> Requires Visual Studio 2017+ |
||||
|
|
||||
|
1. Go to `Tools > Options > NuGet Package Manager > Package Source`. |
||||
|
2. Click the green `+` icon. |
||||
|
3. Set `ABP Nightly` as *Name* and `https://www.myget.org/F/abp-nightly/api/v3/index.json` as the *Source* as shown below: |
||||
|
 |
||||
|
4. Click the `Update` button. |
||||
|
5. Click the `OK` button to save changes. |
||||
|
|
||||
|
## Install Package |
||||
|
|
||||
|
Now, you can install preview / nightly packages to your project from Nuget Browser or Package Manager Console. |
||||
|
|
||||
|
 |
||||
|
|
||||
|
1. In the nuget browser, select "Include prereleases". |
||||
|
2. Change package source to "All". |
||||
|
3. Search a package. You will see prereleases of the package formatted as `(VERSION)-preview(DATE)` (like *v0.16.0-preview20190401* in this sample). |
||||
|
4. You can click to the `Install` button to add package to your project. |
||||
|
|
||||
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 146 KiB |
|
After Width: | Height: | Size: 144 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
@ -0,0 +1,25 @@ |
|||||
|
# 每日构建 |
||||
|
|
||||
|
所有框架和模块包都每晚都部署到MyGet. 因此你可以使用或测试最新的代码,而无需等待下一个版本. |
||||
|
|
||||
|
## 在Visual Studio配置 |
||||
|
|
||||
|
> 需要Visual Studio 2017以上 |
||||
|
|
||||
|
1. 在VS中打开: `工具 > 选项 > NuGet 包管理器 > 程序包源` |
||||
|
2. 单击绿色的`+`图标 |
||||
|
3. 在底部输入名称(ABP Nightly)和并粘贴URL(`https://www.myget.org/F/abp-nightly/api/v3/index.json`)到源上. |
||||
|
 |
||||
|
3. 单击`更新`按钮 |
||||
|
4. 点击`确定`按钮保存 |
||||
|
|
||||
|
## 安装包 |
||||
|
|
||||
|
现在, 你可以从**管理NuGet包** 或 **程序包管理器控制台** 将预览/夜间程序包安装到你的项目中. |
||||
|
|
||||
|
 |
||||
|
|
||||
|
1. 在nuget浏览中,选择"包括预发行版". |
||||
|
2. 将包源更改为`全部`. |
||||
|
3. 搜索nuget包. 你将看到包的预发布格式为`(VERSION)-preview(DATE)` (如本示例中的**v0.16.0-preview20190401**). |
||||
|
4. 你可以单击`安装`按钮将包添加到项目中. |
||||
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 29 KiB |
@ -1,9 +1,11 @@ |
|||||
{ |
{ |
||||
"culture": "pt-BR", |
"culture": "pt-BR", |
||||
"texts": { |
"texts": { |
||||
"GivenTenantIsNotAvailable": "Tenant não está disponível: {0}", |
"GivenTenantIsNotAvailable": "Inquilino não está disponível: {0}", |
||||
"SwitchTenant": "Trocar tenant", |
"Tenant": "Inquilino", |
||||
|
"Switch": "trocar", |
||||
"Name": "Nome", |
"Name": "Nome", |
||||
"SwitchTenantHint": "Deixe o campo de nome em branco para alternar para o lado do host." |
"SwitchTenantHint": "Deixe o campo de nome em branco para alternar para o lado do host.", |
||||
|
"NotSelected": "Não selecionado" |
||||
} |
} |
||||
} |
} |
||||
@ -1,28 +0,0 @@ |
|||||
using System.Linq; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
using Volo.Abp.Security.Claims; |
|
||||
|
|
||||
namespace Volo.Abp.MultiTenancy |
|
||||
{ |
|
||||
public class CurrentClaimsPrincipalTenantResolveContributor : TenantResolveContributorBase |
|
||||
{ |
|
||||
public const string ContributorName = "CurrentClaims"; |
|
||||
|
|
||||
public override string Name => ContributorName; |
|
||||
|
|
||||
public override void Resolve(ITenantResolveContext context) |
|
||||
{ |
|
||||
var principal = context.ServiceProvider.GetRequiredService<ICurrentPrincipalAccessor>().Principal; |
|
||||
if (principal?.Identity?.IsAuthenticated != true) |
|
||||
{ |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
context.Handled = true; |
|
||||
context.TenantIdOrName = principal |
|
||||
.Claims |
|
||||
.FirstOrDefault(c => c.Type == AbpClaimTypes.TenantId) |
|
||||
?.Value; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,24 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
|
namespace Volo.Abp.MultiTenancy |
||||
|
{ |
||||
|
public class CurrentUserTenantResolveContributor : TenantResolveContributorBase |
||||
|
{ |
||||
|
public const string ContributorName = "CurrentUser"; |
||||
|
|
||||
|
public override string Name => ContributorName; |
||||
|
|
||||
|
public override void Resolve(ITenantResolveContext context) |
||||
|
{ |
||||
|
var currentUser = context.ServiceProvider.GetRequiredService<ICurrentUser>(); |
||||
|
if (currentUser.IsAuthenticated != true) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
context.Handled = true; |
||||
|
context.TenantIdOrName = currentUser.TenantId?.ToString(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,6 +1,7 @@ |
|||||
{ |
{ |
||||
"culture": "pt-BR", |
"culture": "pt-BR", |
||||
"texts": { |
"texts": { |
||||
"BirthDate": "Aniversário" |
"BirthDate": "Aniversário", |
||||
|
"Value1": "Valor Um" |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
{ |
||||
|
"culture": "zh-Hans", |
||||
|
"texts": { |
||||
|
"BirthDate": "生日", |
||||
|
"Value1": "Value One" |
||||
|
} |
||||
|
} |
||||
@ -1,6 +1,7 @@ |
|||||
{ |
{ |
||||
"culture": "en", |
"culture": "en", |
||||
"texts": { |
"texts": { |
||||
"USA": "United States of America" |
"USA": "United States of America", |
||||
|
"Brazil": "Brasil" |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
{ |
||||
|
"culture": "zh-Hans", |
||||
|
"texts": { |
||||
|
"USA": "美国", |
||||
|
"Brazil": "巴西" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
{ |
||||
|
"culture": "zh-Hans", |
||||
|
"texts": { |
||||
|
"ThisFieldIsRequired": "此字段是必填字段", |
||||
|
"MaxLenghtErrorMessage": "该字段最多可包含'{0}'个字符" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
{ |
||||
|
"culture": "zh-Hans", |
||||
|
"texts": { |
||||
|
"Hello <b>{0}</b>.": "你好 <b>{0}</b>.", |
||||
|
"Car": "汽车", |
||||
|
"CarPlural": "汽车", |
||||
|
"MaxLenghtErrorMessage": "此字段的长度最多为'{0}'个字符", |
||||
|
"Universe": "宇宙", |
||||
|
"FortyTwo": "四十二" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Volo.Abp.AuditLogging.EntityFrameworkCore |
||||
|
{ |
||||
|
public class AuditLogRepository_Tests : AuditLogRepository_Tests<AbpAuditLoggingEntityFrameworkCoreTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Volo.Abp.AuditLogging.MongoDB |
||||
|
{ |
||||
|
public class AuditLogRepository_Tests : AuditLogRepository_Tests<AbpAuditLoggingMongoDbTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,232 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Net; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Auditing; |
||||
|
using Volo.Abp.Guids; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Abp.AuditLogging |
||||
|
{ |
||||
|
public abstract class AuditLogRepository_Tests<TStartupModule> : AuditLoggingTestBase<TStartupModule> |
||||
|
where TStartupModule : IAbpModule |
||||
|
{ |
||||
|
protected IAuditLogRepository AuditLogRepository { get; } |
||||
|
protected IGuidGenerator GuidGenerator { get; } |
||||
|
|
||||
|
protected AuditLogRepository_Tests() |
||||
|
{ |
||||
|
AuditLogRepository = GetRequiredService<IAuditLogRepository>(); |
||||
|
GuidGenerator = GetRequiredService<IGuidGenerator>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetListAsync() |
||||
|
{ |
||||
|
// Arrange
|
||||
|
var userId = new Guid("4456fb0d-74cc-4807-9eee-23e551e6cb06"); |
||||
|
var userId2 = new Guid("4456fb0d-74cc-4807-9eee-23e551e6cb06"); |
||||
|
var ipAddress = "153.1.7.61"; |
||||
|
var firstComment = "first Comment"; |
||||
|
|
||||
|
var log1 = new AuditLogInfo |
||||
|
{ |
||||
|
UserId = userId, |
||||
|
ImpersonatorUserId = Guid.NewGuid(), |
||||
|
ImpersonatorTenantId = Guid.NewGuid(), |
||||
|
ExecutionTime = DateTime.Today, |
||||
|
ExecutionDuration = 42, |
||||
|
ClientIpAddress = ipAddress, |
||||
|
ClientName = "MyDesktop", |
||||
|
BrowserInfo = "Chrome", |
||||
|
Comments = new List<string> { firstComment, "Second Comment" }, |
||||
|
UserName = "Douglas", |
||||
|
EntityChanges = { |
||||
|
new EntityChangeInfo |
||||
|
{ |
||||
|
EntityId = Guid.NewGuid().ToString(), |
||||
|
EntityTypeFullName = "Volo.Abp.AuditLogging.TestEntity", |
||||
|
ChangeType = EntityChangeType.Created, |
||||
|
ChangeTime = DateTime.Now, |
||||
|
PropertyChanges = new List<EntityPropertyChangeInfo> |
||||
|
{ |
||||
|
new EntityPropertyChangeInfo |
||||
|
{ |
||||
|
PropertyTypeFullName = typeof(string).FullName, |
||||
|
PropertyName = "Name", |
||||
|
NewValue = "New value", |
||||
|
OriginalValue = null |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
new EntityChangeInfo |
||||
|
{ |
||||
|
EntityId = Guid.NewGuid().ToString(), |
||||
|
EntityTypeFullName = "Volo.Abp.AuditLogging.TestEntity", |
||||
|
ChangeType = EntityChangeType.Created, |
||||
|
ChangeTime = DateTime.Now, |
||||
|
PropertyChanges = new List<EntityPropertyChangeInfo> |
||||
|
{ |
||||
|
new EntityPropertyChangeInfo |
||||
|
{ |
||||
|
PropertyTypeFullName = typeof(string).FullName, |
||||
|
PropertyName = "Name", |
||||
|
NewValue = "New value", |
||||
|
OriginalValue = null |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
var log2 = new AuditLogInfo |
||||
|
{ |
||||
|
UserId = userId2, |
||||
|
ImpersonatorUserId = Guid.NewGuid(), |
||||
|
ImpersonatorTenantId = Guid.NewGuid(), |
||||
|
ExecutionTime = DateTime.Today, |
||||
|
ExecutionDuration = 42, |
||||
|
ClientIpAddress = ipAddress, |
||||
|
ClientName = "MyDesktop", |
||||
|
BrowserInfo = "Chrome", |
||||
|
Comments = new List<string> { firstComment, "Second Comment" }, |
||||
|
HttpStatusCode = (int?)HttpStatusCode.BadGateway, |
||||
|
EntityChanges = { |
||||
|
new EntityChangeInfo |
||||
|
{ |
||||
|
EntityId = Guid.NewGuid().ToString(), |
||||
|
EntityTypeFullName = "Volo.Abp.AuditLogging.TestEntity", |
||||
|
ChangeType = EntityChangeType.Created, |
||||
|
ChangeTime = DateTime.Now, |
||||
|
PropertyChanges = new List<EntityPropertyChangeInfo> |
||||
|
{ |
||||
|
new EntityPropertyChangeInfo |
||||
|
{ |
||||
|
PropertyTypeFullName = typeof(string).FullName, |
||||
|
PropertyName = "Name", |
||||
|
NewValue = "New value", |
||||
|
OriginalValue = null |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
AuditLogRepository.Insert(new AuditLog(GuidGenerator, log1)); |
||||
|
AuditLogRepository.Insert(new AuditLog(GuidGenerator, log2)); |
||||
|
|
||||
|
//Assert
|
||||
|
var logs = await AuditLogRepository.GetListAsync(); |
||||
|
logs.ShouldNotBeNull(); |
||||
|
logs.ShouldContain(x => x.UserId == userId); |
||||
|
logs.ShouldContain(x => x.UserId == userId2); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetCountAsync() |
||||
|
{ |
||||
|
// Arrange
|
||||
|
var userId = new Guid("4456fb0d-74cc-4807-9eee-23e551e6cb06"); |
||||
|
var userId2 = new Guid("4456fb0d-74cc-4807-9eee-23e551e6cb06"); |
||||
|
var ipAddress = "153.1.7.61"; |
||||
|
var firstComment = "first Comment"; |
||||
|
|
||||
|
var log1 = new AuditLogInfo |
||||
|
{ |
||||
|
UserId = userId, |
||||
|
ImpersonatorUserId = Guid.NewGuid(), |
||||
|
ImpersonatorTenantId = Guid.NewGuid(), |
||||
|
ExecutionTime = DateTime.Today, |
||||
|
ExecutionDuration = 42, |
||||
|
ClientIpAddress = ipAddress, |
||||
|
ClientName = "MyDesktop", |
||||
|
BrowserInfo = "Chrome", |
||||
|
Comments = new List<string> { firstComment, "Second Comment" }, |
||||
|
UserName = "Douglas", |
||||
|
EntityChanges = { |
||||
|
new EntityChangeInfo |
||||
|
{ |
||||
|
EntityId = Guid.NewGuid().ToString(), |
||||
|
EntityTypeFullName = "Volo.Abp.AuditLogging.TestEntity", |
||||
|
ChangeType = EntityChangeType.Created, |
||||
|
ChangeTime = DateTime.Now, |
||||
|
PropertyChanges = new List<EntityPropertyChangeInfo> |
||||
|
{ |
||||
|
new EntityPropertyChangeInfo |
||||
|
{ |
||||
|
PropertyTypeFullName = typeof(string).FullName, |
||||
|
PropertyName = "Name", |
||||
|
NewValue = "New value", |
||||
|
OriginalValue = null |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
new EntityChangeInfo |
||||
|
{ |
||||
|
EntityId = Guid.NewGuid().ToString(), |
||||
|
EntityTypeFullName = "Volo.Abp.AuditLogging.TestEntity", |
||||
|
ChangeType = EntityChangeType.Created, |
||||
|
ChangeTime = DateTime.Now, |
||||
|
PropertyChanges = new List<EntityPropertyChangeInfo> |
||||
|
{ |
||||
|
new EntityPropertyChangeInfo |
||||
|
{ |
||||
|
PropertyTypeFullName = typeof(string).FullName, |
||||
|
PropertyName = "Name", |
||||
|
NewValue = "New value", |
||||
|
OriginalValue = null |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
var log2 = new AuditLogInfo |
||||
|
{ |
||||
|
UserId = userId2, |
||||
|
ImpersonatorUserId = Guid.NewGuid(), |
||||
|
ImpersonatorTenantId = Guid.NewGuid(), |
||||
|
ExecutionTime = DateTime.Today, |
||||
|
ExecutionDuration = 42, |
||||
|
ClientIpAddress = ipAddress, |
||||
|
ClientName = "MyDesktop", |
||||
|
BrowserInfo = "Chrome", |
||||
|
Comments = new List<string> { firstComment, "Second Comment" }, |
||||
|
HttpStatusCode = (int?)HttpStatusCode.BadGateway, |
||||
|
EntityChanges = { |
||||
|
new EntityChangeInfo |
||||
|
{ |
||||
|
EntityId = Guid.NewGuid().ToString(), |
||||
|
EntityTypeFullName = "Volo.Abp.AuditLogging.TestEntity", |
||||
|
ChangeType = EntityChangeType.Created, |
||||
|
ChangeTime = DateTime.Now, |
||||
|
PropertyChanges = new List<EntityPropertyChangeInfo> |
||||
|
{ |
||||
|
new EntityPropertyChangeInfo |
||||
|
{ |
||||
|
PropertyTypeFullName = typeof(string).FullName, |
||||
|
PropertyName = "Name", |
||||
|
NewValue = "New value", |
||||
|
OriginalValue = null |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
AuditLogRepository.Insert(new AuditLog(GuidGenerator, log1)); |
||||
|
AuditLogRepository.Insert(new AuditLog(GuidGenerator, log2)); |
||||
|
|
||||
|
//Assert
|
||||
|
var logs = await AuditLogRepository.GetCountAsync(); |
||||
|
logs.ShouldBe(2); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.AuditLogging |
||||
|
{ |
||||
|
public class AuditLogging_Repository_Resolve_Tests<TStartupModule> : AuditLoggingTestBase<TStartupModule> |
||||
|
where TStartupModule : IAbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netcoreapp2.2</TargetFramework> |
||||
|
|
||||
|
<IsPackable>false</IsPackable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Volo.Blogging.EntityFrameworkCore.Tests\Volo.Blogging.EntityFrameworkCore.Tests.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Blogging.TestBase\Volo.Blogging.TestBase.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public abstract class BloggingDomainTestBase : BloggingTestBase<BloggingTestBaseModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(BloggingEntityFrameworkCoreTestModule), |
||||
|
typeof(BloggingTestBaseModule) |
||||
|
)] |
||||
|
public class BloggingDomainTestModule : AbpModule |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Shouldly; |
||||
|
using Volo.Blogging.Blogs; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public class Blog_Tests |
||||
|
{ |
||||
|
[Theory] |
||||
|
[InlineData("aaa")] |
||||
|
[InlineData("bbb")] |
||||
|
public void SetName(string name) |
||||
|
{ |
||||
|
var blog = new Blog(Guid.NewGuid(), "test blog", "test"); |
||||
|
blog.SetName(name); |
||||
|
blog.Name.ShouldBe(name); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData("aaa")] |
||||
|
[InlineData("bbb")] |
||||
|
public void SetShortName(string name) |
||||
|
{ |
||||
|
var blog = new Blog(Guid.NewGuid(), "test blog", "test"); |
||||
|
blog.SetShortName(name); |
||||
|
blog.ShortName.ShouldBe(name); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Shouldly; |
||||
|
using Volo.Blogging.Comments; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public class Comment_Tests |
||||
|
{ |
||||
|
[Theory] |
||||
|
[InlineData("aaa")] |
||||
|
[InlineData("bbb")] |
||||
|
public void SetText(string text) |
||||
|
{ |
||||
|
var comment = new Comment(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), "good"); |
||||
|
comment.SetText(text); |
||||
|
comment.Text.ShouldBe(text); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Shouldly; |
||||
|
using Volo.Blogging.Comments; |
||||
|
using Volo.Blogging.Posts; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public class Post_Tests |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void IncreaseReadCount() |
||||
|
{ |
||||
|
var post = new Post(Guid.NewGuid(), Guid.NewGuid(), "abp", "⊙o⊙", "abp.io"); |
||||
|
post.IncreaseReadCount(); |
||||
|
post.ReadCount.ShouldBe(1); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData("aaa")] |
||||
|
[InlineData("bbb")] |
||||
|
public void SetTitle(string title) |
||||
|
{ |
||||
|
var post = new Post(Guid.NewGuid(), Guid.NewGuid(), "abp", "⊙o⊙", "abp.io"); |
||||
|
post.SetTitle(title); |
||||
|
post.Title.ShouldBe(title); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData("aaa")] |
||||
|
[InlineData("bbb")] |
||||
|
public void SetUrl(string url) |
||||
|
{ |
||||
|
var post = new Post(Guid.NewGuid(), Guid.NewGuid(), "abp", "⊙o⊙", "abp.io"); |
||||
|
post.SetUrl(url); |
||||
|
post.Url.ShouldBe(url); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void AddTag() |
||||
|
{ |
||||
|
var post = new Post(Guid.NewGuid(), Guid.NewGuid(), "abp", "⊙o⊙", "abp.io"); |
||||
|
var tagId = Guid.NewGuid(); |
||||
|
post.AddTag(tagId); |
||||
|
post.Tags.ShouldContain(x => x.TagId == tagId); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
[Fact] |
||||
|
public void RemoveTag() |
||||
|
{ |
||||
|
var post = new Post(Guid.NewGuid(), Guid.NewGuid(), "abp", "⊙o⊙", "abp.io"); |
||||
|
var tagId = Guid.NewGuid(); |
||||
|
post.AddTag(tagId); |
||||
|
|
||||
|
post.Tags.ShouldContain(x => x.TagId == tagId); |
||||
|
|
||||
|
post.RemoveTag(tagId); |
||||
|
post.Tags.ShouldNotContain(x => x.TagId == tagId); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,64 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Shouldly; |
||||
|
using Volo.Blogging.Tagging; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public class Tag_Tests |
||||
|
{ |
||||
|
[Theory] |
||||
|
[InlineData("aaa")] |
||||
|
[InlineData("bbb")] |
||||
|
public void SetName(string name) |
||||
|
{ |
||||
|
var tag = new Tag(Guid.NewGuid(), "abp", 0, "abp tag"); |
||||
|
tag.SetName(name); |
||||
|
tag.Name.ShouldBe(name); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(1)] |
||||
|
[InlineData(2)] |
||||
|
[InlineData(3)] |
||||
|
public void IncreaseUsageCount(int number) |
||||
|
{ |
||||
|
var tag = new Tag(Guid.NewGuid(), "abp", 0, "abp tag"); |
||||
|
tag.IncreaseUsageCount(number); |
||||
|
tag.UsageCount.ShouldBe(number); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData(1)] |
||||
|
[InlineData(2)] |
||||
|
[InlineData(3)] |
||||
|
public void DecreaseUsageCount(int number) |
||||
|
{ |
||||
|
var tag = new Tag(Guid.NewGuid(), "abp", 10, "abp tag"); |
||||
|
tag.DecreaseUsageCount(number); |
||||
|
tag.UsageCount.ShouldBe(10 - number); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void DecreaseUsageCount_Should_Greater_ThanOrEqual_Zero() |
||||
|
{ |
||||
|
var tag = new Tag(Guid.NewGuid(), "abp", 10, "abp tag"); |
||||
|
tag.DecreaseUsageCount(100); |
||||
|
tag.UsageCount.ShouldBe(0); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData("aaa")] |
||||
|
[InlineData("bbb")] |
||||
|
public void SetDescription(string description) |
||||
|
{ |
||||
|
var tag = new Tag(Guid.NewGuid(), "abp", 0, "abp tag"); |
||||
|
tag.SetDescription(description); |
||||
|
tag.Description.ShouldBe(description); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,71 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq.Expressions; |
||||
|
using System.Text; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Users; |
||||
|
using Volo.Blogging.Users; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public class BlogUser_Test |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void Update() |
||||
|
{ |
||||
|
var userId = Guid.NewGuid(); |
||||
|
var tenantId = Guid.NewGuid(); |
||||
|
var blogUser = new BlogUser(new UserData(userId, "bob lee", "boblee@volosoft.com", "lee", "bob", true, |
||||
|
"123456", true, tenantId)); |
||||
|
var userData = new UserData(userId, "lee bob", "leebob@volosoft.com", "bob", "lee", false, |
||||
|
"654321", false, tenantId); |
||||
|
|
||||
|
blogUser.Update(userData); |
||||
|
|
||||
|
blogUser.Equals(new BlogUser(userData)).ShouldBeTrue(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Update_User_Id_Must_Equals() |
||||
|
{ |
||||
|
var userId = Guid.NewGuid(); |
||||
|
var tenantId = Guid.NewGuid(); |
||||
|
var blogUser = new BlogUser(new UserData(userId, "bob lee", "boblee@volosoft.com", "lee", "bob", true, |
||||
|
"123456", true, tenantId)); |
||||
|
|
||||
|
var userData = new UserData(Guid.NewGuid(), "lee bob", "leebob@volosoft.com", "bob", "lee", false, |
||||
|
"654321", false, tenantId); |
||||
|
|
||||
|
Assert.Throws<ArgumentException>(() => blogUser.Update(userData)); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Update_Tenant_Id_Must_Equals() |
||||
|
{ |
||||
|
var userId = Guid.NewGuid(); |
||||
|
var tenantId = Guid.NewGuid(); |
||||
|
var blogUser = new BlogUser(new UserData(userId, "bob lee", "boblee@volosoft.com", "lee", "bob", true, |
||||
|
"123456", true, tenantId)); |
||||
|
|
||||
|
var userData = new UserData(userId, "lee bob", "leebob@volosoft.com", "bob", "lee", false, |
||||
|
"654321", false, Guid.NewGuid()); |
||||
|
|
||||
|
Assert.Throws<ArgumentException>(() => blogUser.Update(userData)); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void BlogUserEquals() |
||||
|
{ |
||||
|
var userId = Guid.NewGuid(); |
||||
|
var tenantId = Guid.NewGuid(); |
||||
|
var blogUser = new BlogUser(new UserData(userId, "bob lee", "john@volosoft.com", "lee", "bob", true, |
||||
|
"123456", true, tenantId)); |
||||
|
|
||||
|
var blogUser2= new BlogUser(new UserData(userId, "bob lee", "john@volosoft.com", "lee", "bob", true, |
||||
|
"123456", true, tenantId)); |
||||
|
|
||||
|
blogUser.Equals(blogUser2).ShouldBeTrue(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,9 +1,8 @@ |
|||||
using Volo.Blogging.EntityFrameworkCore; |
using Volo.Blogging.Blogs; |
||||
|
|
||||
namespace Volo.Blogging.Blogs |
namespace Volo.Blogging |
||||
{ |
{ |
||||
public class BlogRepository_Tests : BlogRepository_Tests<BloggingEntityFrameworkCoreTestModule> |
public class BlogRepository_Tests : BlogRepository_Tests<BloggingEntityFrameworkCoreTestModule> |
||||
{ |
{ |
||||
|
|
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Blogging.Comments; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public class CommentRepository_Tests : CommentRepository_Tests<BloggingEntityFrameworkCoreTestModule> |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Blogging.Posts; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public class PostRepository_Tests : PostRepository_Tests<BloggingEntityFrameworkCoreTestModule> |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Blogging.Tagging; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public class TagRepository_Tests : TagRepository_Tests<BloggingEntityFrameworkCoreTestModule> |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netcoreapp2.2</TargetFramework> |
||||
|
|
||||
|
<IsPackable>false</IsPackable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> |
||||
|
<PackageReference Include="Mongo2Go" Version="2.2.8" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\src\Volo.Blogging.MongoDB\Volo.Blogging.MongoDB.csproj" /> |
||||
|
<ProjectReference Include="..\Volo.Blogging.TestBase\Volo.Blogging.TestBase.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Blogging.Blogs; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public class BlogRepository_Tests : BlogRepository_Tests<BloggingMongoDBTestModule> |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Blogging.Comments; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public class CommentRepository_Tests : CommentRepository_Tests<BloggingMongoDBTestModule> |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
using Mongo2Go; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Blogging.MongoDB; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(BloggingTestBaseModule), |
||||
|
typeof(BloggingMongoDbModule) |
||||
|
)] |
||||
|
public class BloggingMongoDBTestModule : AbpModule |
||||
|
{ |
||||
|
private MongoDbRunner _mongoDbRunner; |
||||
|
|
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
_mongoDbRunner = MongoDbRunner.Start(); |
||||
|
|
||||
|
Configure<DbConnectionOptions>(options => |
||||
|
{ |
||||
|
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public override void OnApplicationShutdown(ApplicationShutdownContext context) |
||||
|
{ |
||||
|
_mongoDbRunner.Dispose(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Blogging.Posts; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public class PostRepository_Tests : PostRepository_Tests<BloggingMongoDBTestModule> |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Blogging.Tagging; |
||||
|
|
||||
|
namespace Volo.Blogging |
||||
|
{ |
||||
|
public class TagRepository_Tests : TagRepository_Tests<BloggingMongoDBTestModule> |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,54 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Blogging.Comments |
||||
|
{ |
||||
|
public abstract class CommentRepository_Tests<TStartupModule> : BloggingTestBase<TStartupModule> |
||||
|
where TStartupModule : IAbpModule |
||||
|
{ |
||||
|
protected ICommentRepository CommentRepository { get; } |
||||
|
protected BloggingTestData BloggingTestData { get; } |
||||
|
|
||||
|
protected CommentRepository_Tests() |
||||
|
{ |
||||
|
CommentRepository = GetRequiredService<ICommentRepository>(); |
||||
|
BloggingTestData = GetRequiredService<BloggingTestData>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetListOfPostAsync() |
||||
|
{ |
||||
|
var comments = await CommentRepository.GetListOfPostAsync(BloggingTestData.Blog1Post1Id); |
||||
|
comments.ShouldNotBeNull(); |
||||
|
comments.Count.ShouldBe(2); |
||||
|
comments.ShouldAllBe(x => x.PostId == BloggingTestData.Blog1Post1Id); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetCommentCountOfPostAsync() |
||||
|
{ |
||||
|
var count = await CommentRepository.GetCommentCountOfPostAsync(BloggingTestData.Blog1Post1Id); |
||||
|
count.ShouldBe(2); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetRepliesOfComment() |
||||
|
{ |
||||
|
var comment = await CommentRepository.GetRepliesOfComment(BloggingTestData.Blog1Post1Comment1Id); |
||||
|
comment.ShouldNotBeNull(); |
||||
|
comment.ShouldContain(x => x.Id == BloggingTestData.Blog1Post1Comment2Id); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task DeleteOfPost() |
||||
|
{ |
||||
|
await CommentRepository.DeleteOfPost(BloggingTestData.Blog1Post1Id); |
||||
|
(await CommentRepository.GetListAsync()).ShouldBeEmpty(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Blogging.Posts |
||||
|
{ |
||||
|
public abstract class PostRepository_Tests<TStartupModule> : BloggingTestBase<TStartupModule> |
||||
|
where TStartupModule : IAbpModule |
||||
|
{ |
||||
|
protected IPostRepository PostRepository { get; } |
||||
|
protected BloggingTestData BloggingTestData { get; } |
||||
|
|
||||
|
protected PostRepository_Tests() |
||||
|
{ |
||||
|
PostRepository = GetRequiredService<IPostRepository>(); |
||||
|
BloggingTestData = GetRequiredService<BloggingTestData>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetListOfPostAsync() |
||||
|
{ |
||||
|
var posts = await PostRepository.GetPostsByBlogId(BloggingTestData.Blog1Id); |
||||
|
posts.ShouldNotBeNull(); |
||||
|
posts.Count.ShouldBe(2); |
||||
|
posts.ShouldContain(x => x.Id == BloggingTestData.Blog1Post1Id); |
||||
|
posts.ShouldContain(x => x.Id == BloggingTestData.Blog1Post2Id); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetPostByUrl() |
||||
|
{ |
||||
|
var post = await PostRepository.GetPostByUrl(BloggingTestData.Blog1Id, "url"); |
||||
|
post.ShouldNotBeNull(); |
||||
|
post.Url.ShouldBe("url"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,73 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Blogging.Tagging |
||||
|
{ |
||||
|
public abstract class TagRepository_Tests<TStartupModule> : BloggingTestBase<TStartupModule> |
||||
|
where TStartupModule : IAbpModule |
||||
|
{ |
||||
|
protected ITagRepository TagRepository { get; } |
||||
|
protected BloggingTestData BloggingTestData { get; } |
||||
|
|
||||
|
protected TagRepository_Tests() |
||||
|
{ |
||||
|
TagRepository = GetRequiredService<ITagRepository>(); |
||||
|
BloggingTestData = GetRequiredService<BloggingTestData>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetListAsync() |
||||
|
{ |
||||
|
var tags = await TagRepository.GetListAsync(BloggingTestData.Blog1Id); |
||||
|
tags.ShouldNotBeNull(); |
||||
|
tags.Count.ShouldBe(2); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetByNameAsync() |
||||
|
{ |
||||
|
var tag = await TagRepository.GetByNameAsync(BloggingTestData.Blog1Id, BloggingTestData.Tag1Name); |
||||
|
tag.ShouldNotBeNull(); |
||||
|
tag.Name.ShouldBe(BloggingTestData.Tag1Name); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task FindByNameAsync() |
||||
|
{ |
||||
|
var tag = await TagRepository.FindByNameAsync(BloggingTestData.Blog1Id, BloggingTestData.Tag1Name); |
||||
|
tag.ShouldNotBeNull(); |
||||
|
tag.Name.ShouldBe(BloggingTestData.Tag1Name); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetListAsync2() |
||||
|
{ |
||||
|
var tagIds = (await TagRepository.GetListAsync()).Select(x => x.Id).ToList(); |
||||
|
var tags = await TagRepository.GetListAsync(tagIds); |
||||
|
tags.ShouldNotBeNull(); |
||||
|
tags.Count.ShouldBe(tagIds.Count); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task DecreaseUsageCountOfTags() |
||||
|
{ |
||||
|
var tag = await TagRepository.FindByNameAsync(BloggingTestData.Blog1Id, BloggingTestData.Tag1Name); |
||||
|
var usageCount = tag.UsageCount; |
||||
|
|
||||
|
TagRepository.DecreaseUsageCountOfTags(new List<Guid>() |
||||
|
{ |
||||
|
tag.Id |
||||
|
}); |
||||
|
|
||||
|
await TagRepository.FindByNameAsync(BloggingTestData.Blog1Id, BloggingTestData.Tag1Name); |
||||
|
(await TagRepository.FindByNameAsync(BloggingTestData.Blog1Id, BloggingTestData.Tag1Name)).UsageCount |
||||
|
.ShouldBe(usageCount - 1); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Blogging.Users |
||||
|
{ |
||||
|
public abstract class BlogUserRepository_Tests<TStartupModule> : BloggingTestBase<TStartupModule> |
||||
|
where TStartupModule : IAbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -1,4 +0,0 @@ |
|||||
@page |
|
||||
@model Volo.DocsTestApp.Pages.IndexModel |
|
||||
<h3>Welcome to the Docs Demo!</h3> |
|
||||
<a href="/documents/">Go to documents...</a> |
|
||||
@ -1,16 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages; |
|
||||
|
|
||||
namespace Volo.DocsTestApp.Pages |
|
||||
{ |
|
||||
public class IndexModel : PageModel |
|
||||
{ |
|
||||
public void OnGet() |
|
||||
{ |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||