public void EmptyTailTest() { var queue = BankersQueue <string> .Empty; var ex = AssertThrows <ArgumentNullException>(() => BankersQueue <string> .Tail(queue)); Assert.AreEqual("Value cannot be null.\r\n" + "Parameter name: queue", ex.Message); }
public void TailTest() { const string data = "One Two Three One Three"; var queue = data.Split().Aggregate(BankersQueue <string> .Empty, BankersQueue <string> .Snoc); var tail = BankersQueue <string> .Tail(queue); Assert.AreEqual("[2, {$Two, $Three}, 2, {$Three, $One}]", DumpQueue(tail, true)); }
public void EmptyTest() { var queue = BankersQueue <string> .Empty; Assert.IsTrue(BankersQueue <string> .IsEmpty(queue)); queue = BankersQueue <string> .Snoc(queue, "Item"); Assert.IsFalse(BankersQueue <string> .IsEmpty(queue)); queue = BankersQueue <string> .Tail(queue); Assert.IsTrue(BankersQueue <string> .IsEmpty(queue)); }
public void PushPopTest() { const string data = "One Two Three One Three"; var queue = data.Split().Aggregate(BankersQueue <string> .Empty, BankersQueue <string> .Snoc); foreach (var expected in data.Split()) { var actual = BankersQueue <string> .Head(queue); Assert.AreEqual(expected, actual); queue = BankersQueue <string> .Tail(queue); } Assert.IsTrue(BankersQueue <string> .IsEmpty(queue)); }
public void NullTailTest() { var ex = AssertThrows <NullReferenceException>(() => BankersQueue <string> .Tail(null)); Assert.AreEqual("Object reference not set to an instance of an object.", ex.Message); }