Browse Source

Merge branch 'dev' into deniz/L

pull/19076/head
denizdemirkan 3 years ago
parent
commit
2c1bd9c01c
  1. 2
      .github/ISSUE_TEMPLATE/config.yml
  2. 6
      abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/en.json
  3. 1
      abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json
  4. 2
      abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/tr.json
  5. 24
      docs/en/API/Static-CSharp-API-Clients.md
  6. 4
      docs/en/Modules/Tenant-Management.md
  7. 56
      docs/en/Testing.md
  8. BIN
      docs/en/images/solution-test-projects.png
  9. BIN
      docs/en/images/unitest-efcore-mongodb.png
  10. BIN
      docs/en/images/vs-run-tests-in-parallel.png
  11. BIN
      docs/en/images/vs-startup-template-tests.png
  12. 29
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs
  13. 52
      framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Sqlite/AbpUnitTestSqliteConnection.cs
  14. 8
      framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs
  15. 2
      framework/test/Volo.Abp.Auditing.Tests/Volo/Abp/Auditing/AbpAuditingTestModule.cs
  16. 2
      framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs
  17. 19
      framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpStringToEnum_Tests.cs
  18. 2
      modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AccountController.cs
  19. 2
      modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AbpAccountApplicationTestModule.cs
  20. 2
      modules/audit-logging/test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingEntityFrameworkCoreTestModule.cs
  21. 2
      modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/AbpBackgroundJobsEntityFrameworkCoreTestModule.cs
  22. 6
      modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs
  23. 1
      modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj
  24. 2
      modules/blogging/test/Volo.Blogging.EntityFrameworkCore.Tests/Volo/Blogging/EntityFrameworkCore/BloggingEntityFrameworkCoreTestModule.cs
  25. 2
      modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs
  26. 2
      modules/docs/test/Volo.Docs.EntityFrameworkCore.Tests/Volo/Docs/EntityFrameworkCore/DocsEntityFrameworkCoreTestModule.cs
  27. 2
      modules/feature-management/test/Volo.Abp.FeatureManagement.EntityFrameworkCore.Tests/Volo/Abp/FeatureManagement/EntityFrameworkCore/AbpFeatureManagementEntityFrameworkCoreTestModule.cs
  28. 2
      modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo/Abp/Identity/EntityFrameworkCore/AbpIdentityEntityFrameworkCoreTestModule.cs
  29. 2
      modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs
  30. 2
      modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo/Abp/OpenIddict/EntityFrameworkCore/OpenIddictEntityFrameworkCoreTestModule.cs
  31. 2
      modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo/Abp/SettingManagement/EntityFrameworkCore/AbpSettingManagementEntityFrameworkCoreTestModule.cs
  32. 2
      modules/tenant-management/test/Volo.Abp.TenantManagement.EntityFrameworkCore.Tests/Volo/Abp/TenantManagement/EntityFrameworkCore/AbpTenantManagementEntityFrameworkCoreTestModule.cs
  33. 2
      npm/ng-packs/packages/oauth/src/lib/services/remember-me.service.ts
  34. 71
      npm/ng-packs/packages/oauth/src/lib/tests/remember-me.service.spec.ts
  35. 1
      npm/ng-packs/packages/theme-shared/src/lib/tests/loader-bar.component.spec.ts
  36. 2
      templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs
  37. 2
      templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs

2
.github/ISSUE_TEMPLATE/config.yml

@ -2,7 +2,7 @@ blank_issues_enabled: true
contact_links:
- name: Issue with ABP Commercial
url: https://support.abp.io/QA/Questions
about: Please open issues relating to ABP Commercial in support.abp.io.
about: Please open ABP Commercial related issues at https://support.abp.io.
- name: Ask a question (community support)
url: https://stackoverflow.com/questions/tagged/abp
about: Ask a question that will be answered by the ABP community

6
abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/en.json

