Skip to content

Commit

Permalink
Rename AtataSessionDeInitEvent to AtataSessionDeInitStartedEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
YevgeniyShunevych committed Jan 16, 2025
1 parent 0b5a50d commit 357b9e1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
5 changes: 4 additions & 1 deletion src/Atata/Context/AtataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,10 @@ public void SetAsCurrent()
/// Also writes the execution time to log.
/// Throws <see cref="AggregateAssertionException"/> if
/// <see cref="PendingFailureAssertionResults"/> is not empty (contains warnings).
/// Publishes events: <see cref="AtataContextDeInitEvent"/>, <see cref="AtataSessionDeInitEvent"/> (for sessions), <see cref="AtataContextDeInitCompletedEvent"/>.
/// Publishes events: <see cref="AtataContextDeInitEvent"/>,
/// <see cref="AtataSessionDeInitStartedEvent"/> (for sessions),
/// <see cref="AtataSessionDeInitCompletedEvent"/> (for sessions)
/// <see cref="AtataContextDeInitCompletedEvent"/>.
/// </summary>
public void Dispose()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Atata/Context/Sessions/AtataSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ await Log.ExecuteSectionAsync(
{
try
{
await EventBus.PublishAsync(new AtataSessionDeInitEvent(this))
await EventBus.PublishAsync(new AtataSessionDeInitStartedEvent(this))
.ConfigureAwait(false);
}
finally
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace Atata;

/// <summary>
/// Represents an event that occurs when <see cref="AtataSession"/> is deinitializing.
/// Represents an event that occurs when <see cref="AtataSession"/> is started to deinitialize.
/// </summary>
public sealed class AtataSessionDeInitEvent
public sealed class AtataSessionDeInitStartedEvent
{
internal AtataSessionDeInitEvent(AtataSession session) =>
internal AtataSessionDeInitStartedEvent(AtataSession session) =>
Session = session;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
namespace Atata;

public sealed class TakePageSnapshotOnNUnitErrorEventHandler : IConditionalEventHandler<AtataSessionDeInitEvent>
public sealed class TakePageSnapshotOnNUnitErrorEventHandler : IConditionalEventHandler<AtataSessionDeInitStartedEvent>
{
private readonly string _snapshotTitle;

public TakePageSnapshotOnNUnitErrorEventHandler(string snapshotTitle = "Failed") =>
_snapshotTitle = snapshotTitle;

public bool CanHandle(AtataSessionDeInitEvent eventData, AtataContext context) =>
public bool CanHandle(AtataSessionDeInitStartedEvent eventData, AtataContext context) =>
NUnitAdapter.IsCurrentTestFailed() && eventData.Session.IsActive;

public void Handle(AtataSessionDeInitEvent eventData, AtataContext context) =>
public void Handle(AtataSessionDeInitStartedEvent eventData, AtataContext context) =>
(eventData.Session as WebSession)?.TakePageSnapshot(_snapshotTitle);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Atata;

public sealed class TakeScreenshotOnNUnitErrorEventHandler : IConditionalEventHandler<AtataSessionDeInitEvent>
public sealed class TakeScreenshotOnNUnitErrorEventHandler : IConditionalEventHandler<AtataSessionDeInitStartedEvent>
{
private readonly ScreenshotKind _screenshotKind;

Expand All @@ -17,9 +17,9 @@ public TakeScreenshotOnNUnitErrorEventHandler(ScreenshotKind screenshotKind, str
_screenshotTitle = screenshotTitle;
}

public bool CanHandle(AtataSessionDeInitEvent eventData, AtataContext context) =>
public bool CanHandle(AtataSessionDeInitStartedEvent eventData, AtataContext context) =>
NUnitAdapter.IsCurrentTestFailed() && eventData.Session.IsActive;

public void Handle(AtataSessionDeInitEvent eventData, AtataContext context) =>
public void Handle(AtataSessionDeInitStartedEvent eventData, AtataContext context) =>
(eventData.Session as WebSession)?.TakeScreenshot(_screenshotKind, _screenshotTitle);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public async Task OrderOfExecution()
session.EventSubscriptions.Add<AtataSessionUnassignedFromContextEvent>(
x => x.Session.Log.Info(nameof(AtataSessionUnassignedFromContextEvent)));

session.EventSubscriptions.Add<AtataSessionDeInitEvent>(
x => x.Session.Log.Info(nameof(AtataSessionDeInitEvent)));
session.EventSubscriptions.Add<AtataSessionDeInitStartedEvent>(
x => x.Session.Log.Info(nameof(AtataSessionDeInitStartedEvent)));

session.EventSubscriptions.Add<AtataSessionDeInitCompletedEvent>(
x => x.Session.Log.Info(nameof(AtataSessionDeInitCompletedEvent)));
Expand Down Expand Up @@ -68,7 +68,7 @@ public async Task OrderOfExecution()
AtataSessionAssignedToContextEvent
FakeSession { * } is returned by AtataContext { * }
> Deinitialize FakeSession { * }
- AtataSessionDeInitEvent
- AtataSessionDeInitStartedEvent
- AtataSessionDeInitCompletedEvent
< Deinitialize FakeSession { * } (*)
""");
Expand Down

0 comments on commit 357b9e1

Please sign in to comment.