public void InsertTest() { var emptySeq = new ShieldedSeqNc <int>(); Shield.InTransaction(() => emptySeq.Insert(0, 1)); Assert.IsTrue(emptySeq.Any()); Assert.AreEqual(1, emptySeq[0]); Assert.Throws <InvalidOperationException>(() => emptySeq.Count()); Shield.InTransaction(() => Assert.AreEqual(1, emptySeq.Count())); var seq = new ShieldedSeq <int>(2, 3, 4, 6, 7); Shield.InTransaction(() => seq.Insert(0, 1)); Assert.AreEqual(6, seq.Count); Assert.AreEqual(1, seq[0]); Assert.AreEqual(2, seq[1]); Shield.InTransaction(() => seq.Insert(4, 5)); Assert.AreEqual(7, seq.Count); Assert.AreEqual(1, seq[0]); Assert.AreEqual(2, seq[1]); Assert.AreEqual(5, seq[4]); Assert.AreEqual(6, seq[5]); Shield.InTransaction(() => seq.Insert(7, 8)); Assert.AreEqual(8, seq.Count); Shield.InTransaction(() => { for (int i = 0; i < seq.Count; i++) { Assert.AreEqual(i + 1, seq[i]); } }); }
public void InsertTest() { var emptySeq = new ShieldedSeqNc<int>(); Shield.InTransaction(() => emptySeq.Insert(0, 1)); Assert.IsTrue(emptySeq.Any()); Assert.AreEqual(1, emptySeq[0]); Assert.Throws<InvalidOperationException>(() => emptySeq.Count()); Shield.InTransaction(() => Assert.AreEqual(1, emptySeq.Count())); var seq = new ShieldedSeq<int>(2, 3, 4, 6, 7); Shield.InTransaction(() => seq.Insert(0, 1)); Assert.AreEqual(6, seq.Count); Assert.AreEqual(1, seq[0]); Assert.AreEqual(2, seq[1]); Shield.InTransaction(() => seq.Insert(4, 5)); Assert.AreEqual(7, seq.Count); Assert.AreEqual(1, seq[0]); Assert.AreEqual(2, seq[1]); Assert.AreEqual(5, seq[4]); Assert.AreEqual(6, seq[5]); Shield.InTransaction(() => seq.Insert(7, 8)); Assert.AreEqual(8, seq.Count); Shield.InTransaction(() => { for (int i=0; i < seq.Count; i++) Assert.AreEqual(i + 1, seq[i]); }); }