public void PooledLinkedListExtensions_All_ReturnsTrueIfPooledLinkedListIsEmpty()
        {
            var list = new PooledLinkedList<Int32>();

            var result = list.All(x => x % 2 == 0);

            TheResultingValue(result).ShouldBe(true);
        }
        public void PooledLinkedListExtensions_Any_ReturnsFalseIfPooledLinkedListDoesNotContainItems()
        {
            var list = new PooledLinkedList<Int32>();

            var result = list.Any();

            TheResultingValue(result).ShouldBe(false);
        }
        public void PooledLinkedListExtensions_Any_ReturnsTrueIfPooledLinkedListContainsItems()
        {
            var list = new PooledLinkedList<Int32>();
            list.AddLast(1);

            var result = list.Any();

            TheResultingValue(result).ShouldBe(true);
        }
        public void PooledLinkedListExtensions_AnyWithPredicate_ReturnsFalseIfPooledLinkedListDoesNotContainMatchingItems()
        {
            var list = new PooledLinkedList<Int32>();
            list.AddLast(1);
            list.AddLast(3);

            var result = list.Any(x => x % 2 == 0);

            TheResultingValue(result).ShouldBe(false);
        }
        public void PooledLinkedListExtensions_All_ReturnsTrueIfAllItemsMatchPredicate()
        {
            var list = new PooledLinkedList<Int32>();
            list.AddLast(2);
            list.AddLast(4);
            list.AddLast(6);

            var result = list.All(x => x % 2 == 0);

            TheResultingValue(result).ShouldBe(true);
        }
        public void PooledLinkedList_CanAddItems()
        {
            var list = new PooledLinkedList<Int32>();

            list.AddLast(1);
            list.AddFirst(2);
            list.AddLast(3);

            TheResultingCollection(list)
                .ShouldBeExactly(2, 1, 3);
        }
        public void PooledLinkedListExtensions_All_ReturnsFalseIfOneItemDoesNotMatchPredicate()
        {
            var list = new PooledLinkedList<Int32>();
            list.AddLast(1);
            list.AddLast(2);
            list.AddLast(4);
            list.AddLast(6);

            var result = list.All(x => x % 2 == 0);

            TheResultingValue(result).ShouldBe(false);
        }
        public void PooledLinkedList_ClearsNodesUponRemoval()
        {
            var list = new PooledLinkedList<Int32>();
            list.AddLast(1);

            TheResultingValue(list.First.Value)
                .ShouldBe(1);

            var node = list.Last;
            list.Remove(node);

            TheResultingValue(node.Value)
                .ShouldBe(default(Int32));
        }
        public void PooledLinkedListExtensions_Single_ThrowsExceptionIfPooledLinkedListIsEmpty()
        {
            var list = new PooledLinkedList<Int32>();

            Assert.That(() => list.Single(),
                Throws.TypeOf<InvalidOperationException>());
        }
        public void PooledLinkedListExtensions_Single_ThrowsExceptionIfPooledLinkedListHasMultipleItems()
        {
            var list = new PooledLinkedList<Int32>();
            list.AddLast(1);
            list.AddLast(2);

            Assert.That(() => list.Single(),
                Throws.TypeOf<InvalidOperationException>());
        }
Exemplo n.º 11
0
 public void IterateBackward_ReturnsFalseWhenEmpty()
 {
     PooledLinkedList <int> .Node current = null;
     Assert.False(PooledLinkedList.IterateBackward(ref current));
 }
        public void PooledLinkedListExtensions_Min_ReturnsMinValue()
        {
            var list = new PooledLinkedList<Int32>();
            list.AddLast(4);
            list.AddLast(5);
            list.AddLast(6);
            list.AddLast(99);
            list.AddLast(10);
            list.AddLast(1);
            list.AddLast(12);
            list.AddLast(45);

            var result = list.Min();

            TheResultingValue(result).ShouldBe(1);
        }
        public void PooledLinkedListExtensions_Last_ReturnsLastItemInPooledLinkedList()
        {
            var list = new PooledLinkedList<Int32>();
            list.AddLast(1);
            list.AddLast(2);
            list.AddLast(3);

            var result = list.Last();

            TheResultingValue(result).ShouldBe(3);
        }
        public void PooledLinkedListExtensions_Min_ThrowsExceptionIfPooledLinkedListIsEmpty()
        {
            var list = new PooledLinkedList<Int32>();

            list.Min();
        }
        public void PooledLinkedListExtensions_SingleOrDefault_ThrowsExceptionIfPooledLinkedListHasMultipleItems()
        {
            var list = new PooledLinkedList<Int32>();
            list.AddLast(1);
            list.AddLast(2);

            list.SingleOrDefault();
        }
        public void PooledLinkedListExtensions_CountWithPredicate_ReturnsCorrectSize()
        {
            var list = new PooledLinkedList<Int32>();
            list.AddLast(1);
            list.AddLast(2);
            list.AddLast(3);

            var result = list.Count(x => x % 2 == 0);

            TheResultingValue(result).ShouldBe(1);
        }
        public void PooledLinkedListExtensions_SingleOrDefault_ReturnsDefaultValueIfPooledLinkedListIsEmpty()
        {
            var list = new PooledLinkedList<Int32>();

            var result = list.SingleOrDefault();

            TheResultingValue(result).ShouldBe(default(Int32));
        }
        public void PooledLinkedListExtensions_Single_ReturnsSingleItemInPooledLinkedList()
        {
            var list = new PooledLinkedList<Int32>();
            list.AddLast(4);

            var result = list.Single();

            TheResultingValue(result).ShouldBe(4);
        }
Exemplo n.º 19
0
 public void Setup()
 {
     PooledLinkedList = new();
 }