You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/JsonRpc.Tests/ProcessSchedulerTests.cs
+18-12Lines changed: 18 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ public void ShouldScheduleCompletedTask(RequestProcessType type)
33
33
done.Signal();
34
34
returnTask.CompletedTask;
35
35
});
36
-
done.Wait(ALONGTIME_MS).Should().Be(true);
36
+
done.Wait(ALONGTIME_MS).Should().Be(true,because:"all tasks have to run");
37
37
}
38
38
}
39
39
@@ -48,7 +48,7 @@ public void ShouldScheduleAwaitableTask(RequestProcessType type)
48
48
awaitTask.Yield();
49
49
done.Signal();
50
50
});
51
-
done.Wait(ALONGTIME_MS).Should().Be(true);
51
+
done.Wait(ALONGTIME_MS).Should().Be(true,because:"all tasks have to run");
52
52
}
53
53
}
54
54
@@ -64,7 +64,7 @@ public void ShouldScheduleConstructedTask(RequestProcessType type)
64
64
done.Signal();
65
65
});
66
66
});
67
-
done.Wait(ALONGTIME_MS).Should().Be(true);
67
+
done.Wait(ALONGTIME_MS).Should().Be(true,because:"all tasks have to run");
68
68
}
69
69
}
70
70
@@ -89,9 +89,11 @@ public void ShouldScheduleSerialInOrder()
89
89
for(vari=0;i<done.CurrentCount;i++)
90
90
s.Add(RequestProcessType.Serial,HandlePeek);
91
91
92
-
done.Wait(ALONGTIME_MS).Should().Be(true);
93
-
running.Should().Be(0);
94
-
peek.Should().Be(1);
92
+
done.Wait(ALONGTIME_MS).Should().Be(true,because:"all tasks have to run");
93
+
running.Should().Be(0,because:"all tasks have to run normally");
94
+
peek.Should().Be(1,because:"all tasks must not overlap");
95
+
s.Dispose();
96
+
Interlocked.Read(ref((ProcessScheduler)s)._TestOnly_NonCompleteTaskCount).Should().Be(0,because:"the scheduler must not wait for tasks to complete after disposal");
95
97
}
96
98
}
97
99
@@ -116,9 +118,11 @@ public void ShouldScheduleParallelInParallel()
116
118
for(vari=0;i<done.CurrentCount;i++)
117
119
s.Add(RequestProcessType.Parallel,HandlePeek);
118
120
119
-
done.Wait(ALONGTIME_MS).Should().Be(true);
120
-
running.Should().Be(0);
121
-
peek.Should().BeGreaterThan(3);
121
+
done.Wait(ALONGTIME_MS).Should().Be(true,because:"all tasks have to run");
122
+
running.Should().Be(0,because:"all tasks have to run normally");
123
+
peek.Should().BeGreaterThan(3,because:"a lot of tasks should overlap");
124
+
s.Dispose();
125
+
Interlocked.Read(ref((ProcessScheduler)s)._TestOnly_NonCompleteTaskCount).Should().Be(0,because:"the scheduler must not wait for tasks to complete after disposal");
122
126
}
123
127
}
124
128
@@ -149,9 +153,11 @@ public void ShouldScheduleMixed()
149
153
s.Add(RequestProcessType.Parallel,HandlePeek);
150
154
s.Add(RequestProcessType.Serial,HandlePeek);
151
155
152
-
done.Wait(ALONGTIME_MS).Should().Be(true);
153
-
running.Should().Be(0);
154
-
peek.Should().BeGreaterThan(2);
156
+
done.Wait(ALONGTIME_MS).Should().Be(true,because:"all tasks have to run");
157
+
running.Should().Be(0,because:"all tasks have to run normally");
158
+
peek.Should().BeGreaterThan(2,because:"some tasks should overlap");
159
+
s.Dispose();
160
+
Interlocked.Read(ref((ProcessScheduler)s)._TestOnly_NonCompleteTaskCount).Should().Be(0,because:"the scheduler must not wait for tasks to complete after disposal");
0 commit comments