@@ -66,30 +66,30 @@ public static async Task TestConcurrentAddAndCompleteAdding()
6666 Assert . Equal ( 0 , testResult . NumOfFoundBugs ) ;
6767 }
6868
69- ///// <summary>
70- ///// Verifies that tasks added after CompleteAdding is called throw exceptions
71- ///// and that existing tasks are processed correctly.
72- ///// </summary>
73- // [Test]
74- // public static async Task TestAddAfterCompleteAddingThrows()
75- // {
76- // await RunCoyoteTest(async (buffer) =>
77- // {
78- // buffer.CompleteAdding();
69+ /// <summary>
70+ /// Verifies that tasks added after CompleteAdding is called throw exceptions
71+ /// and that existing tasks are processed correctly.
72+ /// </summary>
73+ [ Test ]
74+ public static async Task TestAddAfterCompleteAddingThrows ( )
75+ {
76+ await RunCoyoteTest ( async ( buffer ) =>
77+ {
78+ buffer . CompleteAdding ( ) ;
7979
80- // bool exceptionThrown = false;
81- // try
82- // {
83- // buffer.Add(Task.FromResult(1));
84- // }
85- // catch (InvalidOperationException)
86- // {
87- // exceptionThrown = true;
88- // }
80+ bool exceptionThrown = false ;
81+ try
82+ {
83+ buffer . Add ( Task . FromResult ( 1 ) ) ;
84+ }
85+ catch ( InvalidOperationException )
86+ {
87+ exceptionThrown = true ;
88+ }
8989
90- // Assert(exceptionThrown, "Add after CompleteAdding should throw");
91- // });
92- // }
90+ Assert ( exceptionThrown , "Add after CompleteAdding should throw" ) ;
91+ } ) ;
92+ }
9393
9494 ///// <summary>
9595 ///// Ensures all tasks are processed exactly once even with multiple consumers.
@@ -161,18 +161,21 @@ public static async Task TestConcurrentAddAndCompleteAdding()
161161 // });
162162 //}
163163
164- //// Helper methods
165- // private static async Task RunCoyoteTest(Func<TaskCompletionBuffer<int>, Task> testFunc)
166- // {
167- // var config = Configuration.Create().WithTestingIterations(100);
168- // var testResult = await TestingEngine.Execute (config, async (runtime) =>
169- // {
170- // var buffer = new TaskCompletionBuffer<int>();
171- // await testFunc(buffer);
172- // });
164+ // Helper methods
165+ private static async Task RunCoyoteTest ( Func < TaskCompletionBuffer < int > , Task > testFunc )
166+ {
167+ var config = Configuration . Create ( ) . WithTestingIterations ( 100 ) ;
168+ var engine = TestingEngine . Create ( config , async ( runtime ) =>
169+ {
170+ var buffer = new TaskCompletionBuffer < int > ( ) ;
171+ await testFunc ( buffer ) ;
172+ } ) ;
173173
174- // Assert(testResult.NumOfFoundBugs == 0);
175- //}
174+ engine . Run ( ) ;
175+ var testResult = engine . TestReport ;
176+
177+ Assert . Equal ( 0 , testResult . NumOfFoundBugs ) ;
178+ }
176179
177180 //private static async Task ConsumeAsync(TaskCompletionBuffer<int> buffer, ConcurrentBag<int> results)
178181 //{
0 commit comments