Browse Source

Merge pull request #24535 from abpframework/auto-merge/rel-10-1/4236

Merge branch dev with rel-10.1
pull/24546/head
Ma Liming 4 months ago
committed by GitHub
parent
commit
465e53db4c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 10
      framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpWebApplicationFactoryIntegratedTest.cs
  2. 28
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/BasicAggregateRoot.cs

10
framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/AbpWebApplicationFactoryIntegratedTest.cs

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
@ -33,6 +34,15 @@ public abstract class AbpWebApplicationFactoryIntegratedTest<TProgram> : WebAppl
return base.CreateHost(builder);
}
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.ConfigureAppConfiguration((hostingContext, config) =>
{
hostingContext.HostingEnvironment.EnvironmentName = "Production";
});
base.ConfigureWebHost(builder);
}
protected virtual T? GetService<T>()
{
return Services.GetService<T>();

28
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/BasicAggregateRoot.cs

@ -10,36 +10,38 @@ public abstract class BasicAggregateRoot : Entity,
IAggregateRoot,
IGeneratesDomainEvents
{
private readonly ICollection<DomainEventRecord> _distributedEvents = new Collection<DomainEventRecord>();
private readonly ICollection<DomainEventRecord> _localEvents = new Collection<DomainEventRecord>();
private ICollection<DomainEventRecord>? _distributedEvents;
private ICollection<DomainEventRecord>? _localEvents;
public virtual IEnumerable<DomainEventRecord> GetLocalEvents()
{
return _localEvents;
return _localEvents ?? Array.Empty<DomainEventRecord>();
}
public virtual IEnumerable<DomainEventRecord> GetDistributedEvents()
{
return _distributedEvents;
return _distributedEvents ?? Array.Empty<DomainEventRecord>();
}
public virtual void ClearLocalEvents()
{
_localEvents.Clear();
_localEvents?.Clear();
}
public virtual void ClearDistributedEvents()
{
_distributedEvents.Clear();
_distributedEvents?.Clear();
}
protected virtual void AddLocalEvent(object eventData)
{
_localEvents ??= new Collection<DomainEventRecord>();
_localEvents.Add(new DomainEventRecord(eventData, EventOrderGenerator.GetNext()));
}
protected virtual void AddDistributedEvent(object eventData)
{
_distributedEvents ??= new Collection<DomainEventRecord>();
_distributedEvents.Add(new DomainEventRecord(eventData, EventOrderGenerator.GetNext()));
}
}
@ -49,8 +51,8 @@ public abstract class BasicAggregateRoot<TKey> : Entity<TKey>,
IAggregateRoot<TKey>,
IGeneratesDomainEvents
{
private readonly ICollection<DomainEventRecord> _distributedEvents = new Collection<DomainEventRecord>();
private readonly ICollection<DomainEventRecord> _localEvents = new Collection<DomainEventRecord>();
private ICollection<DomainEventRecord>? _distributedEvents;
private ICollection<DomainEventRecord>? _localEvents;
protected BasicAggregateRoot()
{
@ -65,31 +67,33 @@ public abstract class BasicAggregateRoot<TKey> : Entity<TKey>,
public virtual IEnumerable<DomainEventRecord> GetLocalEvents()
{
return _localEvents;
return _localEvents ?? Array.Empty<DomainEventRecord>();
}
public virtual IEnumerable<DomainEventRecord> GetDistributedEvents()
{
return _distributedEvents;
return _distributedEvents ?? Array.Empty<DomainEventRecord>();
}
public virtual void ClearLocalEvents()
{
_localEvents.Clear();
_localEvents?.Clear();
}
public virtual void ClearDistributedEvents()
{
_distributedEvents.Clear();
_distributedEvents?.Clear();
}
protected virtual void AddLocalEvent(object eventData)
{
_localEvents ??= new Collection<DomainEventRecord>();
_localEvents.Add(new DomainEventRecord(eventData, EventOrderGenerator.GetNext()));
}
protected virtual void AddDistributedEvent(object eventData)
{
_distributedEvents ??= new Collection<DomainEventRecord>();
_distributedEvents.Add(new DomainEventRecord(eventData, EventOrderGenerator.GetNext()));
}
}

Loading…
Cancel
Save