Exemplo n.º 1
0
        public void WcfClient_with_no_name_set_should_connect_to_the_channel_to_get_name()
        {
            const string testBuildAgentName = "teszt-buildagent";
            var testChannel = TestChannel.Create(r => new BuildAgentPropertiesResponse {Name = testBuildAgentName});
            var subject = new WcfClient(testChannel);

            Assert.That(subject.Name, Is.EqualTo(testBuildAgentName));
        }
Exemplo n.º 2
0
        public void WcfClients_endpointaddress_should_return_the_inner_channels_endpoint()
        {
            var testUri = "http://tesztUri.com/teszt".ToLowerInvariant();
            var testChannel = TestChannel.Create(null, testUri);
            var subject = new WcfClient(testChannel);

            Assert.That(subject.EndpointAddress, Is.Not.Null);
            Assert.That(subject.EndpointAddress, Is.EqualTo(testUri));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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);
        }
        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);
        }
Exemplo n.º 6
0
 public void WcfClient_with_no_name_and_failed_connection_should_return_name_as_Unknown()
 {
     var failingChannel = TestChannel.Create(r => { throw new EndpointNotFoundException(); });
     var subject = new WcfClient(failingChannel);
     Assert.That(subject.Name, Is.EqualTo("Unknown"));
 }
Exemplo n.º 7
0
 public void WcfClient_with_name_set_should_return_that_name()
 {
     var subject = new WcfClient(TestChannel.Create(null), "testname");
     Assert.That(subject.Name, Is.EqualTo("testname"));
 }