public void TestInitialize()
        {
            queueManager      = Substitute.For <IQueueManagerAsync>();
            view              = Substitute.For <IExplorerView>();
            eventAggregator   = Substitute.For <IEventAggregator>();
            windowManagerEx   = Substitute.For <IWindowManagerEx>();
            networkOperations = Substitute.For <INetworkOperations>();
            explorer          = new QueueExplorerViewModel(queueManager, eventAggregator, windowManagerEx, networkOperations);

            queue    = new Queue("TestQueue");
            subQueue = new Queue("TestQueue.Subscriptions");

            IList <Queue> queues = new List <Queue> {
                queue, subQueue
            };

            queueManager.GetQueues(Arg.Any <string>()).Returns(Task.Run(() => queues));
            queueManager.GetQueues().Returns(Task.Run(() => queues));
            queueManager.GetMessageCount(Arg.Any <Queue>()).Returns(Task.Run(() => queues.Count));
            queueManager.IsMsmqInstalled(Arg.Any <string>()).Returns(Task.Run(() => true));

            AsyncHelper.Run(() => explorer.AttachView(view, null));
            AsyncHelper.Run(() => explorer.ConnectToQueue(Environment.MachineName));

            queueNode = explorer.MachineRoot.Children.OfType <QueueExplorerItem>().First();
        }
        public void should_refresh_message_count_for_the_queue_when_auto_refresh_event_is_triggerred()
        {
            queueManager.GetMessageCount(Arg.Any <Queue>()).Returns(Task.FromResult(5));

            queueManager.ClearReceivedCalls();
            explorer.Handle(new AutoRefreshBeat());

            queueManager.Received(1).GetMessageCount(Arg.Any <Queue>());
            explorer.MachineRoot.Children.FirstOrDefault(x => x.DisplayName.Contains("(5)")).ShouldNotBe(null);
        }
        public virtual async Task PartialRefresh()
        {
            if (MachineRoot == null)
            {
                return;
            }

            foreach (var explorerItem in MachineRoot.Children.OfType <QueueExplorerItem>())
            {
                var messageCount = await _queueManager.GetMessageCount(explorerItem.Queue);

                explorerItem.UpdateMessageCount(messageCount);
            }
        }
Beispiel #4
0
        public async Task RefreshData()
        {
            if (MachineRoot == null)
            {
                return;
            }

            MachineRoot.Children.Clear();

            var queues = await _queueManager.GetQueues(ConnectedToAddress);

            var sortedQueues = queues.OrderBy(x => x.Address).ToList();

            SetupQueueNodes(sortedQueues);

            foreach (var explorerItem in MachineRoot.Children.OfType <QueueExplorerItem>().ToList())
            {
                var messageCount = await _queueManager.GetMessageCount(explorerItem.Queue);

                explorerItem.UpdateMessageCount(messageCount);
            }
        }
        public void TestInitialize()
        {
            queueManager = Substitute.For<IQueueManagerAsync>();
            view = Substitute.For<IExplorerView>();
            eventAggregator = Substitute.For<IEventAggregator>();
            windowManagerEx = Substitute.For<IWindowManagerEx>();
            networkOperations = Substitute.For<INetworkOperations>();
            explorer = new QueueExplorerViewModel(queueManager, eventAggregator, windowManagerEx, networkOperations);

            queue = new Queue("TestQueue");
            subQueue = new Queue("TestQueue.Subscriptions");

            IList<Queue> queues = new List<Queue> { queue, subQueue };
            queueManager.GetQueues(Arg.Any<string>()).Returns(Task.Run(() => queues));
            queueManager.GetQueues().Returns(Task.Run(() => queues));
            queueManager.GetMessageCount(Arg.Any<Queue>()).Returns(Task.Run(() => queues.Count));
            queueManager.IsMsmqInstalled(Arg.Any<string>()).Returns(Task.Run(() => true));

            AsyncHelper.Run(() => explorer.AttachView(view, null));
            AsyncHelper.Run(() => explorer.ConnectToQueue(Environment.MachineName));

            queueNode = explorer.MachineRoot.Children.OfType<QueueExplorerItem>().First();
        }