public void TestWriteStringReadLegal()
        {
            NmsStreamMessage streamMessage = factory.CreateStreamMessage();

            string integralValue = Convert.ToString(byte.MaxValue);

            streamMessage.WriteString(integralValue);
            streamMessage.Reset();

            AssertGetStreamEntryEquals <string>(streamMessage, true, integralValue);
            AssertGetStreamEntryEquals <bool>(streamMessage, true, false);
            AssertGetStreamEntryEquals <byte>(streamMessage, true, byte.MaxValue);

            streamMessage.ClearBody();
            integralValue = Convert.ToString(short.MaxValue);
            streamMessage.WriteString(integralValue);
            streamMessage.Reset();

            AssertGetStreamEntryEquals <short>(streamMessage, true, short.MaxValue);

            streamMessage.ClearBody();
            integralValue = Convert.ToString(int.MaxValue);
            streamMessage.WriteString(integralValue);
            streamMessage.Reset();

            AssertGetStreamEntryEquals <int>(streamMessage, true, int.MaxValue);

            streamMessage.ClearBody();
            integralValue = Convert.ToString(long.MaxValue);
            streamMessage.WriteString(integralValue);
            streamMessage.Reset();

            AssertGetStreamEntryEquals <long>(streamMessage, true, long.MaxValue);

            streamMessage.ClearBody();
            string fpValue = Convert.ToString(float.MaxValue, CultureInfo.InvariantCulture);

            streamMessage.WriteString(fpValue);
            streamMessage.Reset();

            AssertGetStreamEntryEquals <float>(streamMessage, true, float.Parse(fpValue));

            // TODO: make following pass
            //AssertGetStreamEntryEquals<double>(streamMessage, true, double.Parse(fpValue));
        }
        public void TestWriteReadString()
        {
            NmsStreamMessage streamMessage = factory.CreateStreamMessage();

            string value = "myString";

            streamMessage.WriteString(value);
            streamMessage.Reset();

            Assert.AreEqual(value, streamMessage.ReadString(), "Value not as expected");
        }
        public void TestWriteStringReadIllegal()
        {
            NmsStreamMessage streamMessage = factory.CreateStreamMessage();

            string stringValue = "myString";

            streamMessage.WriteString(stringValue);
            streamMessage.Reset();

            AssertGetStreamEntryThrowsMessageFormatException <char>(streamMessage);
            AssertGetStreamEntryThrowsMessageFormatException <byte[]>(streamMessage);
        }
        public void TestIllegalTypeConversionFailureDoesNotIncrementPosition2()
        {
            NmsStreamMessage streamMessage = factory.CreateStreamMessage();

            String stringVal = "myString";

            streamMessage.WriteString(stringVal);
            streamMessage.Reset();

            AssertGetStreamEntryThrowsMessageFormatException <byte[]>(streamMessage);

            Assert.AreEqual(stringVal, streamMessage.ReadString(), "Expected written string");
        }
        public void TestReadBigString()
        {
            NmsStreamMessage streamMessage = factory.CreateStreamMessage();

            StringBuilder stringBuilder = new StringBuilder(1024 * 1024);

            for (int i = 0; i < 1024 * 1024; i++)
            {
                stringBuilder.Append('a' + i % 26);
            }

            string bigString = stringBuilder.ToString();

            streamMessage.WriteString(bigString);
            streamMessage.Reset();
            Assert.AreEqual(bigString, streamMessage.ReadString());
        }
Beispiel #6
0
 public void WriteString(string value)
 {
     message.WriteString(value);
 }