Beispiel #1
0
        public void DeserializeUUID()
        {
            LLSD      theLLSD  = null;
            LLSDArray array    = null;
            LLSDUUID  tempUUID = null;

            String testLLSD = @"<?xml version='1.0' encoding='UTF-8'?>
            <llsd>
                <array>
                    <uuid>d7f4aeca-88f1-42a1-b385-b9db18abb255</uuid>
                    <uuid/>
                </array>
            </llsd>";

            //Deserialize the string
            byte[] bytes = Encoding.UTF8.GetBytes(testLLSD);
            theLLSD = LLSDParser.DeserializeXml(bytes);

            Assert.IsTrue(theLLSD is LLSDArray);
            array = (LLSDArray)theLLSD;

            Assert.AreEqual(LLSDType.UUID, array[0].Type);
            tempUUID = (LLSDUUID)array[0];
            Assert.AreEqual(new LLUUID("d7f4aeca-88f1-42a1-b385-b9db18abb255"), tempUUID.AsUUID());

            Assert.AreEqual(LLSDType.UUID, array[1].Type);
            tempUUID = (LLSDUUID)array[1];
            Assert.AreEqual(LLUUID.Zero, tempUUID.AsUUID());
        }
Beispiel #2
0
        public void DeserializeLLSDSample()
        {
            LLSD       theLLSD  = null;
            LLSDMap    map      = null;
            LLSD       tempLLSD = null;
            LLSDUUID   tempUUID = null;
            LLSDString tempStr  = null;
            LLSDReal   tempReal = null;

            String testLLSD = @"<?xml version='1.0' encoding='UTF-8'?>
            <llsd>
                <map>
	                <key>region_id</key>
	                <uuid>67153d5b-3659-afb4-8510-adda2c034649</uuid>
	                <key>scale</key>
	                <string>one minute</string>
	                <key>simulator statistics</key>
	                <map>
		                <key>time dilation</key>
		                <real>0.9878624</real>
		                <key>sim fps</key>
		                <real>44.38898</real>
		                <key>agent updates per second</key>
		                <real>nan</real>
		                <key>total task count</key>
		                <real>4</real>
		                <key>active task count</key>
		                <real>0</real>
		                <key>pending uploads</key>
		                <real>0.0001096525</real>
	                </map>
                </map>
            </llsd>";

            //Deserialize the string
            byte[] bytes = Encoding.UTF8.GetBytes(testLLSD);
            theLLSD = LLSDParser.DeserializeXml(bytes);

            //Confirm the contents
            Assert.IsNotNull(theLLSD);
            Assert.IsTrue(theLLSD is LLSDMap);
            Assert.IsTrue(theLLSD.Type == LLSDType.Map);
            map = (LLSDMap)theLLSD;

            tempLLSD = map["region_id"];
            Assert.IsNotNull(tempLLSD);
            Assert.IsTrue(tempLLSD is LLSDUUID);
            Assert.IsTrue(tempLLSD.Type == LLSDType.UUID);
            tempUUID = (LLSDUUID)tempLLSD;
            Assert.AreEqual(new LLUUID("67153d5b-3659-afb4-8510-adda2c034649"), tempUUID.AsUUID());

            tempLLSD = map["scale"];
            Assert.IsNotNull(tempLLSD);
            Assert.IsTrue(tempLLSD is LLSDString);
            Assert.IsTrue(tempLLSD.Type == LLSDType.String);
            tempStr = (LLSDString)tempLLSD;
            Assert.AreEqual("one minute", tempStr.AsString());

            tempLLSD = map["simulator statistics"];
            Assert.IsNotNull(tempLLSD);
            Assert.IsTrue(tempLLSD is LLSDMap);
            Assert.IsTrue(tempLLSD.Type == LLSDType.Map);
            map = (LLSDMap)tempLLSD;

            tempLLSD = map["time dilation"];
            Assert.IsNotNull(tempLLSD);
            Assert.IsTrue(tempLLSD is LLSDReal);
            Assert.IsTrue(tempLLSD.Type == LLSDType.Real);
            tempReal = (LLSDReal)tempLLSD;

            Assert.AreEqual(0.9878624d, tempReal.AsReal());
            //TODO - figure out any relevant rounding variability for 64 bit reals
            tempLLSD = map["sim fps"];
            Assert.IsNotNull(tempLLSD);
            Assert.IsTrue(tempLLSD is LLSDReal);
            Assert.IsTrue(tempLLSD.Type == LLSDType.Real);
            tempReal = (LLSDReal)tempLLSD;
            Assert.AreEqual(44.38898d, tempReal.AsReal());

            tempLLSD = map["agent updates per second"];
            Assert.IsNotNull(tempLLSD);
            Assert.IsTrue(tempLLSD is LLSDReal);
            Assert.IsTrue(tempLLSD.Type == LLSDType.Real);
            tempReal = (LLSDReal)tempLLSD;
            Assert.AreEqual(Double.NaN, tempLLSD.AsReal());

            tempLLSD = map["total task count"];
            Assert.IsNotNull(tempLLSD);
            Assert.IsTrue(tempLLSD is LLSDReal);
            Assert.IsTrue(tempLLSD.Type == LLSDType.Real);
            tempReal = (LLSDReal)tempLLSD;
            Assert.AreEqual(4.0d, tempReal.AsReal());

            tempLLSD = map["active task count"];
            Assert.IsNotNull(tempLLSD);
            Assert.IsTrue(tempLLSD is LLSDReal);
            Assert.IsTrue(tempLLSD.Type == LLSDType.Real);
            tempReal = (LLSDReal)tempLLSD;
            Assert.AreEqual(0.0d, tempReal.AsReal());

            tempLLSD = map["pending uploads"];
            Assert.IsNotNull(tempLLSD);
            Assert.IsTrue(tempLLSD is LLSDReal);
            Assert.IsTrue(tempLLSD.Type == LLSDType.Real);
            tempReal = (LLSDReal)tempLLSD;
            Assert.AreEqual(0.0001096525d, tempReal.AsReal());
        }