예제 #1
0
        public void Should_initialize_with_type_initializer_in_correct_order()
        {
            // given
            var list = new RdfListAdapter <IRdfListOwner, IRdfListNode <int>, int>(_context, _entity.Object, _override)
            {
                4, 8, 41, 666
            };

            // then
            list.Should().ContainInOrder(4, 8, 41, 666);
            _contextMock.Verify(c => c.Create <IRdfListNode <int> >(It.IsAny <BlankId>()), Times.Exactly(4));
        }
예제 #2
0
        public void Should_allow_removing_last_element()
        {
            // given
            var list = new RdfListAdapter <IRdfListOwner, IRdfListNode <int>, int>(_context, _entity.Object, _override)
            {
                666
            };

            // when
            list.Remove(666);

            // then
            list.Should().BeEmpty();
        }
예제 #3
0
        public void Should_allow_clearing_entire_list()
        {
            // given
            var list = new RdfListAdapter <IRdfListOwner, IRdfListNode <int>, int>(_context, _entity.Object, _override)
            {
                4, 8, 8, 41, 666
            };

            // when
            list.Clear();

            // then
            list.Should().BeEmpty();
            _contextMock.Verify(c => c.Delete(It.IsAny <BlankId>()), Times.Exactly(5));
        }
예제 #4
0
        public void Should_allow_removing_elements_by_index(int index, int[] expectedResultCollection)
        {
            // given
            var list = new RdfListAdapter <IRdfListOwner, IRdfListNode <int>, int>(_context, _entity.Object, _override)
            {
                4, 8, 8, 41, 666
            };

            // when
            list.RemoveAt(index);

            // then
            list.Should().ContainInOrder(expectedResultCollection);
            _contextMock.Verify(c => c.Delete(It.IsAny <BlankId>()), Times.Exactly(1));
        }
예제 #5
0
        public void Removing_last_element_and_adding_new_to_end_should_keep_list_linked()
        {
            // given
            var list = new RdfListAdapter <IRdfListOwner, IRdfListNode <int>, int>(_context, _entity.Object, _override)
            {
                4, 8, 8, 41, 666
            };

            // when
            list.Remove(666);
            list.Add(1337);

            // then
            list.Should().ContainInOrder(4, 8, 8, 41, 1337);
        }
예제 #6
0
        public void Should_allow_inserting_elements_at_index_with_indexer(int index, int[] expectedCollection)
        {
            // given
            var list = new RdfListAdapter <IRdfListOwner, IRdfListNode <int>, int>(_context, _entity.Object, _override)
            {
                4, 8, 41, 666
            };

            // when
            list[index] = 5;

            // then
            list.Count.Should().Be(5);
            list.Should().ContainInOrder(expectedCollection);
            _contextMock.Verify(c => c.Create <IRdfListNode <int> >(It.IsAny <BlankId>()), Times.Exactly(5));
        }
예제 #7
0
        public void Should_allow_removing_last_elements_and_add_new_afterwards()
        {
            // given
            var list = new RdfListAdapter <IRdfListOwner, IRdfListNode <int>, int>(_context, _entity.Object, _override)
            {
                666
            };

            // when
            list.Remove(666);
            list.Add(1337);
            list.Add(999);

            // then
            list.Should().ContainInOrder(1337, 999);
        }
예제 #8
0
        public void Should_allow_removing_elements(int elementToRemove, int[] expectedResultCollection, bool expectedReturnValue)
        {
            // given
            var list = new RdfListAdapter <IRdfListOwner, IRdfListNode <int>, int>(_context, _entity.Object, _override)
            {
                4, 8, 8, 41, 666
            };

            // when
            var removeResult = list.Remove(elementToRemove);

            // then
            list.Should().ContainInOrder(expectedResultCollection);
            removeResult.Should().Be(expectedReturnValue);
            if (expectedReturnValue)
            {
                _contextMock.Verify(c => c.Delete(It.IsAny <BlankId>()), Times.Once);
            }
            else
            {
                _contextMock.Verify(c => c.Delete(It.IsAny <BlankId>()), Times.Never);
            }
        }