示例#1
0
        public void Variation_EndMethod()
        {
            var host = ServiceHelper.CreateWebHostBuilder <Startup>(_output).Build();

            using (host)
            {
                host.Start();
                var httpBinding = ClientHelper.GetBufferedModeBinding();
                var factory     = new System.ServiceModel.ChannelFactory <IClientAsync_767311>(httpBinding, new System.ServiceModel.EndpointAddress(new Uri("http://localhost:8080/BasicWcfService/SyncService.svc")));
                IClientAsync_767311 clientAsync_ = factory.CreateChannel();
                _output.WriteLine("Testing [Variation_EndMethod]");
                IAsyncResult result = clientAsync_.BeginEchoString(clientString, null, null);
                _output.WriteLine("Message sent via Async");
                string strB = clientAsync_.EndEchoString(result);
                Assert.Equal(clientResult, strB);
            }
        }
示例#2
0
        public void Variation_CallbackMethod()
        {
            var host = ServiceHelper.CreateWebHostBuilder <Startup>(_output).Build();

            using (host)
            {
                host.Start();
                var httpBinding = ClientHelper.GetBufferedModeBinding();
                var factory     = new System.ServiceModel.ChannelFactory <IClientAsync_767311>(httpBinding, new System.ServiceModel.EndpointAddress(new Uri("http://localhost:8080/BasicWcfService/SyncService.svc")));
                IClientAsync_767311 clientAsync_ = factory.CreateChannel();
                _output.WriteLine("Testing [Variation_CallbackMethod]");
                AsyncCallback callback = new AsyncCallback(CallbackResults);
                IAsyncResult  result   = clientAsync_.BeginEchoString(clientString, callback, null);
                _output.WriteLine("Message sent via Async, waiting for callback");
                this.autoEvent.WaitOne();
                _output.WriteLine("Event has been signalled");
                string text = clientAsync_.EndEchoString(result);
                _output.WriteLine(text);
                Assert.Equal(clientResult, text);
            }
        }
示例#3
0
        public void Variation_PollingMethod()
        {
            IWebHost host = ServiceHelper.CreateWebHostBuilder <Startup>(_output).Build();

            using (host)
            {
                host.Start();
                System.ServiceModel.BasicHttpBinding httpBinding = ClientHelper.GetBufferedModeBinding();
                var factory = new System.ServiceModel.ChannelFactory <IClientAsync_767311>(httpBinding, new System.ServiceModel.EndpointAddress(new Uri("http://localhost:8080/BasicWcfService/SyncService.svc")));
                IClientAsync_767311 clientAsync_ = factory.CreateChannel();
                _output.WriteLine("Testing [Variation_PollingMethod]");
                IAsyncResult asyncResult = clientAsync_.BeginEchoString(clientString, null, null);
                _output.WriteLine("Message sent via Async");
                _output.WriteLine("Start polling for IsCompleted != true");
                while (!asyncResult.IsCompleted)
                {
                }
                _output.WriteLine("IsCompleted == true");
                string text = clientAsync_.EndEchoString(asyncResult);
                _output.WriteLine(text);
                Assert.Equal(clientResult, text);
            }
        }