@ -240,6 +240,12 @@
"MeetTheABPCommunity": "Meet the ABP <span class=\"gradient-community\">Community</span>",
"DisplayName:CommunityIndexPagePoll": "Community Index Page Poll",
"ReturnOfInvestment": "Return Of Investment",
"PromotionalOffers": "Promotional Offers",
"PromotionalOffersDefinition": "Discounts, seasonal campaigns, etc.",
"EventsDefinition": "Community Talks, Webinars, ABP .NET Conference, etc.",
"ReleaseNotesDefinition": "ABP.IO Platform releases, new products, etc.",
"Newsletter": "Newsletter",
"NewsletterDefinition": "Blog posts, community news, etc.",
"EmailPreferences": "Email Preferences",
"DoYouAgreePrivacyPolicy": "By clicking <i>Subscribe</i> button you agree to the <a href=\"https://account.abp.io/Account/TermsConditions\">Terms & Conditions</a> and <a href=\"https://account.abp.io/Account/Privacy\">Privacy Policy</a>."
}

1
abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json

@ -1181,6 +1181,7 @@
"LearnMore": "Learn More",
"ReturnOfInvestment": "Return of Investment",
"ReturnOfInvestment_Description": "Learn how to reduce your development costs by more than %50.",
"SpecialDiscount": "Special Discount",
"Previous": "Previous"
}
}

2
abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/tr.json

@ -615,7 +615,7 @@
"TotalDeveloperPrice": "Toplam Geliştirici Fiyatı",
"Purchase_PricePerDeveloper": "<span>{0}</span> geliştirici başına",
"Purchase_IncludedDeveloperInfo": "{0} {1} dahil.",
"Purchase_LicenseExtraDeveloperPurchaseMessage": "<span class=\"fw-6\">{0} lisansı</span> {1} geliştirici(ler) içerir. Şimdi veya daha sonra ek geliştiriciler ekleyebilirsiniz.",
"Purchase_LicenseExtraDeveloperPurchaseMessage": "<span class=\"fw-6\">{0} lisansı</span> {1} geliştirici içerir. Şimdi veya daha sonra ek geliştirici ekleyebilirsiniz.",
"StartupTemplates_Page_Title": "ABP Başlangıç Şablonları",
"StartupTemplates_Page_Description": "ABP Commercial, her düzeyde karmaşıklığa sahip projeler oluşturmanıza olanak tanır. Önceden oluşturulmuş iki ana başlangıç projesi sunar. Gereksinimlerinize yakın olanı seçebilir ve bunun üzerine kendi özel projenizi oluşturabilirsiniz.",
"MicroserviceStartupSolutionForDotnet": ".NET için Mikroservis Başlatma Projesi",

24
docs/en/API/Static-CSharp-API-Clients.md

