public void MessageQueueMessageQueueReaderMethodReadMessagesRemote() { var mockMsmqRepository = new Moq.Mock <IMsmqRepository>(); mockMsmqRepository.Setup(x => x.Exists(It.IsAny <string>())).Returns(true); mockMsmqRepository.Setup(x => x.Create(It.IsAny <string>(), It.IsAny <bool>())); mockMsmqRepository.Setup(x => x.WriteMessage( It.IsAny <string>(), It.IsAny <object>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <System.Messaging.IMessageFormatter>())); mockMsmqRepository.Setup(x => x.Start()).Raises( x => x.MessageQueuesProcessed += null, new EngineEventArgs(string.Empty)); mockMsmqRepository.Setup(x => x.Close()); mockMsmqRepository.Setup(x => x.GetTotalMessages()).Returns(It.IsAny <int>()); mockMsmqRepository.Raise( x => x.MessageQueuesProcessed += null, new EngineEventArgs(It.IsAny <string>())); // add mock repositories to the container ServiceLocator.Container.RegisterInstance <IMsmqRepository>(mockMsmqRepository.Object); TestHelper.LoadMockFileSystemRepository(); string serverName = "sedidevlab02"; string queuePath = "private$\\testing"; MessageQueueReader messageQueueReader = new MessageQueueReader(queuePath, false, serverName); Assert.IsTrue(true); }
/// <summary> /// Helper method to load the default mocks for the MSMQ repository. /// </summary> public static void LoadMockMsmqRepositoryServiceManager() { var mockMsmqRepository = new Moq.Mock <IMsmqRepository>(); mockMsmqRepository.Setup(x => x.Exists( It.IsAny <string>())) .Returns(It.IsAny <bool>); mockMsmqRepository.Setup(x => x.Create( It.IsAny <string>(), It.IsAny <bool>())); mockMsmqRepository.Setup(x => x.WriteMessage( It.IsAny <string>(), It.IsAny <object>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <System.Messaging.IMessageFormatter>())); mockMsmqRepository.Setup(x => x.Start()).Raises( x => x.MessageQueuesProcessed += null, new EngineEventArgs(new object[] { "Name", "Value" })); mockMsmqRepository.Setup(x => x.Close()); mockMsmqRepository.Setup(x => x.GetTotalMessages()).Returns(It.IsAny <int>()); mockMsmqRepository.Raise( x => x.MessageQueuesProcessed += null, new EngineEventArgs(It.IsAny <string>())); ServiceLocator.Container.RegisterInstance <IMsmqRepository>(mockMsmqRepository.Object); }
public void MessageQueueMessageQueueReaderMethodReadMessagesNoTransactional() { var mockMsmqRepository = new Moq.Mock <IMsmqRepository>(); mockMsmqRepository.Setup(x => x.Exists(It.IsAny <string>())).Returns(true); mockMsmqRepository.Setup(x => x.Create(It.IsAny <string>(), It.IsAny <bool>())); mockMsmqRepository.Setup(x => x.WriteMessage( It.IsAny <string>(), It.IsAny <object>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <System.Messaging.IMessageFormatter>())); mockMsmqRepository.Setup(x => x.Start()).Raises( x => x.MessageQueuesProcessed += null, new EngineEventArgs(string.Empty)); mockMsmqRepository.Setup(x => x.Close()); mockMsmqRepository.Setup(x => x.GetTotalMessages()).Returns(It.IsAny <int>()); mockMsmqRepository.Raise( x => x.MessageQueuesProcessed += null, new EngineEventArgs(It.IsAny <string>())); // add mock repositories to the container ServiceLocator.Container.RegisterInstance <IMsmqRepository>(mockMsmqRepository.Object); TestHelper.LoadMockFileSystemRepository(); string serverName = Environment.MachineName; string queuePath = "private$\\notrans"; MessageQueueReader messageQueueReader = new MessageQueueReader(queuePath, false, serverName); messageQueueReader.PersistMessageToDisk = false; messageQueueReader.MessageQueuesReaderProcessed += this.MessageQueuesProcessed; messageQueueReader.Start(this.TransmitQueue); Assert.IsTrue(true); }