Example #1
0
 public void Valid_url_should_point_to_the_specified_endpoint_address()
 {
     using (var subject = new WcfChannel <IEmptyClient>(TestUri))
     {
         Assert.That(subject.EndpointAddress.Uri.ToString(), Is.EqualTo(TestUri));
     }
 }
Example #2
0
        public void Send <T>(T message)
        {
            _fiber.Add(() =>
            {
                try
                {
                    var envelope = new WcfMessageEnvelope
                    {
                        MessageType = typeof(T).AssemblyQualifiedName,
                        Body        = Serializer.Serialize(message),
                    };

                    WcfChannel <WcfMessageEnvelope> proxy = _channelFactory.CreateChannel();
                    proxy.Send(envelope);

                    var channel = proxy as IClientChannel;
                    if (channel != null)
                    {
                        channel.Close();
                    }

                    var disposable = proxy as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                catch
                {
                    // i hate doing this, but we don't want to take down the entire appdomain
                }
            });
        }
Example #3
0
 public void Valid_url_should_create_a_WSHttpBinding()
 {
     using (var subject = new WcfChannel <IEmptyClient>(TestUri))
     {
         Assert.IsInstanceOf <WSHttpBinding>(subject.Binding);
     }
 }
Example #4
0
 public void Valid_url_should_point_to_the_specified_endpoint_address()
 {
     using (var subject = new WcfChannel<IEmptyClient>(TestUri))
     {
         Assert.That(subject.EndpointAddress.Uri.ToString(), Is.EqualTo(TestUri));
     }
 }
Example #5
0
 public void Valid_url_should_create_a_WSHttpBinding()
 {
     using (var subject = new WcfChannel<IEmptyClient>(TestUri))
     {
         Assert.IsInstanceOf<WSHttpBinding>(subject.Binding);
     }
 }
Example #6
0
 public void Wrapper_should_return_a_specified_client_instance()
 {
     using (var subject = new WcfChannel <IEmptyClient>(TestUri))
     {
         IEmptyClient client = subject.Client;
         Assert.IsInstanceOf <IEmptyClient>(subject.Client);
         Assert.IsNotNull(client);
     }
 }
Example #7
0
 public void Wrapper_should_return_a_specified_client_instance()
 {
     using (var subject = new WcfChannel<IEmptyClient>(TestUri))
     {
         IEmptyClient client = subject.Client;
         Assert.IsInstanceOf<IEmptyClient>(subject.Client);
         Assert.IsNotNull(client);
     }
 }
Example #8
0
        public void Calling_the_client_after_dispose_should_throw_InvalidOperationException()
        {
            var subject = new WcfChannel<IEmptyClient>(TestUri);

            IEmptyClient client = subject.Client;
            subject.Dispose();

            Assert.Throws<InvalidOperationException>(() => { IEmptyClient secondAccess = subject.Client; });
        }
Example #9
0
        public void Calling_the_client_after_dispose_should_throw_InvalidOperationException()
        {
            var subject = new WcfChannel <IEmptyClient>(TestUri);

            IEmptyClient client = subject.Client;

            subject.Dispose();

            Assert.Throws <InvalidOperationException>(() => { IEmptyClient secondAccess = subject.Client; });
        }
Example #10
0
        public WcfChannelProxy(Fiber fiber, Uri serviceUri, string pipeName)
        {
            _fiber     = fiber;
            Serializer = new FastTextSerializer();
            ServiceUri = serviceUri;
            PipeName   = pipeName;

            _address = new EndpointAddress(serviceUri.AppendPath(pipeName));
            _proxy   = System.ServiceModel.ChannelFactory <WcfChannel <WcfMessageEnvelope> > .CreateChannel(new NetNamedPipeBinding(),
                                                                                                            _address);
        }
Example #11
0
        public void Calling_Dispose_on_a_closed_channel_should_not_throw()
        {
            TestDelegate alreadyClosedChannel = () =>
            {
                var          subject = new WcfChannel <IEmptyClient>(TestUri);
                IEmptyClient client  = subject.Client;
                subject.Dispose();
                subject.Dispose();
            };

            Assert.DoesNotThrow(alreadyClosedChannel);
        }
Example #12
0
        public void Calling_Dispose_on_a_closed_channel_should_not_throw()
        {
            TestDelegate alreadyClosedChannel = () =>
            {
                var subject = new WcfChannel<IEmptyClient>(TestUri);
                IEmptyClient client = subject.Client;
                subject.Dispose();
                subject.Dispose();
            };

            Assert.DoesNotThrow(alreadyClosedChannel);
        }
Example #13
0
        public void RetrieveServerNameRetrievesNameFromInvoker()
        {
            var serverName  = "urn:ccnet:someserver";
            var invokerMock = new Mock <IActionInvoker>(MockBehavior.Strict);

            invokerMock.Setup(i => i.RetrieveServerName()).Returns(serverName).Verifiable();

            var channel = new WcfChannel(invokerMock.Object);
            var actual  = channel.RetrieveServerName();

            Assert.AreSame(serverName, actual);
            invokerMock.Verify();
        }
Example #14
0
        public void QueryPassesOnCall()
        {
            var urn         = string.Empty;
            var args        = new QueryArguments();
            var result      = new QueryResult();
            var invokerMock = new Mock <IActionInvoker>(MockBehavior.Strict);

            invokerMock.Setup(i => i.Query(urn, args)).Returns(result).Verifiable();

            var channel = new WcfChannel(invokerMock.Object);
            var actual  = channel.Query(urn, args);

            Assert.AreSame(result, actual);
            invokerMock.Verify();
        }
Example #15
0
        public void PingReturnsTrue()
        {
            var channel = new WcfChannel(null);

            Assert.IsTrue(channel.Ping());
        }