-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathAttachmentTracker.cs
More file actions
46 lines (38 loc) · 1.71 KB
/
Copy pathAttachmentTracker.cs
File metadata and controls
46 lines (38 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Io.Cucumber.Messages.Types;
using Reqnroll.Formatters.PayloadProcessing.Cucumber;
using Reqnroll.Events;
using System;
using System.Threading.Tasks;
using Reqnroll.Formatters.PubSub;
namespace Reqnroll.Formatters.ExecutionTracking;
/// <summary>
/// Tracks the addition of a particular attachment. The <see cref="TestCaseStartedId"/> and <see cref="TestCaseStepId"/> are optional,
/// they are only filled out if the attachment is added in a scope of a scenario or step/hook execution.
/// </summary>
public class AttachmentTracker
{
private readonly ICucumberMessageFactory _messageFactory;
public string TestRunStartedId { get; }
public string TestCaseStartedId { get; }
public string TestCaseStepId { get; }
public string TestRunHookStartedId { get; }
private readonly IMessagePublisher _publisher;
public string FilePath { get; private set; }
public DateTime Timestamp { get; private set; }
internal AttachmentTracker(string testRunStartedId, string testCaseStartedId, string testCaseStepId, string testRunHookStartedId, ICucumberMessageFactory messageFactory, IMessagePublisher publisher)
{
_messageFactory = messageFactory;
TestRunStartedId = testRunStartedId;
TestCaseStartedId = testCaseStartedId;
TestCaseStepId = testCaseStepId;
TestRunHookStartedId = testRunHookStartedId;
_publisher = publisher;
}
public async Task ProcessEvent(AttachmentAddedEvent attachmentAddedEvent)
{
FilePath = attachmentAddedEvent.FilePath;
Timestamp = attachmentAddedEvent.Timestamp;
if (_messageFactory.TryCreateAttachmentEnvelope(this, out var envelope))
await _publisher.PublishAsync(envelope);
}
}