コード例 #1
0
        public void Should_invoke_the_continuation()
        {
            var transport = MockRepository.GenerateStub <IMsmqTransport>();

            transport.Stub(x => x.Receive(null))
            .Callback(new Func <Func <Message, Action <Message> >, bool>(Forwarder));

            var address = MockRepository.GenerateMock <IMsmqEndpointAddress>();

            IEndpoint endpoint = new MsmqEndpoint(address, new XmlMessageSerializer(), transport, MockRepository.GenerateMock <IMsmqTransport>());

            var future = new Future <object>();

            endpoint.Receive(m =>
                             message =>
            {
                Assert.IsInstanceOf <SimpleMessage>(message);

                Assert.AreEqual(((SimpleMessage)message).Name, "Chris");

                future.Complete(message);
            });

            Assert.IsTrue(future.IsAvailable(), "Receive was not called");
        }
コード例 #2
0
        public static IEndpoint New(CreateMsmqEndpointSettings settings)
        {
            try
            {
                Guard.Against.Null(settings.Address, "An address for the endpoint must be specified");
                Guard.Against.Null(settings.ErrorAddress, "An error address for the endpoint must be specified");
                Guard.Against.Null(settings.Serializer, "A message serializer for the endpoint must be specified");

                var transport = MsmqTransportFactory.New(settings);
                
				// TODO Does this need to be a bus concern?
                PurgeExistingMessagesIfRequested(settings);

                var errorSettings = new CreateMsmqTransportSettings(settings.ErrorAddress, settings);
				if(transport.MsmqAddress.IsTransactional)
					settings.Transactional = true;

                IMsmqTransport errorTransport = MsmqTransportFactory.New(errorSettings);

                var endpoint = new MsmqEndpoint(settings.Address, settings.Serializer, transport, errorTransport);

                return endpoint;
            }
            catch (Exception ex)
            {
                throw new EndpointException(settings.Address.Uri, "Failed to create MSMQ endpoint", ex);
            }
        }
コード例 #3
0
		public void Should_invoke_the_continuation()
		{
			var transport = MockRepository.GenerateStub<IMsmqTransport>();
			transport.Stub(x => x.Receive(null))
				.Callback(new Func<Func<Message, Action<Message>>, bool>(Forwarder));

			var address = MockRepository.GenerateMock<IMsmqEndpointAddress>();

			IEndpoint endpoint = new MsmqEndpoint(address, new XmlMessageSerializer(), transport, MockRepository.GenerateMock<IMsmqTransport>());

			var future = new Future<object>();

			endpoint.Receive(m =>
			                 message =>
			                 	{
			                 		Assert.IsInstanceOf<SimpleMessage>(message);

			                 		Assert.AreEqual(((SimpleMessage) message).Name, "Chris");

			                 		future.Complete(message);
			                 	});

			Assert.IsTrue(future.IsAvailable(), "Receive was not called");
		}