Skip to content

Commit 2c69299

Browse files
committed
Fix corrupted test file and restore unit test for DefaultActivityExecutionMapper
- Recreated `DefaultActivityExecutionMapperTests` to fix compilation issues due to corrupted code. - Restored unit test `MapAsync_SetsCallStackDepth_FromContext` ensuring proper handling of `CallStackDepth`.
1 parent 29531c0 commit 2c69299

2 files changed

Lines changed: 88 additions & 33 deletions

File tree

test/unit/Elsa.Workflows.Runtime.UnitTests/Services/DefaultActivityExecutionMapperTests.cs

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,38 @@ public class DefaultActivityExecutionMapperTests
1919
private readonly Mock<ICompressionCodecResolver> _compressionCodecResolverMock = new();
2020
private readonly Mock<IOptions<ManagementOptions>> _optionsMock = new();
2121
private readonly DefaultActivityExecutionMapper _sut;
22-
using Elsa.Common;
23-
using Elsa.Common.Codecs;
24-
using Elsa.Workflows.Management.Options;
25-
using Elsa.Workflows.Runtime;
26-
using Microsoft.Extensions.Options;
27-
using Moq;
28-
using Xupusing Elsa.Commont.using Elsa.Workflows.Mans(using Elsa.Workflows.Runtime;
29-
using Mic using Microsoft.Extensions.Oviusing Moq;
30-
using Xunit;
31-
using Elsafeusing XunrMusing Elsa.
32-
using Elsa.Workflows;
33-
using Micckusing Microsoft.Exte _using System.Collections.Generic;
34-
using System _optionsMock.Object);
35-
}
36-
[using public async Task Manamespace Elsa.Workflows.rectly_WhenCircularReferenceExists()
22+
23+
public DefaultActivityExecutionMapperTests()
3724
{
38-
// A{
39-
private readonly Mock<ISafeSerializer> _s;
40-
private readonly Mock<IPayloadSerializer> _payloadSerializerMock =Ro private readonly Mock<ICompressionCodecResolver> _compressionCodecResolvon private readonly Mock<IOptions<ManagementOptions>> _optionsMock = new();
41-
private ron private readonly DefaultActivityExecutionMapper _sut;
42-
using Elsa.Commoty using Elsa.Common;
43-
using Elsa.Common.Codecs;
44-
usiefault);
45-
using Elsa.Common.tB = new ActivityExecutionCousing El", w, null, root, contextRoot.Actusing Microsoft.Extensions.O.Susing Moq;
46-
using Xupusing Elsa.Com using Xupreusing Mic using Microsoft.Extensions.Oviusing Moq;
47-
using Xunit;
48-
using Elsafeusing using Xunit;
49-
using Elsafeusing XunrMusing Elsa.
50-
using Elsafis using Elsa.Workflows;
51-
using Micc eusing Micckusing using System _optionsMock.Object);
25+
_optionsMock.Setup(x => x.Value).Returns(new ManagementOptions());
26+
_compressionCodecResolverMock.Setup(x => x.Resolve(It.IsAny<string>())).Returns(new Mock<ICompressionCodec>().Object);
27+
28+
_sut = new DefaultActivityExecutionMapper(
29+
_safeSerializerMock.Object,
30+
_payloadSerializerMock.Object,
31+
_compressionCodecResolverMock.Object,
32+
_optionsMock.Object);
5233
}
53-
[using ActivityExe }
54-
[using public async T A {
55-
record = await _sut.MapAsync(contextA);
34+
35+
[Fact]
36+
public async Task MapAsync_SetsCallStackDepth_FromContext()
37+
{
38+
// Arrange
39+
var root = new WriteLine("root");
40+
var fixture = new ActivityTestFixture(root);
41+
var contextRoot = await fixture.BuildAsync();
42+
var w = contextRoot.WorkflowExecutionContext;
43+
var clock = contextRoot.GetRequiredService<ISystemClock>();
44+
45+
var contextA = new ActivityExecutionContext("A", w, null, root, contextRoot.ActivityDescriptor, contextRoot.StartedAt, null, clock, default)
46+
{
47+
CallStackDepth = 5
48+
};
49+
50+
// Act
51+
var record = await _sut.MapAsync(contextA);
52+
5653
// Assert
57-
Assert.Equal(2, record.CallStackDepth);
54+
Assert.Equal(5, record.CallStackDepth);
5855
}
5956
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using Elsa.Common;
2+
using Elsa.Common.Codecs;
3+
using Elsa.Workflows.Management.Options;
4+
using Elsa.Workflows.Runtime;
5+
using Microsoft.Extensions.Options;
6+
using Moq;
7+
using Xunit;
8+
using Elsa.Workflows.Activities;
9+
using Elsa.Workflows;
10+
using Microsoft.Extensions.DependencyInjection;
11+
using System.Collections.Generic;
12+
using System.Threading.Tasks;
13+
using Elsa.Testing.Shared;
14+
15+
namespace Elsa.Workflows.Runtime.UnitTests.Services;
16+
17+
public class DefaultActivityExecutionMapperTests
18+
{
19+
private readonly Mock<ISafeSerializer> _safeSerializerMock = new();
20+
private readonly Mock<IPayloadSerializer> _payloadSerializerMock = new();
21+
private readonly Mock<ICompressionCodecResolver> _compressionCodecResolverMock = new();
22+
private readonly Mock<IOptions<ManagementOptions>> _optionsMock = new();
23+
private readonly DefaultActivityExecutionMapper _sut;
24+
25+
public DefaultActivityExecutionMapperTests()
26+
{
27+
_optionsMock.Setup(x => x.Value).Returns(new ManagementOptions());
28+
_compressionCodecResolverMock.Setup(x => x.Resolve(It.IsAny<string>())).Returns(new Mock<ICompressionCodec>().Object);
29+
30+
_sut = new DefaultActivityExecutionMapper(
31+
_safeSerializerMock.Object,
32+
_payloadSerializerMock.Object,
33+
_compressionCodecResolverMock.Object,
34+
_optionsMock.Object);
35+
}
36+
37+
[Fact]
38+
public async Task MapAsync_SetsCallStackDepth_FromContext()
39+
{
40+
// Arrange
41+
var root = new WriteLine("root");
42+
var fixture = new ActivityTestFixture(root);
43+
var contextRoot = await fixture.BuildAsync();
44+
var w = contextRoot.WorkflowExecutionContext;
45+
var clock = contextRoot.GetRequiredService<ISystemClock>();
46+
47+
var contextA = new ActivityExecutionContext("A", w, null, root, contextRoot.ActivityDescriptor, contextRoot.StartedAt, null, clock, default)
48+
{
49+
CallStackDepth = 5
50+
};
51+
52+
// Act
53+
var record = await _sut.MapAsync(contextA);
54+
55+
// Assert
56+
Assert.Equal(5, record.CallStackDepth);
57+
}
58+
}

0 commit comments

Comments
 (0)