public static void SameBinding_Binary_EchoComplexString() { string variationDetails = "Client:: CustomBinding/BinaryEncoder/Http\nServer:: CustomBinding/BinaryEncoder/Http"; StringBuilder errorBuilder = new StringBuilder(); bool success = false; try { CustomBinding binding = new CustomBinding(new BinaryMessageEncodingBindingElement(), new HttpTransportBindingElement()); ChannelFactory <IWcfService> factory = new ChannelFactory <IWcfService>(binding, new EndpointAddress(Endpoints.HttpBinary_Address)); IWcfService serviceProxy = factory.CreateChannel(); ComplexCompositeType compositeObject = ScenarioTestHelpers.GetInitializedComplexCompositeType(); ComplexCompositeType result = serviceProxy.EchoComplex(compositeObject); success = compositeObject.Equals(result); if (!success) { errorBuilder.AppendLine(String.Format(" Error: expected response from service: '{0}' Actual was: '{1}'", compositeObject, result)); } } catch (Exception ex) { errorBuilder.AppendLine(String.Format(" Error: Unexpected exception was caught while doing the basic echo test for variation...\n'{0}'\nException: {1}", variationDetails, ex.ToString())); for (Exception innerException = ex.InnerException; innerException != null; innerException = innerException.InnerException) { errorBuilder.AppendLine(String.Format("Inner exception: {0}", innerException.ToString())); } } Assert.True(errorBuilder.Length == 0, errorBuilder.ToString()); }
public static void SameBinding_Binary_EchoComplexString() { CustomBinding binding = null; ChannelFactory <IWcfService> factory = null; EndpointAddress endpointAddress = null; IWcfService serviceProxy = null; ComplexCompositeType compositeObject = null; ComplexCompositeType result = null; try { // *** SETUP *** \\ binding = new CustomBinding(new BinaryMessageEncodingBindingElement(), new HttpTransportBindingElement()); endpointAddress = new EndpointAddress(Endpoints.HttpBinary_Address); factory = new ChannelFactory <IWcfService>(binding, endpointAddress); serviceProxy = factory.CreateChannel(); compositeObject = ScenarioTestHelpers.GetInitializedComplexCompositeType(); // *** EXECUTE *** \\ result = serviceProxy.EchoComplex(compositeObject); // *** VALIDATE *** \\ Assert.True(compositeObject.Equals(result), String.Format(" Error: expected response from service: '{0}' Actual was: '{1}'", compositeObject, result)); // *** CLEANUP *** \\ factory.Close(); ((ICommunicationObject)serviceProxy).Close(); } finally { // *** ENSURE CLEANUP *** \\ ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory); } }
public static bool RunComplexEchoTest(Binding binding, string address, string variation, StringBuilder errorBuilder, Action <ChannelFactory> factorySettings = null) { bool success = false; try { ChannelFactory <IWcfService> factory = new ChannelFactory <IWcfService>(binding, new EndpointAddress(address)); if (factorySettings != null) { factorySettings(factory); } IWcfService serviceProxy = factory.CreateChannel(); ComplexCompositeType compositeObject = new ComplexCompositeType() { BoolValue = true, ByteArrayValue = new byte[] { 0x60, 0x61, 0x62 }, CharArrayValue = new char[] { 'a', 'b', 'c' }, CharValue = 'a', DateTimeValue = new DateTime(2000, 1, 1), DayOfWeekValue = DayOfWeek.Sunday, DoubleValue = 3.14159265, FloatValue = 2.71828183f, GuidValue = new Guid("EFEA21A0-F59A-4F43-B5D3-B2C667CA6FB6"), IntValue = int.MinValue, LongerStringValue = GenerateStringValue(2048), LongValue = long.MaxValue, SbyteValue = (sbyte)'a', ShortValue = short.MaxValue, StringValue = "the quick brown fox jumps over the lazy dog", TimeSpanValue = TimeSpan.MinValue, UintValue = uint.MaxValue, UlongValue = ulong.MaxValue, UshortValue = ushort.MaxValue }; ComplexCompositeType result = serviceProxy.EchoComplex(compositeObject); success = compositeObject.Equals(result); if (!success) { errorBuilder.AppendLine(String.Format(" Error: expected response from service: '{0}' Actual was: '{1}'", testString, result)); } } catch (Exception ex) { Logger.LogInformation(" {0}", ex.Message); errorBuilder.AppendLine(String.Format(" Error: Unexpected exception was caught while doing the basic echo test for variation...\n'{0}'\nException: {1}", variation, ex.ToString())); } return(success); }
public static bool RunComplexEchoTest(Binding binding, string address, string variation, StringBuilder errorBuilder, Action<ChannelFactory> factorySettings = null) { bool success = false; try { ChannelFactory<IWcfService> factory = new ChannelFactory<IWcfService>(binding, new EndpointAddress(address)); if (factorySettings != null) { factorySettings(factory); } IWcfService serviceProxy = factory.CreateChannel(); ComplexCompositeType compositeObject = new ComplexCompositeType() { BoolValue = true, ByteArrayValue = new byte[] { 0x60, 0x61, 0x62 }, CharArrayValue = new char[] { 'a', 'b', 'c' }, CharValue = 'a', DateTimeValue = new DateTime(2000, 1, 1), DayOfWeekValue = DayOfWeek.Sunday, DoubleValue = 3.14159265, FloatValue = 2.71828183f, GuidValue = new Guid("EFEA21A0-F59A-4F43-B5D3-B2C667CA6FB6"), IntValue = int.MinValue, LongerStringValue = GenerateStringValue(2048), LongValue = long.MaxValue, SbyteValue = (sbyte)'a', ShortValue = short.MaxValue, StringValue = "the quick brown fox jumps over the lazy dog", TimeSpanValue = TimeSpan.MinValue, UintValue = uint.MaxValue, UlongValue = ulong.MaxValue, UshortValue = ushort.MaxValue }; ComplexCompositeType result = serviceProxy.EchoComplex(compositeObject); success = compositeObject.Equals(result); if (!success) { errorBuilder.AppendLine(String.Format(" Error: expected response from service: '{0}' Actual was: '{1}'", testString, result)); } } catch (Exception ex) { Logger.LogInformation(" {0}", ex.Message); errorBuilder.AppendLine(String.Format(" Error: Unexpected exception was caught while doing the basic echo test for variation...\n'{0}'\nException: {1}", variation, ex.ToString())); } return success; }