コード例 #1
0
        public void EnumeratorIterationFromHeadIdIndices_WithItems_ReturnsItems()
        {
            m_MultiList.Add(0, "0a");
            m_MultiList.Add(0, "0b");
            m_MultiList.Add(1, "1a");
            m_MultiList.Add(0, "0c");
            m_MultiList.Add(1, "1b");

            using (var enumerator = m_MultiList.SelectList(0))
            {
                Assert.That(enumerator, Is.EqualTo(new[] { "0a", "0c", "0b" }));
            }

            using (var enumerator = m_MultiList.SelectListAt(m_MultiList.HeadIds[0]))
            {
                Assert.That(enumerator, Is.EqualTo(new[] { "0a", "0c", "0b" }));
            }

            using (var enumerator = m_MultiList.SelectList(1))
            {
                Assert.That(enumerator, Is.EqualTo(new[] { "1a", "1b" }));
            }

            using (var enumerator = m_MultiList.SelectListAt(m_MultiList.HeadIds[1]))
            {
                Assert.That(enumerator, Is.EqualTo(new[] { "1a", "1b" }));
            }
        }
        public void AddVarious_WithInvalidId_Throws()
        {
            const int invalid    = -1;
            var       outOfRange = m_MultiList.HeadIds.Length;

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.AddHead(invalid, "0"));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.AddHead(outOfRange, "0"));

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.Add(invalid, "0"));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.Add(outOfRange, "0"));

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.AddTail(invalid));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.AddTail(outOfRange));

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.AddTail(invalid, "0"));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.AddTail(outOfRange, "0"));

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.ReleaseList(invalid));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.ReleaseList(outOfRange));

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.ReleaseListKeepHead(invalid));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.ReleaseListKeepHead(outOfRange));

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.SelectList(invalid));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.SelectList(outOfRange));
        }