-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80976ee
commit 541bab1
Showing
19 changed files
with
703 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ Nixie.Tests/bin | |
Nixie.Tests/obj | ||
.vs/ | ||
.DS_Store | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
namespace Nixie.Tests.Actors; | ||
|
||
public sealed class PeriodicTimerActorStruct : IActorStruct<int> | ||
{ | ||
private readonly Dictionary<int, int> receivedMessages = new(); | ||
|
||
public PeriodicTimerActorStruct(IActorContextStruct<PeriodicTimerActorStruct, int> context) | ||
{ | ||
context.ActorSystem.StartPeriodicTimerStruct(context.Self, "periodic-timer", 100, TimeSpan.Zero, TimeSpan.FromSeconds(1)); | ||
} | ||
|
||
public int GetMessages(int id) | ||
{ | ||
return receivedMessages.GetValueOrDefault(id, 0); | ||
} | ||
|
||
private void IncrMessage(int id) | ||
{ | ||
if (!receivedMessages.TryGetValue(id, out int value)) | ||
receivedMessages.Add(id, 1); | ||
else | ||
receivedMessages[id] = ++value; | ||
} | ||
|
||
public async Task Receive(int message) | ||
{ | ||
await Task.CompletedTask; | ||
|
||
IncrMessage(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace Nixie.Tests.Actors; | ||
|
||
public sealed class ShutdownReplyActor : IActor<string, string> | ||
{ | ||
private int receivedMessages; | ||
|
||
public ShutdownReplyActor(IActorContext<ShutdownReplyActor, string, string> _) | ||
{ | ||
|
||
} | ||
|
||
public int GetMessages() | ||
{ | ||
return receivedMessages; | ||
} | ||
|
||
private void IncrMessage() | ||
{ | ||
receivedMessages++; | ||
} | ||
|
||
public async Task<string?> Receive(string message) | ||
{ | ||
await Task.Yield(); | ||
|
||
IncrMessage(); | ||
|
||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
namespace Nixie.Tests.Actors; | ||
|
||
public sealed class ShutdownSlowActor : IActor<string> | ||
{ | ||
private int receivedMessages; | ||
|
||
public ShutdownSlowActor(IActorContext<ShutdownSlowActor, string> _) | ||
{ | ||
|
||
} | ||
|
||
public int GetMessages() | ||
{ | ||
return receivedMessages; | ||
} | ||
|
||
private void IncrMessage() | ||
{ | ||
receivedMessages++; | ||
} | ||
|
||
public async Task Receive(string message) | ||
{ | ||
await Task.Delay(1000); | ||
|
||
IncrMessage(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.