Exemplo n.º 1
0
        public void Enqueue_MaxCapacityReached_TryToEnqueueNewPriority_Failes()
        {
            // Arrange
            TestHelpers.GetItemsWithIntegerPriority().ForEach(i => _targetQueue.Enqueue(i));


            var mockWithPriority = new MockWithIntegerPriority(10);

            // Act
            var result = _targetQueue.Enqueue(mockWithPriority);

            // Assert
            result.Should().BeFalse();
        }
Exemplo n.º 2
0
        public void Dequeue_QueueContainsItemsWithSamePriority_ReturnsSuccessWithFirstInItem()
        {
            // Arrange
            var mockWithPriority1 = new MockWithIntegerPriority(0);
            var mockWithPriority2 = new MockWithIntegerPriority(0);

            _targetQueue.Enqueue(mockWithPriority1);
            _targetQueue.Enqueue(mockWithPriority2);

            // Act
            var result1 = _targetQueue.Dequeue();
            var result2 = _targetQueue.Dequeue();

            // Assert
            result1.Should().Be(mockWithPriority1);
            result2.Should().Be(mockWithPriority2);
        }
        public void GetEnumerator_QueueContainsSamePriorities_EnumerationIsOrderedByFirstIn()
        {
            // Arrange
            var mockWithPriority1 = new MockWithIntegerPriority(0);
            var mockWithPriority2 = new MockWithIntegerPriority(0);

            _targetQueue.Enqueue(mockWithPriority1);
            _targetQueue.Enqueue(mockWithPriority2);

            // Act
            var enumerator = _targetQueue.GetEnumerator();

            // Assert
            enumerator.MoveNext();
            enumerator.Current.Should().Be(mockWithPriority1);
            enumerator.MoveNext();
            enumerator.Current.Should().Be(mockWithPriority2);
        }