public void Remove_ReturnsTrue_WhenItemDoensntExists() { // Arrange var list = new LimitedList <string>(2); list.Add("1"); list.Add("2"); // Act var remove = list.Remove("3"); // Assert Assert.IsFalse(remove, "remove returns false"); }
public void Remove_NonExisting_Fails() { //arrange var obj1 = new object(); var obj2 = new object(); var list = new LimitedList <object>(1); list.Add(obj1); //act var removed = list.Remove(obj2); //assert Assert.IsFalse(removed); }
public void Remove_Success_Test() { // Arrange int capacity = 1; LimitedList <object> list = new LimitedList <object>(capacity); var obj = new object(); list.Add(obj); // Act bool removed = list.Remove(obj); // Assert Assert.IsTrue(removed); Assert.IsFalse(list.Contains(obj)); }
public void Remove_Passes_WhenItemExists() { // Arrange var list = new LimitedList <string>(2); list.Add("1"); var result2 = list.Add("2"); // Act var removeFirst = list.Remove("1"); // Assert Assert.IsTrue(removeFirst, "remove returns true"); //Assert.AreNotEqual("1", list[0], "first item is not 1"); Assert.AreEqual("2", list[0], "1:st item becomes 0:th"); //Assert.AreEqual(1, list.Count); }
public void Remove_Existing_Suceeds() { //arrange var obj = new object(); var list = new LimitedList <object>(1); list.Add(obj); //act var removed = list.Remove(obj); //assert Assert.IsTrue(removed); foreach (var item in list) //inget obj ska vara samma som det borttagna { Assert.AreNotEqual(obj, item); } }
public string Use(Item item) { var message = ""; var log = new Log(m => message += m); if (item is Weapon) { log.Add(Wield(item as Weapon)); } if (item is IAffecting) { log.Add((item as IAffecting).Affect(this)); var removed = Backpack.Remove(item); } log.Flush(); return(message != "" ? message : item.Name.A() + " can't be \"used\""); }