Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit16f174d

Browse files
authored
Bugfix workflow execute dtmfailureexception (#100)
* Change the test method to verify exception handlingChange the test method name to a more accurate description, and update the test logic to expect a 'DtmFailureException' instead of returning 'null'. This enhances the verification of exception handling.* Inside the 'Process' method, a check for the 'err' variable is added to make sure an error is thrown if 'err' is not null. Modify the exception assertion of the 'Rollback_Should_Be_Executed' single test to use 'Assert.ThrowsAsync' to verify whether a 'DtmFailureException' was thrown.
1 parent8c65784 commit16f174d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

‎src/Dtmworkflow/Workflow.Imp.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ internal async Task<byte[]> Process(WfFunc2 handler, byte[] data)
8181
awaitthis.Submit(res,err,default);
8282
}
8383

84+
if(err!=null)
85+
throwerr;
86+
8487
returnres;
8588
}
8689

‎tests/Dtmworkflow.Tests/WorkflowHttpTests.cs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public async void Execute_Should_ThrowException_When_WfFunc2_ThrowException()
141141
}
142142

143143
[Fact]
144-
publicasyncvoidExecute_Should_Return_Null_When_WfFunc2_ThrowDtmFailureException()
144+
publicasyncvoidExecute_Should_ThrowDtmFailureException_When_WfFunc2_ThrowDtmFailureException()
145145
{
146146
varfactory=newMock<IWorkflowFactory>();
147147
varhttpClient=newMock<IDtmClient>();
@@ -161,7 +161,7 @@ public async void Execute_Should_Return_Null_When_WfFunc2_ThrowDtmFailureExcepti
161161

162162
varwfgt=newWorkflowGlobalTransaction(factory.Object,NullLoggerFactory.Instance);
163163

164-
varwfName=nameof(Execute_Should_Return_Null_When_WfFunc2_ThrowDtmFailureException);
164+
varwfName=nameof(Execute_Should_ThrowDtmFailureException_When_WfFunc2_ThrowDtmFailureException);
165165
vargid=Guid.NewGuid().ToString("N");
166166

167167
varhandler=newMock<WfFunc2>();
@@ -170,8 +170,7 @@ public async void Execute_Should_Return_Null_When_WfFunc2_ThrowDtmFailureExcepti
170170
wfgt.Register(wfName,handler.Object);
171171
varreq=JsonSerializer.Serialize(new{userId="1",amount=30});
172172

173-
varres=awaitwfgt.Execute(wfName,gid,Encoding.UTF8.GetBytes(req),true);
174-
Assert.Null(res);
173+
awaitAssert.ThrowsAsync<DtmFailureException>(async()=>awaitwfgt.Execute(wfName,gid,Encoding.UTF8.GetBytes(req),true));
175174
}
176175

177176
[Fact]
@@ -209,7 +208,7 @@ public async void Rollback_Should_Be_Executed()
209208
wfgt.Register(wfName,handler);
210209
varreq=JsonSerializer.Serialize(new{userId="1",amount=30});
211210

212-
varres=awaitwfgt.Execute(wfName,gid,Encoding.UTF8.GetBytes(req),true);
211+
varres=awaitAssert.ThrowsAsync<DtmFailureException>(async()=>awaitwfgt.Execute(wfName,gid,Encoding.UTF8.GetBytes(req),true));
213212

214213
func.Verify(x=>x.Invoke(It.IsAny<BranchBarrier>()),Times.Once);
215214
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp