コード例 #1
0
        public void Should_RunOneTask()
        {
            // Arrange
            var done = new AutoResetEvent(false);

            // Act
            _cut.AddForExecution(() => done.Set());
            var res = done.WaitOne(_timeout);

            // Assert
            Assert.IsTrue(res);
        }
コード例 #2
0
        public void Should_ReleaseWorkingThreads_When_CallerRespectsDispose()
        {
            // Arrange
            var threadNumberBefore = System.Diagnostics.Process.GetCurrentProcess().Threads.Count;

            // Act
            Parallel.For(0, 100, (i) =>
            {
                using (var cut = new Executor())
                    cut.AddForExecution(() => { });
            });

            // Assert
            var threadNumberAfter = System.Diagnostics.Process.GetCurrentProcess().Threads.Count;

            Assert.AreEqual(threadNumberBefore, threadNumberAfter);
        }
コード例 #3
0
        //[TestMethod] This test is failing now
        public void Should_ReleaseWorkingThreads_When_CallerDoesNotRespectsDispose()
        {
            // Arrange
            var threadNumberBefore = System.Diagnostics.Process.GetCurrentProcess().Threads.Count;

            // Act
            Parallel.For(0, 100, (i) =>
            {
                // Each executor spawns a working thread which is not stopped explicitly
                var cut = new Executor();
                cut.AddForExecution(() => { });
            });

            // Assert
            var threadNumberAfter = System.Diagnostics.Process.GetCurrentProcess().Threads.Count;

            Assert.AreEqual(threadNumberBefore, threadNumberAfter);
        }