public void EmptyHeadTest() { var queue = BankersQueue <string> .Empty; var ex = AssertThrows <ArgumentNullException>(() => BankersQueue <string> .Head(queue)); Assert.AreEqual("Value cannot be null.\r\n" + "Parameter name: queue", ex.Message); }
public void HeadTest() { const string data = "One Two Three One Three"; var queue = data.Split().Aggregate(BankersQueue <string> .Empty, BankersQueue <string> .Snoc); var item = BankersQueue <string> .Head(queue); Assert.AreEqual("One", item); }
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 NullHeadTest() { var ex = AssertThrows <NullReferenceException>(() => BankersQueue <string> .Head(null)); Assert.AreEqual("Object reference not set to an instance of an object.", ex.Message); }