OrWriteAccess(
					list,
					() => val = list[0]);
				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void IndexerSetChangesValueAtGivenIndex()
		{
			using (NativeLinkedList<int> list = CreateNativeLinkedList(10, 20, 30))
			{
				// Need to make a copy because we can't change a 'using' var
				NativeLinkedList<int> copy = list;

				copy[1] = 200;

				Assert.That(list.Head.Next.Value, Is.EqualTo(200));
				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void IndexerSetCannotWritOutOfParallelForSafetyBounds()
		{
			using (NativeLinkedList<int> list = CreateNativeLinkedList(10, 20, 30))
			{
				// Need to make a copy because we can't change a 'using' var
				NativeLinkedList<int> copy = list;
				copy.TestUseOnlySetParallelForSafetyCheckRange(0, 1);

				Assert.That(
					() => copy[2] = 200,
					Throws.TypeOf<IndexOutOfRangeException>());
				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void IndexerSetWhenReadOnlyThrowsException()
		{
			using (NativeLinkedList<int> list = CreateNativeLinkedList(10, 20, 30))
			{
				// Need to make a copy because we can't change a 'using' var
				NativeLinkedList<int> copy = list;

				AssertRequiresReadOrWriteAccess(
					copy,
					() => copy[0] = 100);
				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void GetEnumeratorAtIndexReturnsEnumeratorForTheGivenIndex()
		{
			using (NativeLinkedList<int> list = CreateEmptyNativeLinkedList(3))
			{
				list.InsertAfter(list.Tail, 10);
				NativeLinkedList<int>.Enumerator e20 = list.InsertAfter(list.Tail, 20);
				list.InsertAfter(list.Tail, 30);

				NativeLinkedList<int>.Enumerator e = list.GetEnumeratorAtIndex(1);

				Assert.That(e, Is.EqualTo(e20));

				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void GetEnumeratorAtIndexWhenWriteOnlyThrowsException()
		{
			using (NativeLinkedList<int> list = CreateNativeLinkedList(10, 20, 30))
			{
				NativeLinkedList<int>.Enumerator e = list.Head;

				AssertRequiresReadOrWriteAccess(
					list,
					() => e = list.GetEnumeratorAtIndex(1));
				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void SortNodeMemoryAddressesPreservesOrderButSortsMemory()
		{
			using (NativeLinkedList<int> list = new NativeLinkedList<int>(
				3,
				Allocator.Temp))
			{
				NativeLinkedList<int>.Enumerator e10 = list.InsertAfter(list.Tail, 10);
				NativeLinkedList<int>.Enumerator e20 = list.InsertAfter(list.Tail, 20);
				NativeLinkedList<int>.Enumerator e30 = list.InsertAfter(list.Tail, 30);
				list.Remove(e10);
				// values = [ 30, 20, _ ]
				//			 t   h
				NativeLinkedList<int>.Enumerator e5 = list.InsertAfter(list.Tail, 5);
				// values = [ 30, 20, 5 ]
				//				 h   t

				list.SortNodeMemoryAddresses();

				Assert.That(list[0], Is.EqualTo(20));
				Assert.That(list[1], Is.EqualTo(30));
				Assert.That(list[2], Is.EqualTo(5));
				Assert.That(e10.IsValid, Is.False);
				Assert.That(e20.IsValid, Is.False);
				Assert.That(e30.IsValid, Is.False);
				Assert.That(e5.IsValid, Is.False);
				AssertListValues(list, 20, 30, 5);

				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void SortNodeMemoryAddressesWithoutFullListSafetyCheckBoundsThrowsException()
		{
			using (NativeLinkedList<int> list = CreateNativeLinkedList(10, 30, 40, 50))
			{
				list.TestUseOnlySetParallelForSafetyCheckRange(0, 2);

				Assert.That(
					() => list.SortNodeMemoryAddresses(),
					Throws.TypeOf<IndexOutOfRangeException>());

				AssertGeneralInvariants(list);
				list.TestUseOnlySetParallelForSafetyCheckRange();
			}
		}

		[Test]
		public void SortNodeMemoryAddressesWhenWriteOnlyThrowsException()
		{
			using (NativeLinkedList<int> list = CreateNativeLinkedList(10, 20, 30))
			{
				AssertRequiresReadOrWriteAccess(
					list,
					() => list.SortNodeMemoryAddresses());
				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void GetCapacityReturnsGreaterValueThanLength()
		{
			using (NativeLinkedList<int> list = CreateEmptyNativeLinkedList(4))
			{
				list.InsertAfter(list.Tail, 10);

				Assert.That(list.Capacity, Is.GreaterThan(list.Length));
				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void GetCapacityWhenWriteOnlyThrowsException()
		{
			using (NativeLinkedList<int> list = CreateNativeLinkedList(10, 20, 30))
			{
				NativeLinkedList<int>.Enumerator e = list.Head;
				int val;

				AssertRequiresReadOrWriteAccess(
					list,
					() => val = list.Capacity);
				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void GetLengthReturnsSmallerValueThanCapacity()
		{
			using (NativeLinkedList<int> list = CreateEmptyNativeLinkedList(4))
			{
				list.InsertAfter(list.Tail, 10);

				Assert.That(list.Length, Is.LessThan(list.Capacity));
				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void GetLengthWhenWriteOnlyThrowsException()
		{
			using (NativeLinkedList<int> list = CreateNativeLinkedList(10, 20, 30))
			{
				NativeLinkedList<int>.Enumerator e = list.Head;
				int val;

				AssertRequiresReadOrWriteAccess(
					list,
					() => val = list.Length);
				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void GetHeadReturnsInvalidEnumeratorForEmptyList()
		{
			using (NativeLinkedList<int> list = CreateEmptyNativeLinkedList(3))
			{
				NativeLinkedList<int>.Enumerator e = list.Head;
				
				Assert.That(e.IsValid, Is.False);
				
				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void GetHeadWhenWriteOnlyThrowsException()
		{
			using (NativeLinkedList<int> list = CreateNativeLinkedList(10, 20, 30))
			{
				NativeLinkedList<int>.Enumerator e = list.Head;

				AssertRequiresReadOrWriteAccess(
					list,
					() => e = list.Head);
				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void GetHeadReturnsEnumeratorForFirstNode()
		{
			using (NativeLinkedList<int> list = CreateNativeLinkedList(10, 20, 30, 40))
			{
				NativeLinkedList<int>.Enumerator e = list.Head;

				Assert.That(e.Current, Is.EqualTo(10));

				AssertGeneralInvariants(list);
			}
		}

		[Test]
		public void GetEnumeratorReturnsInvalidEnumeratorForEmptyList()
		{
			using (NativeLinkedList<int> list = CreateEmptyNativeLinkedList(3))
			{
				