Skip to content

Commit 465e53d

Browse files
authored
Merge pull request #24535 from abpframework/auto-merge/rel-10-1/4236
Merge branch dev with rel-10.1
2 parents 634d805 + b6aa282 commit 465e53d

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Net.Http;
5+
using Microsoft.AspNetCore.Hosting;
56
using Microsoft.AspNetCore.Mvc.Testing;
67
using Microsoft.AspNetCore.Routing;
78
using Microsoft.Extensions.DependencyInjection;
@@ -33,6 +34,15 @@ protected override IHost CreateHost(IHostBuilder builder)
3334
return base.CreateHost(builder);
3435
}
3536

37+
protected override void ConfigureWebHost(IWebHostBuilder builder)
38+
{
39+
builder.ConfigureAppConfiguration((hostingContext, config) =>
40+
{
41+
hostingContext.HostingEnvironment.EnvironmentName = "Production";
42+
});
43+
base.ConfigureWebHost(builder);
44+
}
45+
3646
protected virtual T? GetService<T>()
3747
{
3848
return Services.GetService<T>();

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,38 @@ public abstract class BasicAggregateRoot : Entity,
1010
IAggregateRoot,
1111
IGeneratesDomainEvents
1212
{
13-
private readonly ICollection<DomainEventRecord> _distributedEvents = new Collection<DomainEventRecord>();
14-
private readonly ICollection<DomainEventRecord> _localEvents = new Collection<DomainEventRecord>();
13+
private ICollection<DomainEventRecord>? _distributedEvents;
14+
private ICollection<DomainEventRecord>? _localEvents;
1515

1616
public virtual IEnumerable<DomainEventRecord> GetLocalEvents()
1717
{
18-
return _localEvents;
18+
return _localEvents ?? Array.Empty<DomainEventRecord>();
1919
}
2020

2121
public virtual IEnumerable<DomainEventRecord> GetDistributedEvents()
2222
{
23-
return _distributedEvents;
23+
return _distributedEvents ?? Array.Empty<DomainEventRecord>();
2424
}
2525

2626
public virtual void ClearLocalEvents()
2727
{
28-
_localEvents.Clear();
28+
_localEvents?.Clear();
2929
}
3030

3131
public virtual void ClearDistributedEvents()
3232
{
33-
_distributedEvents.Clear();
33+
_distributedEvents?.Clear();
3434
}
3535

3636
protected virtual void AddLocalEvent(object eventData)
3737
{
38+
_localEvents ??= new Collection<DomainEventRecord>();
3839
_localEvents.Add(new DomainEventRecord(eventData, EventOrderGenerator.GetNext()));
3940
}
4041

4142
protected virtual void AddDistributedEvent(object eventData)
4243
{
44+
_distributedEvents ??= new Collection<DomainEventRecord>();
4345
_distributedEvents.Add(new DomainEventRecord(eventData, EventOrderGenerator.GetNext()));
4446
}
4547
}
@@ -49,8 +51,8 @@ public abstract class BasicAggregateRoot<TKey> : Entity<TKey>,
4951
IAggregateRoot<TKey>,
5052
IGeneratesDomainEvents
5153
{
52-
private readonly ICollection<DomainEventRecord> _distributedEvents = new Collection<DomainEventRecord>();
53-
private readonly ICollection<DomainEventRecord> _localEvents = new Collection<DomainEventRecord>();
54+
private ICollection<DomainEventRecord>? _distributedEvents;
55+
private ICollection<DomainEventRecord>? _localEvents;
5456

5557
protected BasicAggregateRoot()
5658
{
@@ -65,31 +67,33 @@ protected BasicAggregateRoot(TKey id)
6567

6668
public virtual IEnumerable<DomainEventRecord> GetLocalEvents()
6769
{
68-
return _localEvents;
70+
return _localEvents ?? Array.Empty<DomainEventRecord>();
6971
}
7072

7173
public virtual IEnumerable<DomainEventRecord> GetDistributedEvents()
7274
{
73-
return _distributedEvents;
75+
return _distributedEvents ?? Array.Empty<DomainEventRecord>();
7476
}
7577

7678
public virtual void ClearLocalEvents()
7779
{
78-
_localEvents.Clear();
80+
_localEvents?.Clear();
7981
}
8082

8183
public virtual void ClearDistributedEvents()
8284
{
83-
_distributedEvents.Clear();
85+
_distributedEvents?.Clear();
8486
}
8587

8688
protected virtual void AddLocalEvent(object eventData)
8789
{
90+
_localEvents ??= new Collection<DomainEventRecord>();
8891
_localEvents.Add(new DomainEventRecord(eventData, EventOrderGenerator.GetNext()));
8992
}
9093

9194
protected virtual void AddDistributedEvent(object eventData)
9295
{
96+
_distributedEvents ??= new Collection<DomainEventRecord>();
9397
_distributedEvents.Add(new DomainEventRecord(eventData, EventOrderGenerator.GetNext()));
9498
}
9599
}

0 commit comments

Comments
 (0)