Exemple #1
0
        public void RelayAsyncMessage()
        {
            _soapStub.As <IValidatingCalculatorService>()
            .Setup(
                s => s.BeginMultiply(
                    It.IsAny <XLangCalculatorRequest>(),
                    It.IsAny <AsyncCallback>(),
                    It.IsAny <object>()))
            .Returns(new StringStream(string.Format(CALCULATOR_RESPONSE_XML, 2)));

            IValidatingCalculatorService client = null;

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

                var calculatorResult = Task <XLangCalculatorResponse> .Factory
                                       .FromAsync(client.BeginMultiply, client.EndMultiply, new XLangCalculatorRequest(CALCULATOR_REQUEST_XML), null)
                                       .Result;

                calculatorResult.RawXmlBody.Should().Be(string.Format(CALCULATOR_RESPONSE_XML, 2));
                client.Close();
            }
            catch (Exception)
            {
                client?.Abort();
                throw;
            }
        }
Exemple #2
0
        public void RelayAsyncMessage()
        {
            StubServiceHost.FindDefaultService <IValidatingCalculatorService>().Setup(
                s => s.BeginMultiply(
                    It.IsAny <XlangCalculatorRequest>(),
                    It.IsAny <AsyncCallback>(),
                    It.IsAny <object>()))
            .Returns(new StringStream(string.Format(CALCULATOR_RESPONSE_XML, 2)));

            IValidatingCalculatorService client = null;

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

                var calculatorResult = Task <XlangCalculatorResponse> .Factory
                                       .FromAsync(client.BeginMultiply, client.EndMultiply, new XlangCalculatorRequest(CALCULATOR_REQUEST_XML), null)
                                       .Result;

                Assert.AreEqual(string.Format(CALCULATOR_RESPONSE_XML, 2), calculatorResult.RawXmlBody);
                client.Close();
            }
            catch (Exception)
            {
                if (client != null)
                {
                    client.Abort();
                }
                throw;
            }
        }
Exemple #3
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;
            }
        }
Exemple #4
0
        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(CALCULATOR_REQUEST_XML));
                calculatorResult.RawXmlBody.Should().Be(string.Format(CALCULATOR_RESPONSE_XML, 3));
                client.Close();
            }
            catch (Exception)
            {
                client?.Abort();
                throw;
            }
        }