public void KinesisRecordUnitTest_Deadlines() { // The nearest deadline should always be kept { KinesisRecord r = new KinesisRecord(); var start = DateTime.Now; for (int i = 0; i < 10; i++) { var ur = TestUtil.make_user_record(); ur.set_deadline(start.AddMilliseconds(i * 100)); ur.set_expiration(start.AddMilliseconds(i * 100)); r.add(ur); } Assert.IsTrue(r.Deadline() == start); Assert.IsTrue(r.Expiration() == start); } // If a nearer deadline comes in, it should override the previous { KinesisRecord r = new KinesisRecord(); var earlier = DateTime.Now; var later = earlier.AddMilliseconds(500); { var ur = TestUtil.make_user_record(); ur.set_deadline(later); r.add(ur); Assert.IsTrue(r.Deadline() == later); } { var ur = TestUtil.make_user_record(); ur.set_deadline(earlier); r.add(ur); Assert.IsTrue(r.Deadline() == earlier); } // Removing the last added record should restore the previous deadline r.remove_last(); Assert.IsTrue(r.Deadline() == later); } }