@ -65,8 +65,9 @@ Now, it's ready to configure the application for the static client proxy generat
````csharp
[DependsOn(
typeof(AbpHttpClientModule) //used to create client proxies
)]
typeof(AbpHttpClientModule), //used to create client proxies
typeof(AbpVirtualFileSystemModule) //virtual file system
)]
public class MyClientAppModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
@ -75,6 +76,12 @@ public class MyClientAppModule : AbpModule
context.Services.AddStaticHttpClientProxies(
typeof(MyClientAppModule).Assembly
);
// Include the generated app-generate-proxy.json in the virtual file system
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<MyClientAppModule>();
});
}
}
````
@ -84,8 +91,9 @@ public class MyClientAppModule : AbpModule
````csharp
[DependsOn(
typeof(AbpHttpClientModule), //used to create client proxies
typeof(AbpVirtualFileSystemModule), //virtual file system
typeof(BookStoreApplicationContractsModule) //contains the application service interfaces
)]
)]
public class MyClientAppModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
@ -94,6 +102,12 @@ public class MyClientAppModule : AbpModule
context.Services.AddStaticHttpClientProxies(
typeof(BookStoreApplicationContractsModule).Assembly
);
// Include the generated app-generate-proxy.json in the virtual file system
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<MyClientAppModule>();
});
}
}
````
@ -139,7 +153,7 @@ This command should generate the following files under the `ClientProxies` folde
* `BookClientProxy.Generated.cs` is the actual generated proxy class in this example. `BookClientProxy` is a `partial` class * where you can write your custom code (ABP won't override it).
* `IBookAppService.cs` is the app service.
* `BookDto.cs` is the Dto class which uses by app service.
* `app-generate-proxy.json` contains information about the remote HTTP endpoint, so ABP can properly perform HTTP requests.
* `app-generate-proxy.json` contains information about the remote HTTP endpoint, so ABP can properly perform HTTP requests. This file must be configured as an embedded resource in your project, so that it can be found by the virtual file system.
#### Without Contracts
@ -152,7 +166,7 @@ This command should generate the following files under the `ClientProxies` folde
![generated-static-client-proxies](../images/generated-static-client-proxies-without-contracts.png)
* `BookClientProxy.Generated.cs` is the actual generated proxy class in this example. `BookClientProxy` is a `partial` class where you can write your custom code (ABP won't override it).
* `app-generate-proxy.json` contains information about the remote HTTP endpoint, so ABP can properly perform HTTP requests.
* `app-generate-proxy.json` contains information about the remote HTTP endpoint, so ABP can properly perform HTTP requests. This file must be configured as an embedded resource in your project, so that it can be found by the virtual file system.
> `generate-proxy` command generates proxies for only the APIs you've defined in your application. If you are developing a modular application, you can specify the `-m` (or `--module`) parameter to specify the module you want to generate proxies. See the *generate-proxy* section in the [ABP CLI](../CLI.md) documentation for other options.

4
docs/en/Modules/Tenant-Management.md

@ -56,7 +56,7 @@ This module defines the following ETOs (Event Transfer Objects) to allow you to
**Example: Get notified when a new tenant has been created**
```
```cs
public class MyHandler :
IDistributedEventHandler<EntityCreatedEto<TenantEto>>,
ITransientDependency
@ -131,4 +131,4 @@ ABP Framework allows to use *database per tenant* approach that allows a tenant
## See Also
* [Multi-Tenancy](../Multi-Tenancy.md)
* [ABP Commercial SaaS Module](https://docs.abp.io/en/commercial/latest/modules/saas)
* [ABP Commercial SaaS Module](https://docs.abp.io/en/commercial/latest/modules/saas)

56
docs/en/Testing.md

@ -36,7 +36,7 @@ There are more than one test project, organized by the layers;
* `Domain.Tests` is used to test your Domain Layer objects (like [Domain Services](Domain-Services.md) and [Entities](Entities.md)).
* `Application.Tests` is used to test your Application Layer (like [Application Services](Application-Services.md)).
* `EntityFrameworkCore.Tests` is used to test your custom repository implementations or EF Core mappings (this project will be different if you use another [Database Provider](Data-Access.md)).
* `EntityFrameworkCore.Tests` is used to implement abstract test classes and test your custom repository implementations or EF Core mappings (this project will be different if you use another [Database Provider](Data-Access.md)).
* `Web.Tests` is used to test the UI Layer (like Pages, Controllers and View Components). This project does exists only for MVC / Razor Page applications.
* `TestBase` contains some classes those are shared/used by the other projects.
@ -537,12 +537,13 @@ using Xunit;
namespace MyProject.Issues
{
public class IssueManager_Integration_Tests : MyProjectDomainTestBase
public abstract class IssueManager_Integration_Tests<TStartupModule> : MyProjectDomainTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly IssueManager _issueManager;
private readonly Issue _issue;
public IssueManager_Integration_Tests()
protected IssueManager_Integration_Tests()
{
_issueManager = GetRequiredService<IssueManager>();
_issue = new Issue
@ -577,6 +578,8 @@ namespace MyProject.Issues
}
````
> The `IssueManager_Integration_Tests` class is an abstract class, and tests in this class are not seen on the tests explorer, see the **Implementing unit tests in EF Core and MongoDB** section below to learn how to list tests in the test explorer and run them.
* First test method assigns the issue to the User 1, which has already assigned to 3 issues in the Data Seed code. So, it throws a `BusinessException`.
* Second test method assigns the issue to User 2, which has only 1 issue assigned. So, the method succeeds.
@ -625,11 +628,12 @@ using Xunit;
namespace MyProject.Issues
{
public class IssueAppService_Tests : MyProjectApplicationTestBase
public abstract class IssueAppService_Tests<TStartupModule> : MyProjectApplicationTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly IIssueAppService _issueAppService;
public IssueAppService_Tests()
protected IssueAppService_Tests()
{
_issueAppService = GetRequiredService<IIssueAppService>();
}
@ -647,6 +651,8 @@ namespace MyProject.Issues
}
````
> The `IssueAppService_Tests` class is an abstract, and tests in this class are not seen on the tests explorer, see the **Implementing unit tests in EF Core and MongoDB** section below to learn how to list tests in the test explorer and run them.
It's that simple. This test method tests everything, including the application service, EF Core mapping, object to object mapping and the repository implementation. In this way, you can fully test the Application Layer and the Domain Layer of your solution.
### Dealing with Unit of Work in Integration Tests
@ -658,11 +664,12 @@ In the ABP Framework, all the database operations must be performed inside a uni
In some cases, you may need to manually control the unit of work scope. Consider the following test method:
````csharp
public class IssueRepository_Tests : MyProjectDomainTestBase
public abstract class IssueRepository_Tests<TStartupModule> : MyProjectDomainTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly IRepository<Issue, Guid> _issueRepository;
public IssueRepository_Tests()
protected IssueRepository_Tests()
{
_issueRepository = GetRequiredService<IRepository<Issue, Guid>>();
}
@ -676,17 +683,20 @@ public class IssueRepository_Tests : MyProjectDomainTestBase
}
````
> The `IssueRepository_Tests` class is an abstract, and tests in this class are not seen on the tests explorer, see the **Implementing unit tests in EF Core and MongoDB** section below to learn how to list tests in the test explorer and run them.
We are using `_issueRepository.GetQueryableAsync` to obtain an `IQueryable<Issue>` object. Then, we are using the `FirstOrDefaultAsync` method to query an issue by its title. The database query is executed at this point, and you get an exception indicating that there is no active unit of work.
To make that test properly working, you should manually start a unit of work scope as shown in the following example:
````csharp
public class IssueRepository_Tests : MyProjectDomainTestBase
public abstract class IssueRepository_Tests<TStartupModule> : MyProjectDomainTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly IRepository<Issue, Guid> _issueRepository;
private readonly IUnitOfWorkManager _unitOfWorkManager;
public IssueRepository_Tests()
protected IssueRepository_Tests()
{
_issueRepository = GetRequiredService<IRepository<Issue, Guid>>();
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
@ -716,12 +726,13 @@ In some cases, you may want to directory work with the Entity Framework's `DbCon
The following example shows how you can create a `DbContext` object in a test method:
````csharp
public class MyDbContext_Tests : MyProjectDomainTestBase
public abstract class MyDbContext_Tests<TStartupModule> : MyProjectDomainTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly IDbContextProvider<MyProjectDbContext> _dbContextProvider;
private readonly IUnitOfWorkManager _unitOfWorkManager;
public IssueRepository_Tests()
protected IssueRepository_Tests()
{
_dbContextProvider = GetRequiredService<IDbContextProvider<MyProjectDbContext>>();
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
@ -740,10 +751,33 @@ public class MyDbContext_Tests : MyProjectDomainTestBase
}
````
> The `MyDbContext_Tests` class is an abstract, and tests in this class are not seen on the tests explorer, see the **Implementing unit tests in EF Core and MongoDB** section below to learn how to list tests in the test explorer and run them.
Just like we've done in the *Dealing with Unit of Work in Integration Tests* section, we should perform `DbContext` operations inside an active unit of work.
For [MongoDB](MongoDB.md), you can use the `IMongoDbContextProvider<T>` service to obtain a `DbContext` object and directly use MongoDB APIs in your test methods.
## Implementing unit tests in EF Core and MongoDB
The unit test classes in the `.Domain.Test` and `.Application.Tests` projects are all abstract classes. Therefore, we need to implement the test classes in EF Core or MongoDB test projects to run the tests, otherwise they will be ignored.
An example implementation for the `IssueManager_Integration_Tests` class in the `.EntityFrameworkCore.Tests` project is shown below:
````csharp
namespace MyProject.EntityFrameworkCore.Applications;
public class EfCoreIssueAppService_Tests : IssueAppService_Tests<MyProjectEntityFrameworkCoreTestModule>
{
}
````
> By deriving from the related abstract classes, now we can see the all tests in the test explorers and run them.
![unitest-efcore-mongodb](images/unitest-efcore-mongodb.png)
As you can see from the folder structure, all tests are clearly placed into the related subfolders, and they will be seen in the test explorer with this separation. Thus, you can clearly see which tests are related to which layers and projects.
## UI Tests
In general, there are two types of UI Tests;

BIN
docs/en/images/solution-test-projects.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 109 KiB

BIN
docs/en/images/unitest-efcore-mongodb.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

BIN
docs/en/images/vs-run-tests-in-parallel.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 576 KiB

BIN
docs/en/images/vs-startup-template-tests.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 344 KiB

29
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs

@ -54,19 +54,22 @@ public class AbpInputTagHelperService : AbpTagHelperService<AbpInputTagHelper>
output.TagMode = TagMode.StartTagAndEndTag;
output.TagName = "div";
LeaveOnlyGroupAttributes(context, output);
if (TagHelper.FloatingLabel && !isCheckBox)
if (!IsOutputHidden(output))
{
output.Attributes.AddClass("form-floating");
}
if (TagHelper.AddMarginBottomClass)
{
output.Attributes.AddClass(isCheckBox ? "mb-2" : "mb-3");
}
if (isCheckBox)
{
output.Attributes.AddClass("custom-checkbox");
output.Attributes.AddClass("custom-control");
output.Attributes.AddClass("form-check");
if (TagHelper.FloatingLabel && !isCheckBox)
{
output.Attributes.AddClass("form-floating");
}
if (TagHelper.AddMarginBottomClass)
{
output.Attributes.AddClass(isCheckBox ? "mb-2" : "mb-3");
}
if (isCheckBox)
{
output.Attributes.AddClass("custom-checkbox");
output.Attributes.AddClass("custom-control");
output.Attributes.AddClass("form-check");
}
}
output.Content.AppendHtml(innerHtml);
}
@ -263,7 +266,7 @@ public class AbpInputTagHelperService : AbpTagHelperService<AbpInputTagHelper>
}
protected virtual async Task<string> GetLabelAsHtmlAsync(TagHelperContext context, TagHelperOutput output, TagHelperOutput inputTag, bool isCheckbox)
{
{
if (IsOutputHidden(inputTag) || TagHelper.SuppressLabel)
{
return string.Empty;

52
framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Sqlite/AbpUnitTestSqliteConnection.cs

@ -0,0 +1,52 @@
using System.Threading;
using Microsoft.Data.Sqlite;
using Volo.Abp.Threading;
namespace Volo.Abp.EntityFrameworkCore.Sqlite;
/// <summary>
/// This class is for unit testing purposes.
/// It prevents exceptions in concurrent testing because Sqlite is not thread-safe.
/// </summary>
public class AbpUnitTestSqliteConnection : SqliteConnection
{
public AbpUnitTestSqliteConnection(string connectionString)
: base(connectionString)
{
}
public override SqliteCommand CreateCommand()
{
return new AbpSqliteCommand
{
Connection = this,
CommandTimeout = DefaultTimeout,
Transaction = Transaction
};
}
}
internal class AbpSqliteCommand : SqliteCommand
{
private readonly static SemaphoreSlim Semaphore = new SemaphoreSlim(1, 1);
public override SqliteConnection? Connection
{
get => base.Connection;
set
{
using (Semaphore.Lock())
{
base.Connection = value;
}
}
}
protected override void Dispose(bool disposing)
{
using (Semaphore.Lock())
{
base.Dispose(disposing);
}
}
}

8
framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs

@ -11,6 +11,8 @@ public class AbpStringToEnumConverter<T> : JsonConverter<T>
private JsonSerializerOptions? _readJsonSerializerOptions;
private JsonSerializerOptions? _writeJsonSerializerOptions;
public AbpStringToEnumConverter()
: this(namingPolicy: null, allowIntegerValues: true)
{
@ -39,7 +41,11 @@ public class AbpStringToEnumConverter<T> : JsonConverter<T>
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
JsonSerializer.Serialize(writer, value);
_writeJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(options, x =>
x == this ||
x.GetType() == typeof(AbpStringToEnumFactory));
JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions);
}
public override T ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

2
framework/test/Volo.Abp.Auditing.Tests/Volo/Abp/Auditing/AbpAuditingTestModule.cs

@ -62,7 +62,7 @@ public class AbpAuditingTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
using (var context = new AbpAuditingTestDbContext(new DbContextOptionsBuilder<AbpAuditingTestDbContext>()

2
framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs

@ -93,7 +93,7 @@ public class AbpEntityFrameworkCoreTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
using (var context = new TestMigrationsDbContext(new DbContextOptionsBuilder<TestMigrationsDbContext>().UseSqlite(connection).Options))

19
framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpStringToEnum_Tests.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using Shouldly;
using Volo.Abp.Json.SystemTextJson.JsonConverters;
using Xunit;
@ -53,10 +54,26 @@ public class AbpStringToEnum_Tests
var testClassJson = JsonSerializer.Serialize(new TestClass()
{
Day = DayOfWeek.Monday
});
}, options);
testClassJson.ShouldBe("{\"Day\":1}");
options = new JsonSerializerOptions()
{
Converters =
{
new AbpStringToEnumFactory(),
new JsonStringEnumConverter()
}
};
testClassJson = JsonSerializer.Serialize(new TestClass()
{
Day = DayOfWeek.Monday
}, options);
testClassJson.ShouldBe("{\"Day\":\"Monday\"}");
testClassJson = JsonSerializer.Serialize(new Dictionary<DayOfWeek, string>
{
{DayOfWeek.Monday, "Mo"}

2
modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AccountController.cs

@ -33,7 +33,7 @@ public class AccountController : AbpControllerBase, IAccountAppService
[HttpPost]
[Route("verify-password-reset-token")]
public Task<bool> VerifyPasswordResetTokenAsync(VerifyPasswordResetTokenInput input)
public virtual Task<bool> VerifyPasswordResetTokenAsync(VerifyPasswordResetTokenInput input)
{
return AccountAppService.VerifyPasswordResetTokenAsync(input);
}

2
modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AbpAccountApplicationTestModule.cs

@ -44,7 +44,7 @@ public class AbpAccountApplicationTestModule : AbpModule
}
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new IdentityDbContext(

2
modules/audit-logging/test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingEntityFrameworkCoreTestModule.cs

@ -31,7 +31,7 @@ public class AbpAuditLoggingEntityFrameworkCoreTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new AbpAuditLoggingDbContext(

2
modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/AbpBackgroundJobsEntityFrameworkCoreTestModule.cs

@ -31,7 +31,7 @@ public class AbpBackgroundJobsEntityFrameworkCoreTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new BackgroundJobsDbContext(

6
modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs

@ -2,6 +2,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using Volo.Abp.EntityFrameworkCore.Sqlite;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;
@ -9,7 +10,8 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore;
[DependsOn(
typeof(BlobStoringDatabaseTestBaseModule),
typeof(BlobStoringDatabaseEntityFrameworkCoreModule)
typeof(BlobStoringDatabaseEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqliteModule)
)]
public class BlobStoringDatabaseEntityFrameworkCoreTestModule : AbpModule
{
@ -28,7 +30,7 @@ public class BlobStoringDatabaseEntityFrameworkCoreTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new BlobStoringDbContext(

1
modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj

@ -11,6 +11,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" />
<ProjectReference Include="..\..\src\Volo.Abp.BlobStoring.Database.EntityFrameworkCore\Volo.Abp.BlobStoring.Database.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.Sqlite\Volo.Abp.EntityFrameworkCore.Sqlite.csproj" />
<ProjectReference Include="..\Volo.Abp.BlobStoring.Database.TestBase\Volo.Abp.BlobStoring.Database.TestBase.csproj" />
</ItemGroup>

2
modules/blogging/test/Volo.Blogging.EntityFrameworkCore.Tests/Volo/Blogging/EntityFrameworkCore/BloggingEntityFrameworkCoreTestModule.cs

@ -33,7 +33,7 @@ namespace Volo.Blogging.EntityFrameworkCore
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<BloggingDbContext>().UseSqlite(connection).Options;

2
modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs

@ -30,7 +30,7 @@ public class CmsKitEntityFrameworkCoreTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new CmsKitDbContext(

2
modules/docs/test/Volo.Docs.EntityFrameworkCore.Tests/Volo/Docs/EntityFrameworkCore/DocsEntityFrameworkCoreTestModule.cs

@ -30,7 +30,7 @@ namespace Volo.Docs.EntityFrameworkCore
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new DocsDbContext(

2
modules/feature-management/test/Volo.Abp.FeatureManagement.EntityFrameworkCore.Tests/Volo/Abp/FeatureManagement/EntityFrameworkCore/AbpFeatureManagementEntityFrameworkCoreTestModule.cs

@ -36,7 +36,7 @@ public class AbpFeatureManagementEntityFrameworkCoreTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new FeatureManagementDbContext(

2
modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo/Abp/Identity/EntityFrameworkCore/AbpIdentityEntityFrameworkCoreTestModule.cs

@ -35,7 +35,7 @@ public class AbpIdentityEntityFrameworkCoreTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new IdentityDbContext(

2
modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs

@ -40,7 +40,7 @@ public class AbpIdentityServerTestEntityFrameworkCoreModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new IdentityDbContext(

2
modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo/Abp/OpenIddict/EntityFrameworkCore/OpenIddictEntityFrameworkCoreTestModule.cs

@ -37,7 +37,7 @@ public class OpenIddictEntityFrameworkCoreTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new IdentityDbContext(

2
modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo/Abp/SettingManagement/EntityFrameworkCore/AbpSettingManagementEntityFrameworkCoreTestModule.cs

@ -33,7 +33,7 @@ public class AbpSettingManagementEntityFrameworkCoreTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new SettingManagementDbContext(

2
modules/tenant-management/test/Volo.Abp.TenantManagement.EntityFrameworkCore.Tests/Volo/Abp/TenantManagement/EntityFrameworkCore/AbpTenantManagementEntityFrameworkCoreTestModule.cs

@ -37,7 +37,7 @@ public class AbpTenantManagementEntityFrameworkCoreTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new TenantManagementDbContext(

2
npm/ng-packs/packages/oauth/src/lib/services/remember-me.service.ts

@ -17,7 +17,7 @@ export class RememberMeService {
}
get() {
return Boolean(JSON.parse(this.localStorageService.getItem(this.#rememberMe)));
return Boolean(JSON.parse(this.localStorageService.getItem(this.#rememberMe) || 'false'));
}
getFromToken(accessToken: string) {

71
npm/ng-packs/packages/oauth/src/lib/tests/remember-me.service.spec.ts

@ -0,0 +1,71 @@
import { SpectatorService, SpyObject, createServiceFactory } from "@ngneat/spectator/jest";
import { RememberMeService } from "../services/remember-me.service";
import { AbpLocalStorageService } from "@abp/ng.core";
describe('RememberMeService', () => {
const key = 'remember_me';
let spectator: SpectatorService<RememberMeService>;
let rememberMeService: RememberMeService;
let abpLocalStorageService: SpyObject<AbpLocalStorageService>;
const createService = createServiceFactory({
service: RememberMeService,
mocks: [AbpLocalStorageService]
});
beforeEach(() => {
spectator = createService();
rememberMeService = spectator.inject(RememberMeService);
abpLocalStorageService = spectator.inject(AbpLocalStorageService);
});
it('should be created', () => {
expect(1).toBe(1);
expect(rememberMeService).toBeTruthy();
expect(abpLocalStorageService).toBeTruthy();
});
it('should set remember me', () => {
rememberMeService.set(true);
expect(abpLocalStorageService.setItem).toHaveBeenCalledWith(key, 'true');
expect(abpLocalStorageService.setItem).toHaveBeenCalledTimes(1);
});
it('should remove remember me', () => {
rememberMeService.remove();
expect(abpLocalStorageService.removeItem).toHaveBeenCalledWith(key);
expect(abpLocalStorageService.removeItem).toBeCalledTimes(1);
});
it('if notting has ben setted, it should return false value', () => {
expect(rememberMeService.get()).toBe(false);
});
it('should return true value', () => {
abpLocalStorageService.getItem.mockReturnValueOnce('true');
expect(rememberMeService.get()).toBe(true);
});
it('should return false value', () => {
abpLocalStorageService.getItem.mockReturnValueOnce('false');
expect(rememberMeService.get()).toBe(false);
});
it('should return true when parsed token is setted to true', () => {
const data = { "remember_me": "True" };
const base64_encoded = btoa(JSON.stringify(data));
const tokenWithValueTrue = "random." + base64_encoded + ".random";
expect(rememberMeService.getFromToken(tokenWithValueTrue)).toBe(true);
});
it('should return false when value is not setted(undefined)', () => {
const data = {};
const base64_encoded = btoa(JSON.stringify(data));
const tokenWithValueTrue = "random." + base64_encoded + ".random";
expect(rememberMeService.getFromToken(tokenWithValueTrue)).toBe(false);
});
});

1
npm/ng-packs/packages/theme-shared/src/lib/tests/loader-bar.component.spec.ts

@ -7,6 +7,7 @@ import { LoaderBarComponent } from '../components/loader-bar/loader-bar.componen
describe('LoaderBarComponent', () => {
let spectator: Spectator<LoaderBarComponent>;
let router: Router;
const events$ = new Subject();
const createComponent = createComponentFactory({

2
templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs

@ -59,7 +59,7 @@ public class MyProjectNameEntityFrameworkCoreTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<MyProjectNameDbContext>()

2
templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs

@ -33,7 +33,7 @@ public class MyProjectNameEntityFrameworkCoreTestModule : AbpModule
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
connection.Open();
new MyProjectNameDbContext(

Loading…
Cancel
Save