예제 #1
0
        public void TestRemoteMethodCallSerialization()
        {
            var call = new RemoteMethodCall();

            call.ComponentName = "component";
            call.CallId        = Guid.NewGuid();
            call.MethodName    = "sampleMethod";
            call.Parameters    = new List <object> {
                1, 2, 3
            };

            var xml = call.Serialize();


            var roundtrip = new RemoteMethodCall();

            Assert.IsTrue(roundtrip.Validate(xml));
            roundtrip.Deserialize(xml);


            Assert.IsNotNull(roundtrip);
            Assert.AreEqual <Guid>(call.CallId, roundtrip.CallId);
            Assert.AreEqual <string>(call.ComponentName, roundtrip.ComponentName);
            Assert.AreEqual <string>(call.MethodName, roundtrip.MethodName);
            Assert.AreEqual <int>(call.Parameters.Count(), roundtrip.Parameters.Count());

            int count = call.Parameters.Count();

            for (int i = 0; i < count; i++)
            {
                Assert.AreEqual <int>((int)call.Parameters.Skip(i).First(), (int)roundtrip.Parameters.Skip(i).First());
            }
        }
예제 #2
0
        public void TestRemoteMethodCallSerialization_MissingCallIdElement()
        {
            var call = new RemoteMethodCall();

            call.ComponentName = "component";
            call.CallId        = Guid.NewGuid();
            call.MethodName    = "sampleMethod";
            call.Parameters    = new List <object> {
                1, 2, 3
            };

            var xml = call.Serialize();

            xml.Element(XName.Get("CallId", xml.Name.NamespaceName)).Remove();

            var roundtrip = new RemoteMethodCall();

            Assert.IsFalse(roundtrip.Validate(xml));
        }
예제 #3
0
        public void TestRemoteMethodCallSerialization_NoParameters()
        {
            var call = new RemoteMethodCall();

            call.ComponentName = "component";
            call.CallId        = Guid.NewGuid();
            call.MethodName    = "sampleMethod";

            var xml = call.Serialize();


            var roundtrip = new RemoteMethodCall();

            Assert.IsTrue(roundtrip.Validate(xml));
            roundtrip.Deserialize(xml);


            Assert.IsNotNull(roundtrip);
            Assert.AreEqual <Guid>(call.CallId, roundtrip.CallId);
            Assert.AreEqual <string>(call.ComponentName, roundtrip.ComponentName);
            Assert.AreEqual <string>(call.MethodName, roundtrip.MethodName);
        }