protected MessageSender CreateSender()
 {
     var connectionManager = new DefaultConnectionManager(ConnectionConfiguration);
     var transactionalUnitOfWork = new TransactionalUnitOfWork(connectionManager)
         {
             EndpointAddress = SenderAddress
         };
     var eventSourcedUnitOfWork = new EventSourcedUnitOfWork(connectionManager)
         {
             EndpointAddress = SenderAddress
         };
     return new MessageSender(transactionalUnitOfWork, eventSourcedUnitOfWork, connectionManager)
         {
             EndpointAddress = SenderAddress
         };
 }
        public void It_can_send_and_receive_messages()
        {
            var projectionsManager = new ProjectionsManager(new NoopLogger(), HttpEndPoint);
            projectionsManager.Enable("$by_category", AdminCredentials);

            var sinkProjectionCreator = new ReceiverSinkProjectionCreator
                {
                    ConnectionManager = new DefaultConnectionManager(ConnectionConfiguration)
                };
            sinkProjectionCreator.RegisterProjectionsFor(ReceiverAddress, "");

            var routerProjectionCreattor = new EventSourcedModeRouterProjectionCreator()
            {
                ConnectionManager = new DefaultConnectionManager(ConnectionConfiguration)
            };
            routerProjectionCreattor.RegisterProjectionsFor(SenderAddress, "");

            var unitOfWork = new EventSourcedUnitOfWork(new DefaultConnectionManager(ConnectionConfiguration))
                {
                    EndpointAddress = SenderAddress
                };
            var sender = CreateSender();
            
            unitOfWork.Begin();

            unitOfWork.Initialize("58",ExpectedVersion.NoStream);

            SendMessages(sender, 5);

            unitOfWork.End();

            if (!ExpectReceive(5, TimeSpan.FromSeconds(5)))
            {
                Assert.Fail("Received {0} messages out of 5", Count);
            }
        }