public void Should_update_count_when_adding_and_removing_elements() { // given var list = new RdfListAdapter <IRdfListOwner, IRdfListNode <int>, int>(_context, _entity.Object, _override) { 4, 5, 6, 7, 8 }; // then list.Remove(6); list.Remove(4); // then list.Count.Should().Be(3); }
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 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_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); } }