Пример #1
0
        /// <summary>
        /// Creates and parses a message contained in some instructions.
        /// </summary>
        /// <param name="ins"></param>
        /// <param name="body"></param>
        static void InterpretMessage(CheckBase ins, XmlNodeList body)
        {
            if (body != null)
            {
                Message message = new Message();

                foreach (XmlNode node in body)
                {
                    switch (node.Name)
                    {
                    case "#text":                             // a nameless text node
                        message.AddText(node.Value);
                        break;

                    case "data":
                        message.AddDataRef(XmlFiler.getAttribute(node, "of"), ins);
                        break;

                    case "beep":
                        message.AddSound(CreateBeep(node));
                        break;

                    case "sound":
                        message.AddSound(CreateSound(node));
                        break;
                    }
                }
                ins.Message = message;
            }
        }
Пример #2
0
		public void DataRefDefaulted()
		{
			TestState ts = TestState.getOnly("LT");
			ts.Script = "MessageTest.xml";
			NoOp nop1 = new NoOp();
			nop1.Data = 123;
			ts.AddNamedInstruction("niceId",nop1);
			NoOp nop2 = new NoOp();
			nop2.Data = 456;
			ts.AddNamedInstruction("greatId",nop2);
			Message message = new Message();
			message.AddText("Let's count, '");
			message.AddDataRef("$niceId",nop1);
			message.AddText("' and '");
			message.AddDataRef("$greatId.data",nop2);
			message.AddText("' to see it work!");
			string result = message.Read();
			Assert.AreEqual("Let's count, '123' and '456' to see it work!",result,"Message not relayed intact!");
		}
Пример #3
0
        public void DataRefDefaulted()
        {
            TestState ts = TestState.getOnly("LT");

            ts.Script = "MessageTest.xml";
            NoOp nop1 = new NoOp();

            nop1.Data = 123;
            ts.AddNamedInstruction("niceId", nop1);
            NoOp nop2 = new NoOp();

            nop2.Data = 456;
            ts.AddNamedInstruction("greatId", nop2);
            Message message = new Message();

            message.AddText("Let's count, '");
            message.AddDataRef("$niceId", nop1);
            message.AddText("' and '");
            message.AddDataRef("$greatId.data", nop2);
            message.AddText("' to see it work!");
            string result = message.Read();

            Assert.AreEqual("Let's count, '123' and '456' to see it work!", result, "Message not relayed intact!");
        }
Пример #4
0
        /// <summary>
        /// Creates and parses a message contained in some instructions.
        /// </summary>
        /// <param name="ins"></param>
        /// <param name="body"></param>
        protected void InterpretMessage(XmlNodeList body)
        {
            if (body != null)
            {
                Message message = new Message();

                foreach (XmlNode node in body)
                {
                    switch (node.Name)
                    {
                    case "#text":                     // a nameless text node
                        message.AddText(node.Value);
                        break;

                    case "data":
                        message.AddDataRef(XmlFiler.getAttribute(node, "of"), this);
                        break;

                    case "beep":
                        message.AddSound(new Beep());
                        break;

                    case "sound":
                        string frequency = XmlFiler.getAttribute(node, "frequency");
                        string duration  = XmlFiler.getAttribute(node, "duration");
                        m_log.isTrue(frequency != null && duration != null, makeNameTag() + "Sound instruction must have a frequency and duration.");
                        Sound sound = null;
                        try { sound = new Sound(Convert.ToUInt32(frequency), Convert.ToUInt32(duration)); }
                        catch { m_log.fail(makeNameTag() + "Sound instruction must have a frequency and duration in milliseconds."); }
                        message.AddSound(sound);
                        break;
                    }
                }
                Message = message;
            }
        }
Пример #5
0
		/// <summary>
		/// Creates and parses a message contained in some instructions.
		/// </summary>
		/// <param name="ins"></param>
		/// <param name="body"></param>
		static void InterpretMessage(CheckBase ins, XmlNodeList body)
		{
			if (body != null )
			{
				Message message = new Message();

				foreach (XmlNode node in body)
				{
					switch (node.Name)
					{
						case "#text": // a nameless text node
							message.AddText(node.Value);
							break;
						case "data":
							message.AddDataRef(XmlFiler.getAttribute(node,"of"),ins);
							break;
						case "beep":
							message.AddSound(CreateBeep(node));
							break;
						case "sound":
							message.AddSound(CreateSound(node));
							break;
					}
				}
				ins.Message = message;
			}
		}
Пример #6
0
        /// <summary>
        /// Creates and parses a message contained in some instructions.
        /// </summary>
        /// <param name="ins"></param>
        /// <param name="body"></param>
        protected void InterpretMessage(XmlNodeList body)
        {
            if (body != null)
            {
                Message message = new Message();

                foreach (XmlNode node in body)
                {
                    switch (node.Name)
                    {
                    case "#text": // a nameless text node
                        message.AddText(node.Value);
                        break;
                    case "data":
                        message.AddDataRef(XmlFiler.getAttribute(node, "of"), this);
                        break;
                    case "beep":
                        message.AddSound(new Beep());
                        break;
                    case "sound":
                        string frequency = XmlFiler.getAttribute(node, "frequency");
                        string duration = XmlFiler.getAttribute(node, "duration");
                        m_log.isTrue(frequency != null && duration != null, makeNameTag() + "Sound instruction must have a frequency and duration.");
                        Sound sound = null;
                        try { sound = new Sound(Convert.ToUInt32(frequency), Convert.ToUInt32(duration)); }
                        catch { m_log.fail(makeNameTag() + "Sound instruction must have a frequency and duration in milliseconds."); }
                        message.AddSound(sound);
                        break;
                    }
                }
                Message = message;
            }
        }