public Overview GetOverview(bool forceDirty = false) { if (!Dirty(forceDirty)) return _cached; lock (_lock) { if (Dirty(forceDirty)) _cached = Fetch(); } return _cached; }
void GivenThatTheBusMonitorReturnsAnOverviewWithDuplicateQueues() { _expected = new Queue {Name = "testqueue"}; var overview = new Overview { Queues = new List<Queue> { _expected, new Queue { Name="testqueue" } }}; _busMonitor.GetOverview().Returns(overview); }
void GivenThatTheBusMonitorReturnsAnOverview(bool expectFresh) { _expected = new Queue {Name = "testqueue"}; var overview = new Overview { Queues = new List<Queue> { _expected, new Queue { Name="testqueue2" } }}; _busMonitor.GetOverview(expectFresh).Returns(overview); }
void GivenThatTheBusMonitorReturnsAnOverview() { _expected = new Overview { Queues = new List<Queue>() }; _busMonitor.GetOverview().Returns(_expected); }
private Overview Fetch() { var manager = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(_config.BusConnectionString); var overview = new Overview { Queues = manager.GetQueues().Select(e => new Queue { Status = e.Status.ToString(), ActiveMessageCount = e.MessageCountDetails.ActiveMessageCount, DeadLetterCount = e.MessageCountDetails.DeadLetterMessageCount, ScheduledMessageCount = e.MessageCountDetails.ScheduledMessageCount, TransferMessageCount = e.MessageCountDetails.TransferMessageCount, DeadTransferMessageCount = e.MessageCountDetails.TransferDeadLetterMessageCount, SizeInBytes = e.SizeInBytes, AutoDeleteOnIdle = new Time(e.AutoDeleteOnIdle), DefaultMessageTTL = new Time(e.DefaultMessageTimeToLive), DuplicateDetectionWindow = new Time(e.DuplicateDetectionHistoryTimeWindow), LockDuration = new Time(e.LockDuration), CreatedAt = e.CreatedAt, UpdatedAt = e.UpdatedAt, AccessedAt = e.AccessedAt, Name = e.Path }).ToList(), Topics = manager.GetTopics().Select(e => new Topic { Status = e.Status.ToString(), Name = e.Path, SizeInBytes = e.SizeInBytes, AutoDeleteOnIdle = new Time(e.AutoDeleteOnIdle), DefaultMessageTTL = new Time(e.DefaultMessageTimeToLive), DuplicateDetectionWindow = new Time(e.DuplicateDetectionHistoryTimeWindow), CreatedAt = e.CreatedAt, UpdatedAt = e.UpdatedAt, AccessedAt = e.AccessedAt, }).ToList(), }; foreach (var topic in overview.Topics) { topic.Subscriptions = manager.GetSubscriptions(topic.Name).Select(e => new Subscription { Status = e.Status.ToString(), Name = e.Name, TopicName = topic.Name, ActiveMessageCount = e.MessageCountDetails.ActiveMessageCount, DeadLetterCount = e.MessageCountDetails.DeadLetterMessageCount, ScheduledMessageCount = e.MessageCountDetails.ScheduledMessageCount, TransferMessageCount = e.MessageCountDetails.TransferMessageCount, DeadTransferMessageCount = e.MessageCountDetails.TransferDeadLetterMessageCount, AutoDeleteOnIdle = new Time(e.AutoDeleteOnIdle), DefaultMessageTTL = new Time(e.DefaultMessageTimeToLive), LockDuration = new Time(e.LockDuration), CreatedAt = e.CreatedAt, UpdatedAt = e.UpdatedAt, AccessedAt = e.AccessedAt, Rules = manager.GetRules(topic.Name, e.Name).Select(MapRule).ToList() }).ToList(); topic.ActiveMessageCount = topic.Subscriptions.Sum(s => s.ActiveMessageCount); topic.DeadLetterCount = topic.Subscriptions.Sum(s => s.DeadLetterCount); topic.ScheduledMessageCount = topic.Subscriptions.Sum(s => s.ScheduledMessageCount); topic.TransferMessageCount = topic.Subscriptions.Sum(s => s.TransferMessageCount); topic.DeadTransferMessageCount = topic.Subscriptions.Sum(s => s.DeadTransferMessageCount); } return overview; }
void GivenThatTheBusMonitorReturnsAnOverviewWithDuplicateSubscriptions() { _expected = new Subscription { Name = "testsubscription" }; var overview = new Overview { Topics = new List<Topic> { new Topic { Name="testtopic", Subscriptions = new List<Subscription> { _expected, _expected}}, new Topic { Name="testtopic2", Subscriptions = new List<Subscription> { _expected}}, } }; _busMonitor.GetOverview().Returns(overview); }
void GivenThatTheBusMonitorReturnsAnOverview(bool expectFresh) { _expected = new Subscription { Name = "testsubscription" }; var overview = new Overview { Topics = new List<Topic> { new Topic { Name="testtopic", Subscriptions = new List<Subscription> { _expected}}, new Topic { Name="testtopic2", Subscriptions = new List<Subscription> { new Subscription { Name="testsubscription2" }}}, } }; _busMonitor.GetOverview(expectFresh).Returns(overview); }
void GivenThatTheBusMonitorReturnsAnOverviewWithDuplicateTopics() { _expected = new Topic { Name = "testtopic" }; var overview = new Overview { Topics = new List<Topic> { _expected, new Topic { Name="testtopic" } } }; _busMonitor.GetOverview().Returns(overview); }
void GivenThatTheBusMonitorReturnsAnOverview(bool expectFresh) { _expected = new Topic { Name = "testtopic" }; var overview = new Overview { Topics = new List<Topic> { _expected, new Topic { Name="testtopic2" } } }; _busMonitor.GetOverview(expectFresh).Returns(overview); }
void WhenBuildingModel() { _result = _builder.Build(); }