public void ExecuteAppendMethod() { ListObject obj = new ListObject(new TopObject()); obj.Evaluate(new Message("append", new object[] { 1 })); object result = obj.Evaluate(new Message("size")); Assert.AreEqual(1, result); Assert.AreEqual(1, obj.Count); obj.Evaluate(new Message("append", new object[] { 2 })); result = obj.Evaluate(new Message("size")); Assert.AreEqual(2, result); Assert.AreEqual(2, obj.Count); }
public void AtPut() { ListObject obj = new ListObject(new TopObject(), new object[] { 1, 2, 3 }); obj.Evaluate(new Message("atPut", new object[] { 1, 20 })); Assert.AreEqual(3, obj.Count); Assert.AreEqual(1, obj[0]); Assert.AreEqual(20, obj[1]); Assert.AreEqual(3, obj[2]); }
public void ExecuteCloneMethod() { ListObject obj = new ListObject(new TopObject()); object result = obj.Evaluate(new Message("clone")); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(ListObject)); Assert.AreEqual(0, obj.Count); Assert.AreEqual(0, ((ListObject)result).Count); }
public void ExecuteRemoveMethod() { ListObject obj = new ListObject(new TopObject()); obj.Evaluate(new Message("append", new object[] { 1 })); obj.Evaluate(new Message("append", new object[] { 2 })); obj.Evaluate(new Message("append", new object[] { 3 })); obj.Evaluate(new Message("remove", new object[] { 1 })); Assert.AreEqual(2, obj.Evaluate(new Message("size"))); Assert.AreEqual(2, obj.Count); Assert.AreEqual(2, obj.Evaluate(new Message("at", new object[] { 0 }))); Assert.AreEqual(2, obj[0]); Assert.AreEqual(3, obj.Evaluate(new Message("at", new object[] { 1 }))); Assert.AreEqual(3, obj[1]); }