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
Showing
9 changed files
with
332 additions
and
35 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
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,59 @@ | ||
using System; | ||
|
||
namespace FluentAssertions.Events; | ||
|
||
/// <summary> | ||
/// Settings for the EventMonitor. | ||
/// </summary> | ||
public class EventMonitorOptions | ||
{ | ||
/// <summary> | ||
/// Will ignore the events, if they throw an exception on any custom event accessor implementation. default: false. | ||
/// </summary> | ||
internal bool ShouldIgnoreEventAccessorExceptions { get; private set; } | ||
|
||
/// <summary> | ||
/// This will record the event, even if the event accessor add event threw an exception. To ignore exceptions in the event add accessor, call <see cref="IgnoreEventAccessorExceptions"/> property to set it to true. default: false. | ||
/// </summary> | ||
internal bool ShouldRecordEventsWithBrokenAccessor { get; private set; } | ||
|
||
/// <summary> | ||
/// Func used to generate the timestamp. | ||
/// </summary> | ||
internal Func<DateTime> TimestampProvider { get; private set; } = () => DateTime.UtcNow; | ||
|
||
/// <summary> | ||
/// When called it will ignore event accessor Exceptions. | ||
/// </summary> | ||
/// <returns>The options instance for method stacking.</returns> | ||
public EventMonitorOptions IgnoreEventAccessorExceptions() | ||
{ | ||
ShouldIgnoreEventAccessorExceptions = true; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// When called it will record the event even when the accessor threw an exception. | ||
/// </summary> | ||
/// <returns>The options instance for method stacking.</returns> | ||
public EventMonitorOptions RecordEventsWithBrokenAccessor() | ||
{ | ||
ShouldRecordEventsWithBrokenAccessor = true; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Sets the timestamp provider. By default it is <see cref="DateTime.UtcNow"/>. | ||
/// </summary> | ||
/// <param name="timestampProvider">The timestamp provider.</param> | ||
/// <returns>The options instance for method stacking.</returns> | ||
internal EventMonitorOptions ConfigureTimestampProvider(Func<DateTime> timestampProvider) | ||
{ | ||
if (timestampProvider != null) | ||
{ | ||
TimestampProvider = timestampProvider; | ||
} | ||
|
||
return this; | ||
} | ||
} |
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.