Пример #1
0
        public void Enqueue_Two()
        {
            // arrange
            var queue = new WorkQueue();
            var task1 = new MockExecutionTask();
            var task2 = new MockExecutionTask();

            // act
            var count1 = queue.Push(task1);
            var count2 = queue.Push(task2);

            // assert
            Assert.Equal(1, count1);
            Assert.Equal(2, count2);
            Assert.False(queue.HasRunningTasks);
            Assert.False(queue.IsEmpty);
        }
Пример #2
0
        public void Clear()
        {
            // arrange
            var queue = new WorkQueue();
            var task1 = new MockExecutionTask();
            var task2 = new MockExecutionTask();

            queue.Push(task1);
            queue.Push(task2);

            // act
            queue.Clear();

            // assert
            Assert.Equal(0, queue.Count);
            Assert.False(queue.HasRunningTasks);
            Assert.True(queue.IsEmpty);
        }
Пример #3
0
        public void Take_One()
        {
            // arrange
            var queue = new WorkQueue();
            var task1 = new MockExecutionTask();
            var task2 = new MockExecutionTask();

            queue.Push(task1);
            queue.Push(task2);

            // act
            var success = queue.TryTake(out var task);

            // assert
            Assert.Same(task2, task);
            Assert.True(success);
            Assert.True(queue.HasRunningTasks);
            Assert.False(queue.IsEmpty);
        }
Пример #4
0
        public void Complete_All()
        {
            // arrange
            var queue = new WorkQueue();
            var task1 = new MockExecutionTask();
            var task2 = new MockExecutionTask();

            queue.Push(task1);
            queue.Push(task2);

            // act
            queue.TryTake(out var task);
            queue.Complete();
            queue.TryTake(out task);
            queue.Complete();

            // assert
            Assert.Same(task1, task);
            Assert.False(queue.HasRunningTasks);
            Assert.True(queue.IsEmpty);
        }
Пример #5
0
        public void Enqueue_One()
        {
            // arrange
            var queue = new WorkQueue();
            var task  = new MockExecutionTask();

            // act
            var count = queue.Push(task);

            // assert
            Assert.Equal(1, count);
            Assert.False(queue.HasRunningTasks);
            Assert.False(queue.IsEmpty);
        }