public void VerifyThatMoveWorks() { var testlist = new OrderedItemList<Thing>(this.person, true); var email0 = new EmailAddress(Guid.NewGuid(), null, null); var email1 = new EmailAddress(Guid.NewGuid(), null, null); var email2 = new EmailAddress(Guid.NewGuid(), null, null); var email3 = new EmailAddress(Guid.NewGuid(), null, null); var email4 = new EmailAddress(Guid.NewGuid(), null, null); testlist.Add(email0); testlist.Add(email1); testlist.Add(email2); testlist.Add(email3); testlist.Add(email4); Assert.AreSame(email0, testlist[0]); Assert.AreSame(email1, testlist[1]); Assert.AreSame(email2, testlist[2]); Assert.AreSame(email3, testlist[3]); Assert.AreSame(email4, testlist[4]); // move 1st to last testlist.Move(0, 4); Assert.AreSame(email1, testlist[0]); Assert.AreSame(email2, testlist[1]); Assert.AreSame(email3, testlist[2]); Assert.AreSame(email4, testlist[3]); Assert.AreSame(email0, testlist[4]); // move last to first testlist.Move(4, 0); Assert.AreSame(email0, testlist[0]); Assert.AreSame(email1, testlist[1]); Assert.AreSame(email2, testlist[2]); Assert.AreSame(email3, testlist[3]); Assert.AreSame(email4, testlist[4]); // does not do anything testlist.Move(0, 0); Assert.AreSame(email0, testlist[0]); Assert.AreSame(email1, testlist[1]); Assert.AreSame(email2, testlist[2]); Assert.AreSame(email3, testlist[3]); Assert.AreSame(email4, testlist[4]); }
public void VerifyThatMoveThrowsException4() { var testlist = new OrderedItemList<Thing>(this.person, true); var email0 = new EmailAddress(Guid.NewGuid(), null, null); var email1 = new EmailAddress(Guid.NewGuid(), null, null); testlist.Add(email0); testlist.Add(email1); Assert.Throws<ArgumentOutOfRangeException>(() => testlist.Move(0, 3)); }