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()); } }
public void TestRemoteMethodCallSerialization_MissingComponentNameElement() { 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("ComponentName", xml.Name.NamespaceName)).Remove(); var roundtrip = new RemoteMethodCall(); Assert.IsFalse(roundtrip.Validate(xml)); }
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); }