Пример #1
0
        public void AddVarious_WithInvalidId_Throws()
        {
            var(min, max) = (-1, m_MultiList.HeadIds.Length);

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.AddHead(min, "0"));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.AddHead(max, "0"));

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.Add(min, "0"));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.Add(max, "0"));

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.AddTail(min));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.AddTail(max));

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.AddTail(min, "0"));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.AddTail(max, "0"));

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.ReleaseList(min));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.ReleaseList(max));

            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.ReleaseListKeepHead(min));
            Assert.Throws <IndexOutOfRangeException>(() => m_MultiList.ReleaseListKeepHead(max));

            Assert.DoesNotThrow(() => { foreach (var _ in m_MultiList.SelectListAt(min))
                                        {
                                        }
                                });
            Assert.Throws <IndexOutOfRangeException>(() => { foreach (var _ in m_MultiList.SelectListAt(max))
                                                             {
                                                             }
                                                     });
        }
        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));
        }