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)); }
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(); }
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)); }
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)); }
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); }
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)); }
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); }
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); } }