public void CreateProxy() { XmlRpcServiceProxyGenerator xmlRpcServiceProxyGenerator = new XmlRpcServiceProxyGenerator(); IMathXmlRpcService mathXmlRpcService = xmlRpcServiceProxyGenerator.CreateProxy <IMathXmlRpcService>(); Assert.IsTrue(mathXmlRpcService is IXmlRpcServiceProxy); Assert.IsNull(((IXmlRpcServiceProxy)mathXmlRpcService).ServiceEndpointUri); ((IXmlRpcServiceProxy)mathXmlRpcService).ServiceEndpointUri = new Uri("http://www.math.com/math"); int result = mathXmlRpcService.Add(1, 2); }
public void Dispatch() { MockRepository mockRepository = new MockRepository(); IMathXmlRpcService mathXmlRpcService = mockRepository.CreateMock <IMathXmlRpcService>(); Expect.Call(mathXmlRpcService.Add(1, 2)).Return(1 + 2); mockRepository.ReplayAll(); IXmlRpcServiceDispatcher xmlRpcServiceDispatcher = new XmlRpcServiceDispatcher(mathXmlRpcService.GetType()); using (MemoryStream memoryStream = new MemoryStream()) { xmlRpcServiceDispatcher.Dispatch(new XmlRpcServiceContext(mathXmlRpcService, ToStream( "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<methodCall><methodName>math:add</methodName>" + "<params>" + "<param><value><i4>1</i4></value></param>" + "<param><value><i4>2</i4></value></param>" + "</params>" + "</methodCall>"), memoryStream)); string response = Encoding.UTF8.GetString(memoryStream.ToArray()); Assert.AreEqual(Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble()) + "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<methodResponse>" + "<params>" + "<param>" + "<value>" + "<i4>3</i4>" + "</value>" + "</param>" + "</params>" + "</methodResponse>", response); } // using }