Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 58 additions & 34 deletions src/core/Akka.TestKit/EventFilter/IEventFilterApplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//-----------------------------------------------------------------------

using System;
using System.Threading;
using System.Threading.Tasks;

namespace Akka.TestKit
Expand All @@ -24,8 +25,9 @@ public interface IEventFilterApplier
/// "akka.test.filter-leeway", see <see cref="TestKitSettings.TestEventFilterLeeway"/>.
/// </summary>
/// <param name="action">The action.</param>
void ExpectOne(Action action);

/// <param name="cancellationToken"></param>
void ExpectOne(Action action, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="action"/> and
/// expects one event to be logged during the execution.
Expand All @@ -34,8 +36,9 @@ public interface IEventFilterApplier
/// "akka.test.filter-leeway", see <see cref="TestKitSettings.TestEventFilterLeeway"/>.
/// </summary>
/// <param name="action">The action.</param>
Task ExpectOneAsync(Action action);

/// <param name="cancellationToken"></param>
Task ExpectOneAsync(Action action, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="actionAsync"/> and
/// expects one event to be logged during the execution.
Expand All @@ -44,7 +47,8 @@ public interface IEventFilterApplier
/// "akka.test.filter-leeway", see <see cref="TestKitSettings.TestEventFilterLeeway"/>.
/// </summary>
/// <param name="actionAsync">The action.</param>
Task ExpectOneAsync(Func<Task> actionAsync);
/// <param name="cancellationToken"></param>
Task ExpectOneAsync(Func<Task> actionAsync, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="action"/> and
Expand All @@ -54,8 +58,9 @@ public interface IEventFilterApplier
/// </summary>
/// <param name="timeout">The time to wait for a log event after executing <paramref name="action"/></param>
/// <param name="action">The action.</param>
void ExpectOne(TimeSpan timeout, Action action);

/// <param name="cancellationToken"></param>
void ExpectOne(TimeSpan timeout, Action action, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="action"/> and
/// expects one event to be logged during the execution.
Expand All @@ -64,8 +69,9 @@ public interface IEventFilterApplier
/// </summary>
/// <param name="timeout">The time to wait for a log event after executing <paramref name="action"/></param>
/// <param name="action">The action.</param>
Task ExpectOneAsync(TimeSpan timeout, Action action);

/// <param name="cancellationToken"></param>
Task ExpectOneAsync(TimeSpan timeout, Action action, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="action"/> and expects the specified number
/// of events to be logged during the execution.
Expand All @@ -75,8 +81,9 @@ public interface IEventFilterApplier
/// </summary>
/// <param name="expectedCount">The expected number of events</param>
/// <param name="action">The action.</param>
void Expect(int expectedCount, Action action);

/// <param name="cancellationToken"></param>
void Expect(int expectedCount, Action action, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="action"/> and expects the specified number
/// of events to be logged during the execution.
Expand All @@ -86,7 +93,8 @@ public interface IEventFilterApplier
/// </summary>
/// <param name="expectedCount">The expected number of events</param>
/// <param name="action">The action.</param>
Task ExpectAsync(int expectedCount, Action action);
/// <param name="cancellationToken"></param>
Task ExpectAsync(int expectedCount, Action action, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="actionAsync"/> task and expects the specified number
Expand All @@ -97,7 +105,8 @@ public interface IEventFilterApplier
/// </summary>
/// <param name="expectedCount">The expected number of events</param>
/// <param name="actionAsync">The async action.</param>
Task ExpectAsync(int expectedCount, Func<Task> actionAsync);
/// <param name="cancellationToken"></param>
Task ExpectAsync(int expectedCount, Func<Task> actionAsync, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="actionAsync"/> task and expects the specified number
Expand All @@ -109,7 +118,8 @@ public interface IEventFilterApplier
/// <param name="expectedCount">The expected number of events</param>
/// <param name="actionAsync">The async action.</param>
/// <param name="timeout"></param>
Task ExpectAsync(int expectedCount, Func<Task> actionAsync, TimeSpan? timeout);
/// <param name="cancellationToken"></param>
Task ExpectAsync(int expectedCount, Func<Task> actionAsync, TimeSpan? timeout, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="action"/> and expects the specified number
Expand All @@ -121,8 +131,9 @@ public interface IEventFilterApplier
/// <param name="timeout">The time to wait for log events after executing <paramref name="action"/></param>
/// <param name="expectedCount">The expected number of events</param>
/// <param name="action">The action.</param>
void Expect(int expectedCount, TimeSpan timeout, Action action);

/// <param name="cancellationToken"></param>
void Expect(int expectedCount, TimeSpan timeout, Action action, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="action"/> and expects the specified number
/// of events to be logged during the execution.
Expand All @@ -133,7 +144,8 @@ public interface IEventFilterApplier
/// <param name="timeout">The time to wait for log events after executing <paramref name="action"/></param>
/// <param name="expectedCount">The expected number of events</param>
/// <param name="action">The action.</param>
Task ExpectAsync(int expectedCount, TimeSpan timeout, Action action);
/// <param name="cancellationToken"></param>
Task ExpectAsync(int expectedCount, TimeSpan timeout, Action action, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="func"/> and
Expand All @@ -144,9 +156,10 @@ public interface IEventFilterApplier
/// </summary>
/// <typeparam name="T">The return value of the function</typeparam>
/// <param name="func">The function.</param>
/// <param name="cancellationToken"></param>
/// <returns>The returned value from <paramref name="func"/>.</returns>
T ExpectOne<T>(Func<T> func);
T ExpectOne<T>(Func<T> func, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="func"/> and
/// expects one event to be logged during the execution.
Expand All @@ -156,8 +169,9 @@ public interface IEventFilterApplier
/// </summary>
/// <typeparam name="T">The return value of the function</typeparam>
/// <param name="func">The function.</param>
/// <param name="cancellationToken"></param>
/// <returns>The returned value from <paramref name="func"/>.</returns>
Task<T> ExpectOneAsync<T>(Func<T> func);
Task<T> ExpectOneAsync<T>(Func<T> func, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="func"/> and
Expand All @@ -168,9 +182,10 @@ public interface IEventFilterApplier
/// <typeparam name="T">The return value of the function</typeparam>
/// <param name="timeout">The time to wait for a log event after executing <paramref name="func"/></param>
/// <param name="func">The function.</param>
/// <param name="cancellationToken"></param>
/// <returns>The returned value from <paramref name="func"/>.</returns>
T ExpectOne<T>(TimeSpan timeout, Func<T> func);
T ExpectOne<T>(TimeSpan timeout, Func<T> func, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="func"/> and
/// expects one event to be logged during the execution.
Expand All @@ -180,8 +195,9 @@ public interface IEventFilterApplier
/// <typeparam name="T">The return value of the function</typeparam>
/// <param name="timeout">The time to wait for a log event after executing <paramref name="func"/></param>
/// <param name="func">The function.</param>
/// <param name="cancellationToken"></param>
/// <returns>The returned value from <paramref name="func"/>.</returns>
Task<T> ExpectOneAsync<T>(TimeSpan timeout, Func<T> func);
Task<T> ExpectOneAsync<T>(TimeSpan timeout, Func<T> func, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="func"/> and expects the specified number
Expand All @@ -193,8 +209,9 @@ public interface IEventFilterApplier
/// <typeparam name="T">The return value of the function</typeparam>
/// <param name="expectedCount">The expected number of events</param>
/// <param name="func">The function.</param>
/// <param name="cancellationToken"></param>
/// <returns>The returned value from <paramref name="func"/>.</returns>
T Expect<T>(int expectedCount, Func<T> func);
T Expect<T>(int expectedCount, Func<T> func, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="func"/> and expects the specified number
Expand All @@ -207,8 +224,9 @@ public interface IEventFilterApplier
/// <typeparam name="T">The return value of the function</typeparam>
/// <param name="expectedCount">The expected number of events</param>
/// <param name="func">The function.</param>
/// <param name="cancellationToken"></param>
/// <returns>The returned value from <paramref name="func"/>.</returns>
Task<T> ExpectAsync<T>(int expectedCount, Func<T> func);
Task<T> ExpectAsync<T>(int expectedCount, Func<T> func, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="func"/> and expects the specified number
Expand All @@ -221,9 +239,10 @@ public interface IEventFilterApplier
/// <param name="timeout">The time to wait for log events after executing <paramref name="func"/></param>
/// <param name="expectedCount">The expected number of events</param>
/// <param name="func">The function.</param>
/// <param name="cancellationToken"></param>
/// <returns>The returned value from <paramref name="func"/>.</returns>
T Expect<T>(int expectedCount, TimeSpan timeout, Func<T> func);
T Expect<T>(int expectedCount, TimeSpan timeout, Func<T> func, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="func"/> and expects the specified number
/// of events to be logged during the execution.
Expand All @@ -235,38 +254,43 @@ public interface IEventFilterApplier
/// <param name="timeout">The time to wait for log events after executing <paramref name="func"/></param>
/// <param name="expectedCount">The expected number of events</param>
/// <param name="func">The function.</param>
/// <param name="cancellationToken"></param>
/// <returns>The returned value from <paramref name="func"/>.</returns>
Task<T> ExpectAsync<T>(int expectedCount, TimeSpan timeout, Func<T> func);
Task<T> ExpectAsync<T>(int expectedCount, TimeSpan timeout, Func<T> func, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="func"/> and prevent events from being logged during the execution.
/// </summary>
/// <typeparam name="T">The return value of the function</typeparam>
/// <param name="func">The function.</param>
/// <param name="cancellationToken"></param>
/// <returns>The returned value from <paramref name="func"/>.</returns>
T Mute<T>(Func<T> func);
T Mute<T>(Func<T> func, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="func"/> and prevent events from being logged during the execution.
/// </summary>
/// <typeparam name="T">The return value of the function</typeparam>
/// <param name="func">The function.</param>
/// <param name="cancellationToken"></param>
/// <returns>The returned value from <paramref name="func"/>.</returns>
Task<T> MuteAsync<T>(Func<T> func);
Task<T> MuteAsync<T>(Func<T> func, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="action"/> and prevent events from being logged during the execution.
/// </summary>
/// <param name="action">The function.</param>
/// <param name="cancellationToken"></param>
/// <returns>The returned value from <paramref name="action"/>.</returns>
void Mute(Action action);
void Mute(Action action, CancellationToken cancellationToken = default);

/// <summary>
/// Executes <paramref name="action"/> and prevent events from being logged during the execution.
/// </summary>
/// <param name="action">The function.</param>
/// <param name="cancellationToken"></param>
/// <returns>The returned value from <paramref name="action"/>.</returns>
Task MuteAsync(Action action);
Task MuteAsync(Action action, CancellationToken cancellationToken = default);

/// <summary>
/// Prevents events from being logged from now on. To allow events to be logged again, call
Expand Down
Loading