Exemplo n.º 1
0
        public void SerializeZeroBasedIndex()
        {
            string expectedLua        = "{[\"Array\"]={[0]=0,[1]=1,[2]=2,},[\"List\"]={[0]=0,[1]=1,[2]=2,},[\"Enumerable\"]={[0]=0,[1]=1,[2]=2,},}";
            ZeroBasedIndexClass input = new ZeroBasedIndexClass();

            input.Array = new int[] { 0, 1, 2 };
            input.List  = new List <int>()
            {
                0, 1, 2
            };
            input.Enumerable = Enumerable.Range(0, 3);
            string result = Serializer.Serialize(input);

            Assert.AreEqual(expectedLua, result);
        }
Exemplo n.º 2
0
        public void ZeroBasedIndexFromZero()
        {
            string lua = GetLua();
            ZeroBasedIndexClass result = Serializer.Deserialize <ZeroBasedIndexClass>(lua);

            Assert.AreEqual(3, result.Array.Length);
            Assert.AreEqual(0, result.Array[0]);
            Assert.AreEqual(1, result.Array[1]);
            Assert.AreEqual(2, result.Array[2]);

            Assert.AreEqual(3, result.List.Count);
            Assert.AreEqual(0, result.List[0]);
            Assert.AreEqual(1, result.List[1]);
            Assert.AreEqual(2, result.List[2]);

            Assert.AreEqual(3, result.Enumerable.Count());
            Assert.AreEqual(0, result.Enumerable.ElementAt(0));
            Assert.AreEqual(1, result.Enumerable.ElementAt(1));
            Assert.AreEqual(2, result.Enumerable.ElementAt(2));
        }