mirror of https://github.com/abpframework/abp.git
836 changed files with 44551 additions and 44466 deletions
@ -0,0 +1,4 @@ |
|||
ui-angular: |
|||
- npm/ng-packs/**/* |
|||
- templates/app/angular/**/* |
|||
- templates/module/angular/**/* |
|||
@ -0,0 +1,17 @@ |
|||
name: "Pull Request Labeler" |
|||
on: |
|||
pull_request: |
|||
paths: |
|||
- npm/ng-packs/**/* |
|||
- templates/app/angular/**/* |
|||
- templates/module/angular/**/* |
|||
branches: |
|||
- master |
|||
- dev |
|||
jobs: |
|||
labeler: |
|||
runs-on: ubuntu-18.04 |
|||
steps: |
|||
- uses: actions/labeler@v2 |
|||
with: |
|||
repo-token: "${{ secrets.GITHUB_TOKEN }}" |
|||
@ -1,24 +0,0 @@ |
|||
name: 'Main' |
|||
on: |
|||
pull_request: |
|||
paths: |
|||
- 'framework/**' |
|||
- 'modules/**' |
|||
branches: |
|||
- dev |
|||
jobs: |
|||
build-test: |
|||
runs-on: windows-latest |
|||
steps: |
|||
- uses: actions/checkout@v1 |
|||
- uses: actions/setup-dotnet@master |
|||
with: |
|||
dotnet-version: '3.0.100' |
|||
|
|||
- name: Build All |
|||
run: .\build-all.ps1 |
|||
shell: pwsh |
|||
|
|||
- name: Test All |
|||
run: .\test-all.ps1 |
|||
shell: pwsh |
|||
@ -0,0 +1,11 @@ |
|||
# Data Access |
|||
|
|||
ABP framework was designed as database agnostic, it can work any type of data source by the help of the [repository](Repositories.md) and [unit of work](Unit-Of-Work.md) abstractions. |
|||
|
|||
However, currently the following providers are implements: |
|||
|
|||
* [Entity Framework Core](Entity-Framework-Core.md) (works with [various DBMS and providers](https://docs.microsoft.com/en-us/ef/core/providers/?tabs=dotnet-core-cli).) |
|||
* [MongoDB](MongoDB.md) |
|||
* [Dapper](Dapper.md) |
|||
|
|||
More providers might be added in the next releases. |
|||
@ -1,14 +1,18 @@ |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Toolbar.LanguageSwitch |
|||
@using System.Linq |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Toolbar.LanguageSwitch |
|||
@model LanguageSwitchViewComponentModel |
|||
<div class="dropdown"> |
|||
<a class="nav-link dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
|||
@Model.CurrentLanguage.DisplayName |
|||
</a> |
|||
@if (Model.OtherLanguages.Any()) |
|||
{ |
|||
<div class="dropdown"> |
|||
<a class="nav-link dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
|||
@Model.CurrentLanguage.DisplayName |
|||
</a> |
|||
|
|||
<div class="dropdown-menu dropdown-menu-right border-0 shadow-sm" aria-labelledby="dropdownMenuLink"> |
|||
@foreach (var language in Model.OtherLanguages) |
|||
{ |
|||
<a class="dropdown-item" href="/Abp/Languages/Switch?culture=@(language.CultureName)&uiCulture=@(language.UiCultureName)&returnUrl=@Context.Request.Path">@language.DisplayName</a> |
|||
} |
|||
</div> |
|||
</div> |
|||
<div class="dropdown-menu dropdown-menu-right border-0 shadow-sm" aria-labelledby="dropdownMenuLink"> |
|||
@foreach (var language in Model.OtherLanguages) |
|||
{ |
|||
<a class="dropdown-item" href="/Abp/Languages/Switch?culture=@(language.CultureName)&uiCulture=@(language.UiCultureName)&returnUrl=@Context.Request.Path">@language.DisplayName</a> |
|||
} |
|||
</div> |
|||
</div> |
|||
} |
|||
|
|||
@ -0,0 +1,49 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc.ModelBinding; |
|||
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Logging; |
|||
using Volo.Abp.Timing; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.ModelBinding |
|||
{ |
|||
public class AbpDateTimeModelBinder : IModelBinder |
|||
{ |
|||
private readonly Type _type; |
|||
private readonly SimpleTypeModelBinder _simpleTypeModelBinder; |
|||
private readonly IClock _clock; |
|||
|
|||
public AbpDateTimeModelBinder(ModelBinderProviderContext context) |
|||
{ |
|||
_type = context.Metadata.ModelType; |
|||
_clock = context.Services.GetRequiredService<IClock>(); |
|||
_simpleTypeModelBinder = new SimpleTypeModelBinder(context.Metadata.ModelType, |
|||
context.Services.GetRequiredService<ILoggerFactory>()); |
|||
} |
|||
|
|||
public async Task BindModelAsync(ModelBindingContext bindingContext) |
|||
{ |
|||
await _simpleTypeModelBinder.BindModelAsync(bindingContext); |
|||
|
|||
if (!bindingContext.Result.IsModelSet) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
if (_type == typeof(DateTime)) |
|||
{ |
|||
var dateTime = (DateTime) bindingContext.Result.Model; |
|||
bindingContext.Result = ModelBindingResult.Success(_clock.Normalize(dateTime)); |
|||
} |
|||
else |
|||
{ |
|||
var dateTime = (DateTime?) bindingContext.Result.Model; |
|||
if (dateTime != null) |
|||
{ |
|||
bindingContext.Result = ModelBindingResult.Success(_clock.Normalize(dateTime.Value)); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
using System; |
|||
using System.Linq; |
|||
using Microsoft.AspNetCore.Mvc.ModelBinding; |
|||
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata; |
|||
using Volo.Abp.Timing; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.ModelBinding |
|||
{ |
|||
public class AbpDateTimeModelBinderProvider : IModelBinderProvider |
|||
{ |
|||
public IModelBinder GetBinder(ModelBinderProviderContext context) |
|||
{ |
|||
if (context.Metadata.ModelType != typeof(DateTime) && |
|||
context.Metadata.ModelType != typeof(DateTime?)) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
if (context.Metadata.ContainerType == null) |
|||
{ |
|||
if (context.Metadata is DefaultModelMetadata defaultModelMetadata && |
|||
defaultModelMetadata.Attributes.Attributes.All(x => x.GetType() != typeof(DisableDateTimeNormalizationAttribute))) |
|||
{ |
|||
return new AbpDateTimeModelBinder(context); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
var dateNormalizationDisabledForClass = |
|||
context.Metadata.ContainerType.IsDefined(typeof(DisableDateTimeNormalizationAttribute), true); |
|||
|
|||
var dateNormalizationDisabledForProperty = context.Metadata.ContainerType |
|||
.GetProperty(context.Metadata.PropertyName) |
|||
?.IsDefined(typeof(DisableDateTimeNormalizationAttribute), true); |
|||
|
|||
if (!dateNormalizationDisabledForClass && |
|||
dateNormalizationDisabledForProperty != null && |
|||
!dateNormalizationDisabledForProperty.Value) |
|||
{ |
|||
return new AbpDateTimeModelBinder(context); |
|||
} |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.Timing; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.ValueConverters |
|||
{ |
|||
public class AbpDateTimeValueConverter : ValueConverter<DateTime?, DateTime?> |
|||
{ |
|||
public AbpDateTimeValueConverter(IClock clock, [CanBeNull] ConverterMappingHints mappingHints = null) |
|||
: base( |
|||
x => x.HasValue ? clock.Normalize(x.Value) : x, |
|||
x => x.HasValue ? clock.Normalize(x.Value) : x, mappingHints) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<AssemblyName>Volo.Abp.Minify</AssemblyName> |
|||
<PackageId>Volo.Abp.Minify</PackageId> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.Core\Volo.Abp.Core.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="NUglify" Version="1.5.13" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,8 @@ |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.Minify |
|||
{ |
|||
public class AbpMinifyModule : AbpModule |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace Volo.Abp.Minify.Html |
|||
{ |
|||
public interface IHtmlMinifier : IMinifier |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -1,4 +1,4 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification |
|||
namespace Volo.Abp.Minify |
|||
{ |
|||
public interface IMinifier |
|||
{ |
|||
@ -1,7 +1,7 @@ |
|||
using NUglify; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Minification.Styles; |
|||
using Volo.Abp.Minify.Styles; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.NUglify |
|||
namespace Volo.Abp.Minify.NUglify |
|||
{ |
|||
public class NUglifyCssMinifier : NUglifyMinifierBase, ICssMinifier |
|||
{ |
|||
@ -0,0 +1,13 @@ |
|||
using NUglify; |
|||
using Volo.Abp.Minify.Html; |
|||
|
|||
namespace Volo.Abp.Minify.NUglify |
|||
{ |
|||
public class NUglifyHtmlMinifier : NUglifyMinifierBase, IHtmlMinifier |
|||
{ |
|||
protected override UglifyResult UglifySource(string source, string fileName) |
|||
{ |
|||
return Uglify.Html(source, sourceFileName: fileName); |
|||
} |
|||
} |
|||
} |
|||
@ -1,9 +1,7 @@ |
|||
using NUglify; |
|||
using NUglify.JavaScript; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Minification.Scripts; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Minify.Scripts; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.NUglify |
|||
namespace Volo.Abp.Minify.NUglify |
|||
{ |
|||
public class NUglifyJavascriptMinifier : NUglifyMinifierBase, IJavascriptMinifier |
|||
{ |
|||
@ -1,4 +1,4 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.Scripts |
|||
namespace Volo.Abp.Minify.Scripts |
|||
{ |
|||
public interface IJavascriptMinifier : IMinifier |
|||
{ |
|||
@ -1,4 +1,4 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.Styles |
|||
namespace Volo.Abp.Minify.Styles |
|||
{ |
|||
public interface ICssMinifier : IMinifier |
|||
{ |
|||
@ -0,0 +1,61 @@ |
|||
using System; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.Timing; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.ModelBinding |
|||
{ |
|||
[Route("api/model-Binding-test")] |
|||
public class ModelBindingController : AbpController |
|||
{ |
|||
[HttpGet("DateTimeKind")] |
|||
public string DateTimeKind(DateTime input) |
|||
{ |
|||
return input.Kind.ToString().ToLower(); |
|||
} |
|||
|
|||
[HttpGet("NullableDateTimeKind")] |
|||
public string NullableDateTimeKind(DateTime? input) |
|||
{ |
|||
return input.Value.Kind.ToString().ToLower(); |
|||
} |
|||
|
|||
[HttpGet("DisableDateTimeNormalizationDateTimeKind")] |
|||
public string DisableDateTimeNormalizationDateTimeKind([DisableDateTimeNormalization]DateTime input) |
|||
{ |
|||
return input.Kind.ToString().ToLower(); |
|||
} |
|||
|
|||
[HttpGet("DisableDateTimeNormalizationNullableDateTimeKind")] |
|||
public string DisableDateTimeNormalizationNullableDateTimeKind([DisableDateTimeNormalization]DateTime? input) |
|||
{ |
|||
return input.Value.Kind.ToString().ToLower(); |
|||
} |
|||
|
|||
[HttpGet("ComplexTypeDateTimeKind")] |
|||
public string ComplexTypeDateTimeKind(GetDateTimeKindModel input) |
|||
{ |
|||
return input.Time1.Kind.ToString().ToLower() + "_" + |
|||
input.Time2.Kind.ToString().ToLower() + "_" + |
|||
input.Time3.Value.Kind.ToString().ToLower() + "_" + |
|||
input.InnerModel.Time4.Kind.ToString().ToLower(); |
|||
} |
|||
} |
|||
|
|||
public class GetDateTimeKindModel |
|||
{ |
|||
[DisableDateTimeNormalization] |
|||
public DateTime Time1 { get; set; } |
|||
|
|||
public DateTime Time2 { get; set; } |
|||
|
|||
public DateTime? Time3 { get; set; } |
|||
|
|||
public GetDateTimeKindInnerModel InnerModel { get; set; } |
|||
|
|||
[DisableDateTimeNormalization] |
|||
public class GetDateTimeKindInnerModel |
|||
{ |
|||
public DateTime Time4 { get; set; } |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,100 @@ |
|||
using System; |
|||
using System.Net; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Shouldly; |
|||
using Volo.Abp.Timing; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.ModelBinding |
|||
{ |
|||
public abstract class ModelBindingController_Tests : AspNetCoreMvcTestBase |
|||
{ |
|||
protected DateTimeKind DateTimeKind { get; set; } |
|||
|
|||
protected override void ConfigureServices(HostBuilderContext context, IServiceCollection services) |
|||
{ |
|||
services.Configure<AbpClockOptions>(x => x.Kind = DateTimeKind); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task DateTimeKind_Test() |
|||
{ |
|||
var response = await Client.GetAsync("/api/model-Binding-test/DateTimeKind?input=2010-01-01T00:00:00Z"); |
|||
|
|||
response.StatusCode.ShouldBe(HttpStatusCode.OK); |
|||
var resultAsString = await response.Content.ReadAsStringAsync(); |
|||
resultAsString.ShouldBe(DateTimeKind.ToString().ToLower()); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task NullableDateTimeKind_Test() |
|||
{ |
|||
var response = |
|||
await Client.GetAsync("/api/model-Binding-test/NullableDateTimeKind?input=2010-01-01T00:00:00Z"); |
|||
|
|||
response.StatusCode.ShouldBe(HttpStatusCode.OK); |
|||
var resultAsString = await response.Content.ReadAsStringAsync(); |
|||
resultAsString.ShouldBe(DateTimeKind.ToString().ToLower()); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task DisableDateTimeNormalizationDateTimeKind_Test() |
|||
{ |
|||
var response = |
|||
await Client.GetAsync( |
|||
"/api/model-Binding-test/DisableDateTimeNormalizationDateTimeKind?input=2010-01-01T00:00:00Z"); |
|||
|
|||
response.StatusCode.ShouldBe(HttpStatusCode.OK); |
|||
var resultAsString = await response.Content.ReadAsStringAsync(); |
|||
//Time parameter(2010-01-01T00:00:00Z) with time zone information, so the default Kind is Local.
|
|||
resultAsString.ShouldBe(DateTimeKind.Local.ToString().ToLower()); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task DisableDateTimeNormalizationNullableDateTimeKind_Test() |
|||
{ |
|||
var response = |
|||
await Client.GetAsync( |
|||
"/api/model-Binding-test/DisableDateTimeNormalizationNullableDateTimeKind?input=2010-01-01T00:00:00Z"); |
|||
|
|||
response.StatusCode.ShouldBe(HttpStatusCode.OK); |
|||
var resultAsString = await response.Content.ReadAsStringAsync(); |
|||
//Time parameter(2010-01-01T00:00:00Z) with time zone information, so the default Kind is Local.
|
|||
resultAsString.ShouldBe(DateTimeKind.Local.ToString().ToLower()); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task ComplexTypeDateTimeKind_Test() |
|||
{ |
|||
var response = await Client.GetAsync("/api/model-Binding-test/ComplexTypeDateTimeKind?" + |
|||
"Time1=2010-01-01T00:00:00Z&" + |
|||
"Time2=2010-01-01T00:00:00Z&" + |
|||
"Time3=2010-01-01T00:00:00Z&" + |
|||
"InnerModel.Time4=2010-01-01T00:00:00Z"); |
|||
|
|||
response.StatusCode.ShouldBe(HttpStatusCode.OK); |
|||
var resultAsString = await response.Content.ReadAsStringAsync(); |
|||
//Time parameter(2010-01-01T00:00:00Z) with time zone information, so the default Kind is Local.
|
|||
resultAsString.ShouldBe( |
|||
$"local_{DateTimeKind.ToString().ToLower()}_{DateTimeKind.ToString().ToLower()}_local"); |
|||
} |
|||
} |
|||
|
|||
public class ModelBindingController_Utc_Tests : ModelBindingController_Tests |
|||
{ |
|||
public ModelBindingController_Utc_Tests() |
|||
{ |
|||
DateTimeKind = DateTimeKind.Utc; |
|||
} |
|||
} |
|||
|
|||
public class ModelBindingController_Local_Tests : ModelBindingController_Tests |
|||
{ |
|||
public ModelBindingController_Local_Tests() |
|||
{ |
|||
DateTimeKind = DateTimeKind.Local; |
|||
} |
|||
} |
|||
} |
|||
@ -1,26 +0,0 @@ |
|||
using Shouldly; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.NUglify |
|||
{ |
|||
public class NUglifyJavascriptMinifier_Tests : AbpAspNetCoreMvcUiTestBase |
|||
{ |
|||
private readonly NUglifyJavascriptMinifier _nUglifyJavascriptMinifier; |
|||
|
|||
public NUglifyJavascriptMinifier_Tests() |
|||
{ |
|||
_nUglifyJavascriptMinifier = GetRequiredService<NUglifyJavascriptMinifier>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_Minify_Simple_Code() |
|||
{ |
|||
const string source = "var x = 5; var y = 6;"; |
|||
|
|||
var minified = _nUglifyJavascriptMinifier.Minify(source); |
|||
|
|||
minified.Length.ShouldBeGreaterThan(0); |
|||
minified.Length.ShouldBeLessThan(source.Length); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using Volo.Abp.TestApp.Testing; |
|||
|
|||
namespace Volo.Abp.EntityFrameworkCore.ValueConverters |
|||
{ |
|||
public class AbpDateTimeValueConverter_Tests : AbpDateTimeValueConverter_Tests<AbpEntityFrameworkCoreTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.TestApp.Domain; |
|||
|
|||
namespace Volo.Abp.TestApp.EntityFrameworkCore |
|||
{ |
|||
public class PersonRepository : EfCoreRepository<TestAppDbContext, Person, Guid>, IPersonRepository |
|||
{ |
|||
public PersonRepository(IDbContextProvider<TestAppDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ |
|||
} |
|||
|
|||
public async Task<PersonView> GetViewAsync(string name) |
|||
{ |
|||
return await DbContext.PersonView.Where(x => x.Name == name).FirstOrDefaultAsync(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\common.test.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp3.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Volo.Abp.Minify\Volo.Abp.Minify.csproj" /> |
|||
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" /> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,11 @@ |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.Minify |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpMinifyModule), |
|||
typeof(AbpTestBaseModule))] |
|||
public class AbpMinifyTestModule : AbpModule |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using Shouldly; |
|||
using Volo.Abp.Minify.Styles; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.Minify.NUglify |
|||
{ |
|||
public class CssMinifier_Tests : AbpIntegratedTest<AbpMinifyModule> |
|||
{ |
|||
private readonly ICssMinifier _cssMinifier; |
|||
|
|||
public CssMinifier_Tests() |
|||
{ |
|||
_cssMinifier = GetRequiredService<ICssMinifier>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_Minify_Simple_Code() |
|||
{ |
|||
const string source = "div { color: #FFF; }"; |
|||
|
|||
var minified = _cssMinifier.Minify(source); |
|||
|
|||
minified.Length.ShouldBeGreaterThan(0); |
|||
minified.Length.ShouldBeLessThan(source.Length); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using Shouldly; |
|||
using Volo.Abp.Minify.Html; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.Minify.NUglify |
|||
{ |
|||
public class HtmlMinifier_Tests : AbpIntegratedTest<AbpMinifyModule> |
|||
{ |
|||
private readonly IHtmlMinifier _htmlMinifier; |
|||
|
|||
public HtmlMinifier_Tests() |
|||
{ |
|||
_htmlMinifier = GetRequiredService<IHtmlMinifier>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_Minify_Simple_Code() |
|||
{ |
|||
const string source = "<div> <p>This is <em> a text </em></p> </div>"; |
|||
|
|||
var minified = _htmlMinifier.Minify(source); |
|||
|
|||
minified.Length.ShouldBeGreaterThan(0); |
|||
minified.Length.ShouldBeLessThan(source.Length); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using Shouldly; |
|||
using Volo.Abp.Minify.Scripts; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.Minify.NUglify |
|||
{ |
|||
public class JavascriptMinifier_Tests : AbpIntegratedTest<AbpMinifyModule> |
|||
{ |
|||
private readonly IJavascriptMinifier _javascriptMinifier; |
|||
|
|||
public JavascriptMinifier_Tests() |
|||
{ |
|||
_javascriptMinifier = GetRequiredService<IJavascriptMinifier>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_Minify_Simple_Code() |
|||
{ |
|||
const string source = "var x = 5; var y = 6;"; |
|||
|
|||
var minified = _javascriptMinifier.Minify(source); |
|||
|
|||
minified.Length.ShouldBeGreaterThan(0); |
|||
minified.Length.ShouldBeLessThan(source.Length); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using System; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
|
|||
namespace Volo.Abp.TestApp.Domain |
|||
{ |
|||
public class District : CreationAuditedEntity |
|||
{ |
|||
public Guid CityId { get; private set; } |
|||
|
|||
public string Name { get; private set; } |
|||
|
|||
public int Population { get; set; } |
|||
|
|||
private District() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public District(Guid cityId, string name, int population = 0) |
|||
{ |
|||
CityId = cityId; |
|||
Name = name; |
|||
} |
|||
|
|||
public override object[] GetKeys() |
|||
{ |
|||
return new Object[] {CityId, Name}; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace Volo.Abp.TestApp.Domain |
|||
{ |
|||
public interface IPersonRepository : IBasicRepository<Person, Guid> |
|||
{ |
|||
Task<PersonView> GetViewAsync(string name); |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
using Volo.Abp.Timing; |
|||
|
|||
namespace Volo.Abp.TestApp.Domain |
|||
{ |
|||
public class PersonView |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public DateTime CreationTime { get; set; } |
|||
|
|||
public DateTime? Birthday { get; set; } |
|||
|
|||
[DisableDateTimeNormalization] |
|||
public DateTime? LastActive { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Shouldly; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.TestApp.Domain; |
|||
using Volo.Abp.Timing; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.TestApp.Testing |
|||
{ |
|||
public abstract class AbpDateTimeValueConverter_Tests<TStartupModule> : TestAppTestBase<TStartupModule> |
|||
where TStartupModule : IAbpModule |
|||
{ |
|||
private readonly IPersonRepository _personRepository; |
|||
|
|||
protected AbpDateTimeValueConverter_Tests() |
|||
{ |
|||
_personRepository = GetRequiredService<IPersonRepository>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task DateTime_Kind_Should_Be_Normalized_To_UTC_Test() |
|||
{ |
|||
var personId = Guid.Parse("4125582e-d100-4c27-aa84-e4de85830dca"); |
|||
await _personRepository.InsertAsync(new Person(personId, "bob lee", 18) |
|||
{ |
|||
Birthday = DateTime.Parse("2020-01-01 00:00:00"), |
|||
LastActive = DateTime.Parse("2020-01-01 00:00:00"), |
|||
}, true); |
|||
|
|||
var person = await _personRepository.GetAsync(personId); |
|||
|
|||
person.ShouldNotBeNull(); |
|||
person.CreationTime.Kind.ShouldBe(DateTimeKind.Utc); |
|||
|
|||
person.Birthday.ShouldNotBeNull(); |
|||
person.Birthday.Value.Kind.ShouldBe(DateTimeKind.Utc); |
|||
person.Birthday.Value.ToString("yyy-MM-dd HH:mm:ss").ShouldBe("2020-01-01 00:00:00"); |
|||
|
|||
//LastActive DisableDateTimeNormalization
|
|||
person.LastActive.ShouldNotBeNull(); |
|||
person.LastActive.Value.Kind.ShouldBe(DateTimeKind.Unspecified); |
|||
person.LastActive.Value.ToString("yyy-MM-dd HH:mm:ss").ShouldBe("2020-01-01 00:00:00"); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task DateTime_Kind_Should_Be_Normalized_To_UTC_View_Test() |
|||
{ |
|||
var personName = "bob lee"; |
|||
await _personRepository.InsertAsync(new Person(Guid.NewGuid(), personName, 18) |
|||
{ |
|||
Birthday = DateTime.Parse("2020-01-01 00:00:00"), |
|||
LastActive = DateTime.Parse("2020-01-01 00:00:00"), |
|||
}, true); |
|||
|
|||
var person = await _personRepository.GetViewAsync(personName); |
|||
|
|||
person.ShouldNotBeNull(); |
|||
person.CreationTime.Kind.ShouldBe(DateTimeKind.Utc); |
|||
|
|||
person.Birthday.ShouldNotBeNull(); |
|||
person.Birthday.Value.Kind.ShouldBe(DateTimeKind.Utc); |
|||
person.Birthday.Value.ToString("yyy-MM-dd HH:mm:ss").ShouldBe("2020-01-01 00:00:00"); |
|||
|
|||
//LastActive DisableDateTimeNormalization
|
|||
person.LastActive.ShouldNotBeNull(); |
|||
person.LastActive.Value.Kind.ShouldBe(DateTimeKind.Unspecified); |
|||
person.LastActive.Value.ToString("yyy-MM-dd HH:mm:ss").ShouldBe("2020-01-01 00:00:00"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
{ |
|||
"culture": "tr", |
|||
"texts": { |
|||
"Volo.IdentityServer:DuplicateIdentityResourceName": "Identity Resource adı zaten mevcut: {Name}", |
|||
"Volo.IdentityServer:DuplicateApiResourceName": "Api Resource adı zaten mevcut: {Name}", |
|||
"Volo.IdentityServer:DuplicateClientId": "ClientId already zaten mevcut: {ClientId}" |
|||
} |
|||
} |
|||
@ -1 +1,3 @@ |
|||
# @abp/ng.account.config |
|||
# @abp/ng.account.config |
|||
|
|||
[docs.abp.io](https://docs.abp.io) |
|||
|
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue