// Local function that performs the core of the test
 static async Task PerformCore(bool useNumberOne)
 {
     if (useNumberOne)
     {
         await using var testInstance = new TestClass1();
         await testInstance.PerformAssertionAsync();
     }
     else
     {
         await using var testInstance = new TestClass2();
         await testInstance.PerformAssertionAsync();
     }
 }
Exemplo n.º 2
0
        public Task ConstructAndDispose_WithLifetimeOfTwoParallelUnitTestClasses_ShouldNotInterfereWithEachOther()
        {
            var tasks = new ConcurrentQueue <Task>();

            Parallel.For(0, 20, i =>
            {
                if (i % 2 == 0)
                {
                    using var testInstance = new TestClass1();
                    tasks.Enqueue(testInstance.PerformAssertionAsync());
                }
                else
                {
                    using var testInstance = new TestClass2();
                    tasks.Enqueue(testInstance.PerformAssertionAsync());
                }
            });

            return(Task.WhenAll(tasks));
        }