Skip to content

Commit d113838

Browse files
committed
Added IActorStateManager actorStateManager parameter to the contructor of DemoActor
1 parent 82df84e commit d113838

File tree

2 files changed

+44
-24
lines changed

2 files changed

+44
-24
lines changed
Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
77

8-
<IsPackable>false</IsPackable>
9-
<IsTestProject>true</IsTestProject>
10-
</PropertyGroup>
8+
<IsPackable>false</IsPackable>
9+
<IsTestProject>true</IsTestProject>
10+
</PropertyGroup>
1111

12-
<ItemGroup>
13-
<PackageReference Include="coverlet.collector" Version="3.2.0" />
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
15-
<PackageReference Include="Moq" Version="4.20.70" />
16-
<PackageReference Include="xunit" Version="2.4.2" />
17-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
18-
</ItemGroup>
12+
<ItemGroup>
13+
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
14+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15+
<PrivateAssets>all</PrivateAssets>
16+
</PackageReference>
17+
<PackageReference Include="coverlet.collector" Version="3.2.0" />
18+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
19+
<PackageReference Include="Moq" Version="4.20.70" />
20+
<PackageReference Include="xunit" Version="2.4.2" />
21+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
22+
</ItemGroup>
1923

20-
<ItemGroup>
21-
<ProjectReference Include="..\DemoActor\DemoActor.csproj" />
22-
</ItemGroup>
24+
<ItemGroup>
25+
<ProjectReference Include="..\DemoActor\DemoActor.csproj" />
26+
</ItemGroup>
2327

24-
<ItemGroup>
25-
<Using Include="Xunit" />
26-
</ItemGroup>
28+
<ItemGroup>
29+
<Using Include="Xunit" />
30+
</ItemGroup>
2731

2832
</Project>

examples/Actor/DemoActor/DemoActor.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,28 @@ public class DemoActor : Actor, IDemoActor, IBankActor, IRemindable
3333

3434
private readonly BankService bank;
3535

36-
public DemoActor(ActorHost host, BankService bank)
36+
/// <summary>
37+
/// Initializes a new instance of <see cref="DemoActor"/>.
38+
/// </summary>
39+
/// <param name="host">ActorHost.</param>
40+
/// <param name="bank">BankService.</param>
41+
/// <param name="actorStateManager">ActorStateManager used in UnitTests.</param>
42+
public DemoActor(
43+
ActorHost host,
44+
BankService bank,
45+
IActorStateManager actorStateManager = null)
3746
: base(host)
3847
{
3948
// BankService is provided by dependency injection.
4049
// See Program.cs
4150
this.bank = bank;
51+
52+
// Assign ActorStateManager when passed as parameter.
53+
// This is used in UnitTests.
54+
if (actorStateManager != null)
55+
{
56+
this.StateManager = actorStateManager;
57+
}
4258
}
4359

4460
public async Task SaveData(MyData data, TimeSpan ttl)
@@ -74,12 +90,12 @@ public async Task RegisterReminderWithTtl(TimeSpan ttl)
7490
{
7591
await this.RegisterReminderAsync("TestReminder", null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5), ttl);
7692
}
77-
93+
7894
public async Task RegisterReminderWithRepetitions(int repetitions)
7995
{
8096
await this.RegisterReminderAsync("TestReminder", null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1), repetitions);
8197
}
82-
98+
8399
public async Task RegisterReminderWithTtlAndRepetitions(TimeSpan ttl, int repetitions)
84100
{
85101
await this.RegisterReminderAsync("TestReminder", null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1), repetitions, ttl);
@@ -98,7 +114,7 @@ public async Task<ActorReminderData> GetReminder()
98114
}
99115
: null;
100116
}
101-
117+
102118
public Task UnregisterReminder()
103119
{
104120
return this.UnregisterReminderAsync("TestReminder");

0 commit comments

Comments
 (0)