elsa-workflows / elsa-workflows/elsa-core
Output of Write activity that is using context is not captured in tests
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
## Description
I am trying to diagnose a problem and to improve test created for PR. The output of `Write` activity that is using context is not captured in tests.
The `Write` activity is defined as follows
```
new WriteLine(context => $"Running subroutine, " +
$"correlation id is '" + context.GetWorkflowExecutionContext().CorrelationId + "'.")
{
Id = "WriteLine ChildWorkflow"
},
```
And `CapturingTextWriter` captures the following
```
"Start Parent",
"Start ChildWorkflow",
""
"Finish ChildWorkflow",
"Finish Parent"
```
## Steps to Reproduce
Attached is the executable test, place in it `Elsa.Workflows.IntegrationTests.Scenarios.RunAsynchronousActivityOutput` namespace.
1. **Detailed Steps**: Run the attached test
2. **Code Snippets**: If the issue involves code (e.g., JavaScript error, server request failure), include the relevant snippets where the issue occurs.
3. **Attachments**:
- **Test**: [Test.cs.txt](https://github.com/user-attachments/files/20687423/Test.cs.txt)
- **Dispatch extensions**: to set correlation id and register additional workflows [DispatchWorkflowExtensions.cs.txt](https://github.com/user-attachments/files/20687440/DispatchWorkflowExtensions.cs.txt)
4. **Reproduction Rate**: every time
## Expected Behavior
`CapturingTextWriter` should capture
```
"Start Parent",
"Start ChildWorkflow",
"Running subroutine, correlation id is 'test-correlation-id'.",
"Finish ChildWorkflow",
"Finish Parent"
```
## Actual Behavior
Output from child activity is not captured.
## Environment
- **Elsa Package Version**: I am using the latest source code (last commit hash is 5fbe2775681e916e22b13b254d7a063802437783)
- **Operating System**: Windows 10
## Troubleshooting Attempts
I tried to debug it and found out that different instances of `Write` activity are used.
When constructor is invoked (see the source)

And when activity is executed - source matches, but `Text` is null:

Contributor guide
Assessment
This issue has not been assessed yet.