Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 134558c

Browse files
Adding a task integration test that demonstrates the execution order of OnStart and OnEnd
1 parent 592687c commit 134558c

File tree

1 file changed

+38
-0
lines changed
  • src/tests/TaskSystemIntegrationTests

1 file changed

+38
-0
lines changed

src/tests/TaskSystemIntegrationTests/Tests.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,44 @@ public async Task ProcessReadsFromStandardInput()
108108
Assert.AreEqual(expectedOutput, output);
109109
}
110110

111+
[Test]
112+
public async Task ProcessOnStartOnEndTaskOrder()
113+
{
114+
var values = new List<string>();
115+
string process1Value = null;
116+
string process2Value = null;
117+
118+
var process1Task = new FirstNonNullLineProcessTask(Token, TestApp, @"-s 100 -d process1")
119+
.Configure(ProcessManager, true).Then((b, s) => {
120+
process1Value = s;
121+
values.Add(s);
122+
});
123+
124+
var process2Task = new FirstNonNullLineProcessTask(Token, TestApp, @"-s 100 -d process2")
125+
.Configure(ProcessManager, true).Then((b, s) => {
126+
process2Value = s;
127+
values.Add(s);
128+
});
129+
130+
var combinedTask = process1Task
131+
.Then(process2Task);
132+
133+
combinedTask.OnStart += task => {
134+
values.Add("OnStart");
135+
};
136+
137+
combinedTask.OnEnd += task => {
138+
values.Add("OnEnd");
139+
};
140+
141+
await combinedTask
142+
.StartAsAsync();
143+
144+
Assert.AreEqual(process1Value, "process1");
145+
Assert.AreEqual(process2Value, "process2");
146+
Assert.True(values.SequenceEqual(new []{ "process1", "OnStart", "process2", "OnEnd" }));
147+
}
148+
111149
[Test]
112150
public async Task ProcessReturningErrorThrowsException()
113151
{

0 commit comments

Comments
 (0)