Beispiel #1
0
        public void Echomessage_should_return_a_failed_response_when_the_channel_fails()
        {
            var testChannel = TestChannel.Create(r =>
            {
                throw new EndpointNotFoundException();
            });

            var subject = new WcfClient(testChannel);

            var result = subject.EchoMessage("message");

            Assert.That(result.ResponseStatus, Is.EqualTo(ResponseStatus.Failure));
            Assert.IsNotInstanceOf <EchoResponse>(result);
        }
Beispiel #2
0
        public void EchoMessage_should_return_echoed_message_when_the_connection_is_okay()
        {
            const string echoedMessage = "teszt echo";
            var          testChannel   = TestChannel.Create(r => new EchoResponse {
                Message = echoedMessage
            });

            var subject = new WcfClient(testChannel);

            var result = subject.EchoMessage("message");

            Assert.That(result.ResponseStatus, Is.EqualTo(ResponseStatus.Success));
            Assert.IsInstanceOf <EchoResponse>(result);
            Assert.That(((EchoResponse)result).Message, Is.EqualTo(echoedMessage));
        }
        public void Calling_dispose_on_a_WcfClient_should_not_throw_EndpointNotFoundException()
        {
            // start the server
            var wcfServer = new WcfServer();

            wcfServer.Start();

            // create the client and test it
            var client = new WcfClient(new WcfChannel <IMessageProcessor>(wcfServer.EndpointAddress), "testclient");

            Assert.DoesNotThrow(() =>
            {
                var response = client.EchoMessage("teszt");
                Assert.IsInstanceOf <EchoResponse>(response);
                Assert.That(((EchoResponse)response).Message, Is.StringContaining("Echo: teszt"));
            });

            // now stop the server and dispose the client and check if it throws
            wcfServer.Stop();
            Assert.DoesNotThrow(client.Dispose);
        }