コード例 #1
0
        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);
        }
コード例 #2
0
        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]);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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]);
        }