public void ObjectTypePropertyYieldsTheCorrectType()
        {
            MessageQueueFactoryObject mqFactoryObject = new MessageQueueFactoryObject();

            Assert.AreEqual(typeof(MessageQueue), mqFactoryObject.ObjectType,
                            "The MessageQueueFactoryObject class ain't giving back DefaultMessageQueue types (it must).");
        }
 public void CheckGetObjectReturnsNewInstance()
 {
     MessageQueueFactoryObject mqFactoryObject = new MessageQueueFactoryObject();
     MessageQueue queue = mqFactoryObject.GetObject() as MessageQueue;
     MessageQueue anotherQueue = mqFactoryObject.GetObject() as MessageQueue;
     Assert.IsFalse(queue == anotherQueue, "Should be returning new instances");
     Assert.IsFalse(mqFactoryObject.IsSingleton,
                    "The MessageQueueFactoryObject class must be configured to return shared instances.");
 }
        public void CheckGetObjectReturnsNewInstance()
        {
            MessageQueueFactoryObject mqFactoryObject = new MessageQueueFactoryObject();
            MessageQueue queue        = mqFactoryObject.GetObject() as MessageQueue;
            MessageQueue anotherQueue = mqFactoryObject.GetObject() as MessageQueue;

            Assert.IsFalse(queue == anotherQueue, "Should be returning new instances");
            Assert.IsFalse(mqFactoryObject.IsSingleton,
                           "The MessageQueueFactoryObject class must be configured to return shared instances.");
        }
 public void CheckDefaultConstructorValues()
 {
     MessageQueueFactoryObject mqFactoryObject = new MessageQueueFactoryObject();
     MessageQueue queue = mqFactoryObject.GetObject() as MessageQueue;
     Assert.IsNotNull(queue);
     Assert.AreEqual(string.Empty, queue.Path);
     Assert.AreEqual(false, queue.DenySharedReceive);
     Assert.AreEqual(QueueAccessMode.SendAndReceive, queue.AccessMode);
     //EnableCache property not on queue.
 }
        public void CheckDefaultConstructorValues()
        {
            MessageQueueFactoryObject mqFactoryObject = new MessageQueueFactoryObject();
            MessageQueue queue = mqFactoryObject.GetObject() as MessageQueue;

            Assert.IsNotNull(queue);
            Assert.AreEqual(string.Empty, queue.Path);
            Assert.AreEqual(false, queue.DenySharedReceive);
            Assert.AreEqual(QueueAccessMode.SendAndReceive, queue.AccessMode);
            //EnableCache property not on queue.
        }
 /// <summary>
 /// Registers the message queue, its creation specified via the factory method
 /// MessageQueueCreatorDelegate, with the provided name in the application context
 /// </summary>
 /// <param name="messageQueueObjectName">Name of the message queue object.</param>
 /// <param name="messageQueueCreatorDelegate">The message queue creator delegate.</param>
 public void RegisterMessageQueue(string messageQueueObjectName,
                          MessageQueueCreatorDelegate messageQueueCreatorDelegate)
 {
     MessageQueueFactoryObject mqfo = new MessageQueueFactoryObject();
     mqfo.MessageCreatorDelegate = messageQueueCreatorDelegate;
     applicationContext.ObjectFactory.RegisterSingleton(messageQueueObjectName, mqfo);
     IDictionary<string, MessageQueueMetadataCache> caches = applicationContext.GetObjects<MessageQueueMetadataCache>();
     foreach (KeyValuePair<string, MessageQueueMetadataCache> entry in caches)
     {
         entry.Value.Insert(mqfo.Path, new MessageQueueMetadata(mqfo.RemoteQueue, mqfo.RemoteQueueIsTransactional));
     }             
 }
        public void CheckSimpleProperties()
        {
            MessageQueueFactoryObject mqFactoryObject = (MessageQueueFactoryObject)applicationContext["&testqueue"];

            Assert.AreEqual(@".\Private$\testqueue", mqFactoryObject.Path);
            Assert.AreEqual(true, mqFactoryObject.DenySharedReceive);
            Assert.AreEqual(QueueAccessMode.Receive, mqFactoryObject.AccessMode);
            Assert.AreEqual(true, mqFactoryObject.EnableCache);
            MessageQueue mq = (MessageQueue)applicationContext["testqueue"];

            Assert.AreEqual("MyLabel", mq.Label);
        }
 public void ObjectTypePropertyYieldsTheCorrectType()
 {
     MessageQueueFactoryObject mqFactoryObject = new MessageQueueFactoryObject();
     Assert.AreEqual(typeof (MessageQueue), mqFactoryObject.ObjectType,
                     "The MessageQueueFactoryObject class ain't giving back DefaultMessageQueue types (it must).");
 }
 /// <summary>
 /// Registers the message queue, its creation specified via the factory method
 /// MessageQueueCreatorDelegate, with the provided name in the application context
 /// </summary>
 /// <param name="messageQueueObjectName">Name of the message queue object.</param>
 /// <param name="messageQueueCreatorDelegate">The message queue creator delegate.</param>
 public void RegisterMessageQueue(string messageQueueObjectName,
     MessageQueueCreatorDelegate messageQueueCreatorDelegate)
 {
     MessageQueueFactoryObject mqfo = new MessageQueueFactoryObject();
     mqfo.MessageCreatorDelegate = messageQueueCreatorDelegate;
     applicationContext.ObjectFactory.RegisterSingleton(messageQueueObjectName, mqfo);
     IDictionary caches = applicationContext.GetObjectsOfType(typeof(MessageQueueMetadataCache));
     foreach (DictionaryEntry entry in caches)
     {
         ((MessageQueueMetadataCache) entry.Value).Insert(mqfo.Path, new MessageQueueMetadata(mqfo.RemoteQueue, mqfo.RemoteQueueIsTransactional));
     }
 }