public void ReadXmlRepresentationOfAction_moveToAction_ReturnsCorrectMovetToActionObject()
        {
            IilAction expected = new IilAction("moveTo", new IilNumeral(2), new IilNumeral(3));

            XmlSerializer serializer = new XmlSerializer(typeof (IilAction));

            string xmldata = "<action name=\"moveTo\">\n"+
                                "<actionParameter>\n" +
                                    "<number value=\"2\" />\n" +
                                "</actionParameter>\n" +
                                "<actionParameter>\n" +
                                    "<number value=\"3\" />\n" +
                                "</actionParameter>\n" +
                            "</action>\n";

            StreamReader sreader = new StreamReader(ExtendedString.ToStream(xmldata), Encoding.UTF8);
            XmlReaderSettings rset = new XmlReaderSettings();
            rset.ConformanceLevel = ConformanceLevel.Fragment;
            XmlReader xreader = XmlReader.Create(sreader, rset);

            //			XElement actual_src = XElement.Parse(
            //				);

            IilAction actual = (IilAction) serializer.Deserialize(xreader);
            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        public void ReadXmlRepresentationOfActionWithoutContentInSingleElement_EmptyActionObject()
        {
            XmlSerializer serializer = new XmlSerializer(typeof (IilAction));
            IilAction expected = new IilAction ("test");

            XElement actual_src = XElement.Parse(
                @"<action name = ""test"" />");

            IilAction actual = (IilAction)serializer.Deserialize (actual_src.CreateReader ());
            Assert.AreEqual (expected, actual);
        }
Пример #3
0
        public void ReadStream_XmlStreamWithTwoPackets_DeserializeXmlCorrectly()
        {
            IilAction expected = new IilAction("moveTo", new IilNumeral(2), new IilNumeral(3));

            XmlSerializer serializer = new XmlSerializer(typeof(IilAction));

            string xmldata = "<action name=\"moveTo\">\n" +
                                "<actionParameter>\n" +
                                    "<number value=\"2\" />\n" +
                                "</actionParameter>\n" +
                                "<actionParameter>\n" +
                                    "<number value=\"3\" />\n" +
                                "</actionParameter>\n" +
                            "</action>\n";

            MemoryStream memsout = new MemoryStream();

            StreamWriter sw = new StreamWriter(new PacketStream(memsout));
            sw.Write(xmldata);
            sw.Flush();
            sw.Write(xmldata);
            sw.Flush();
            memsout.Position = 0;

            PacketStream packet = new PacketStream(memsout);

            StreamReader sreader = new StreamReader(packet, Encoding.UTF8);

            packet.ReadNextPackage();

            XmlReaderSettings rset = new XmlReaderSettings();
            rset.ConformanceLevel = ConformanceLevel.Fragment;
            //XmlReader xreader= XmlReader.Create(sreader, rset);

            IilAction actual;

            actual = (IilAction)serializer.Deserialize(sreader);
            Assert.AreEqual(expected, actual);

            packet.ReadNextPackage();

            actual = (IilAction)serializer.Deserialize(sreader);
            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        public void ReadXmlRepresentationOfAction_emptyFunction_ReturnsCorrectMovetToActionObject()
        {
            IilAction expected = new IilAction("moveTo", new IilFunction("test"));

            string xmldata = "<action name=\"moveTo\">\n" +
                                "<actionParameter>\n" +
                                    "<function name=\"test\"/>\n" +
                                "</actionParameter>\n" +
                            "</action>\n";

            StreamReader sreader = new StreamReader(ExtendedString.ToStream(xmldata), Encoding.UTF8);
            XmlReaderSettings rset = new XmlReaderSettings();
            rset.ConformanceLevel = ConformanceLevel.Fragment;
            XmlReader xreader = XmlReader.Create(sreader, rset);

            //			XElement actual_src = XElement.Parse(
            //				);

            IilAction actual = (IilAction)new IilAction();
            actual.ReadXml(xreader);
            Assert.AreEqual(expected, actual);
        }
Пример #5
0
 private void AddPacket(IilAction packet)
 {
     this.packets.Enqueue(packet);
     this.packetadded.Set();
 }