Ejemplo n.º 1
0
        public void TestForeignMapMessageTransformCreateNewMessage()
        {
            ForeignNmsMapMessage foreignMessage = new ForeignNmsMapMessage();

            foreignMessage.Body.SetBool("bool", true);
            foreignMessage.Body.SetChar("char", 'a');
            foreignMessage.Body.SetString("string", "string");
            foreignMessage.Body.SetByte("byte", 1);
            foreignMessage.Body.SetShort("short", 1);
            foreignMessage.Body.SetInt("int", 1);
            foreignMessage.Body.SetLong("long", 1);
            foreignMessage.Body.SetFloat("float", 1.5F);
            foreignMessage.Body.SetDouble("double", 1.5D);
            foreignMessage.Body.SetList("list", new List <string>()
            {
                "a"
            });
            foreignMessage.Body.SetDictionary("dictionary", new Dictionary <string, string>()
            {
                { "a", "a" }
            });
            foreignMessage.Body.SetBytes("bytes", new byte[] { 6 });

            NmsMessage transformed = NmsMessageTransformation.TransformMessage(factory, foreignMessage);

            Assert.IsNotNull(transformed);
            Assert.AreNotSame(foreignMessage, transformed);

            Assert.IsInstanceOf <NmsMapMessage>(transformed);

            NmsMapMessage message = (NmsMapMessage)transformed;

            Assert.IsTrue(message.Body.GetBool("bool"));
            Assert.AreEqual('a', message.Body.GetChar("char"));
            Assert.AreEqual("string", message.Body.GetString("string"));
            Assert.AreEqual(1, message.Body.GetByte("byte"));
            Assert.AreEqual(1, message.Body.GetShort("short"));
            Assert.AreEqual(1, message.Body.GetInt("int"));
            Assert.AreEqual(1, message.Body.GetLong("long"));
            Assert.AreEqual(1.5F, message.Body.GetFloat("float"));
            Assert.AreEqual(1.5F, message.Body.GetDouble("double"));
            CollectionAssert.AreEqual(new List <string>()
            {
                "a"
            }, message.Body.GetList("list"));
            CollectionAssert.AreEqual(new Dictionary <string, string>()
            {
                { "a", "a" }
            }, message.Body.GetDictionary("dictionary"));
            CollectionAssert.AreEqual(new byte[] { 6 }, message.Body.GetBytes("bytes"));
        }
Ejemplo n.º 2
0
        public void TestEmptyForeignMapMessageTransformCreateNewMessage()
        {
            ForeignNmsMapMessage foreignMessage = new ForeignNmsMapMessage();

            NmsMessage transformed = NmsMessageTransformation.TransformMessage(factory, foreignMessage);

            Assert.IsNotNull(transformed);
            Assert.AreNotSame(foreignMessage, transformed);

            Assert.IsInstanceOf <NmsMapMessage>(transformed);

            NmsMapMessage message = (NmsMapMessage)transformed;

            CollectionAssert.IsEmpty(message.Body.Keys);
        }
Ejemplo n.º 3
0
        public void TestNMSMessagePropertiesAreCopied()
        {
            ForeignNmsMapMessage foreignMessage = new ForeignNmsMapMessage();

            foreignMessage.Properties.SetBool("bool", true);
            foreignMessage.Properties.SetChar("char", 'a');
            foreignMessage.Properties.SetString("string", "string");
            foreignMessage.Properties.SetByte("byte", 1);
            foreignMessage.Properties.SetShort("short", 1);
            foreignMessage.Properties.SetInt("int", 1);
            foreignMessage.Properties.SetLong("long", 1);
            foreignMessage.Properties.SetFloat("float", 1.5F);
            foreignMessage.Properties.SetDouble("double", 1.5D);
            foreignMessage.Properties.SetList("list", new List <string>()
            {
                "a"
            });
            foreignMessage.Properties.SetDictionary("dictionary", new Dictionary <string, string>()
            {
                { "a", "a" }
            });
            foreignMessage.Properties.SetBytes("bytes", new byte[] { 6 });

            NmsMessage transformed = NmsMessageTransformation.TransformMessage(factory, foreignMessage);

            Assert.IsTrue(transformed.Properties.GetBool("bool"));
            Assert.AreEqual('a', transformed.Properties.GetChar("char"));
            Assert.AreEqual("string", transformed.Properties.GetString("string"));
            Assert.AreEqual(1, transformed.Properties.GetByte("byte"));
            Assert.AreEqual(1, transformed.Properties.GetShort("short"));
            Assert.AreEqual(1, transformed.Properties.GetInt("int"));
            Assert.AreEqual(1, transformed.Properties.GetLong("long"));
            Assert.AreEqual(1.5F, transformed.Properties.GetFloat("float"));
            Assert.AreEqual(1.5F, transformed.Properties.GetDouble("double"));
            CollectionAssert.AreEqual(new List <string>()
            {
                "a"
            }, transformed.Properties.GetList("list"));
            CollectionAssert.AreEqual(new Dictionary <string, string>()
            {
                { "a", "a" }
            }, transformed.Properties.GetDictionary("dictionary"));
            CollectionAssert.AreEqual(new byte[] { 6 }, transformed.Properties.GetBytes("bytes"));
        }