Example #1
0
        public void RelaySyncMessage()
        {
            StubServiceHost.FindDefaultService <IValidatingCalculatorService>()
            .Setup(s => s.Add(It.IsAny <XlangCalculatorRequest>()))
            .Returns(new StringStream(string.Format(CALCULATOR_RESPONSE_XML, 3)));

            IValidatingCalculatorService client = null;

            try
            {
                client = SimpleServiceClient <CalculatorService, IValidatingCalculatorService> .Create();

                var calculatorResult = client.Add(new XlangCalculatorRequest(CALCULATOR_REQUEST_XML));
                Assert.AreEqual(string.Format(CALCULATOR_RESPONSE_XML, 3), calculatorResult.RawXmlBody);
                client.Close();
            }
            catch (Exception)
            {
                if (client != null)
                {
                    client.Abort();
                }
                throw;
            }
        }
        public void RelaySyncMessage()
        {
            _soapStub.As <IValidatingCalculatorService>()
            .Setup(s => s.Add(It.IsAny <XLangCalculatorRequest>()))
            .Returns(new StringStream(string.Format(CALCULATOR_RESPONSE_XML, 3)));

            IValidatingCalculatorService client = null;

            try
            {
                client = SoapClient <IValidatingCalculatorService> .For(_calculatorServiceHost.Endpoint);

                var calculatorResult = client.Add(new XLangCalculatorRequest(CALCULATOR_REQUEST_XML));
                calculatorResult.RawXmlBody.Should().Be(string.Format(CALCULATOR_RESPONSE_XML, 3));
                client.Close();
            }
            catch (Exception)
            {
                client?.Abort();
                throw;
            }
        }